⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 raaddusercommand.java

📁 一个免费的CA,基于EJB平台的,老师叫我们测试,现把之共享出来让大家参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    getOutputStream().print(", ");                                        getOutputStream().print(certificateprofileidtonamemap.get(iter.next()));                }                getOutputStream().print("\n");                getOutputStream().print("Existing endentity profiles  : ");                first = true;                iter = endentityprofileids.iterator();                while(iter.hasNext()){                  if(first)                                        first= false;                  else                    getOutputStream().print(", ");                                        getOutputStream().print(endentityprofileidtonamemap.get(iter.next()));                }                                getOutputStream().print("\n");                if( usehardtokens && hardtokenissueraliases.length > 0){                                  getOutputStream().print("Existing hardtoken issuers  : ");                  for(int i=0; i < hardtokenissueraliases.length-1; i++){                    getOutputStream().print(hardtokenissueraliases[i] + ", ");                  }                  getOutputStream().print(hardtokenissueraliases[hardtokenissueraliases.length-1] + "\n");                               }                getOutputStream().println(                    "If the user does not have a SubjectAltName or an email address,\n or you want the password to be auto-generated use the value 'null'. ");                return;            }            String username = args[1];            String password = args[2];            String dn = args[3];            String subjectaltname = args[4];            String caname  = args[5];            String email = args[6];            int type  = Integer.parseInt(args[7]);            String tokenname = args[8];            int profileid =  SecConst.EMPTY_ENDENTITYPROFILE;            int certificatetypeid = SecConst.CERTPROFILE_FIXED_ENDUSER;            int hardtokenissuerid = SecConst.NO_HARDTOKENISSUER;            boolean error = false;            boolean usehardtokenissuer = false;            int caid = 0;            try{              caid = caadminsession.getCAInfo(administrator, caname).getCAId();            }catch(Exception e){                           }                        if(args.length > 9){              // Use certificate type, no end entity profile.              certificatetypeid = certificatesession.getCertificateProfileId(administrator, args[9]);              getOutputStream().println("Using certificate profile: "+args[9]+", with id: "+certificatetypeid);            }            if(args.length > 10){              // Use certificate type and end entity profile.              profileid = raadminsession.getEndEntityProfileId(administrator, args[10]);              getOutputStream().println("Using entity profile: "+args[10]+", with id: "+profileid);            }            if(args.length == 12 && usehardtokens){              // Use certificate type, end entity profile and hardtokenisseur.              hardtokenissuerid = hardtokensession.getHardTokenIssuerId(administrator,args[11]);              usehardtokenissuer = true;              getOutputStream().println("Using hard token issuer: "+args[11]+", with id: "+hardtokenissuerid);            }                        int tokenid =getTokenId(administrator, tokenname, usehardtokens, hardtokensession);            if (tokenid == 0) {                getOutputStream().println("Error : Invalid token id.");                error = true;            }            if (certificatetypeid == SecConst.PROFILE_NO_PROFILE) { // Certificate profile not found i database.                getOutputStream().println("Error : Couldn't find certificate profile in database.");                error = true;            }            if(profileid == 0){ // End entity profile not found i database.              getOutputStream().println("Error : Couldn't find end entity profile in database." );              error = true;            }                        if(caid == 0){ // CA not found i database.              getOutputStream().println("Error : Couldn't find CA in database." );              error = true;            }                        if(usehardtokenissuer && hardtokenissuerid == SecConst.NO_HARDTOKENISSUER){              getOutputStream().println("Error : Couldn't find hard token issuer in database." );              error = true;                   }              if ((tokenid > SecConst.TOKEN_SOFT) &&                    (hardtokenissuerid == SecConst.NO_HARDTOKENISSUER)) {                getOutputStream().println(                    "Error : HardTokenIssuer has to be choosen when user with hard tokens is added.");                error = true;            }            if (email.equalsIgnoreCase("NULL") &&                    ((type & SecConst.USER_SENDNOTIFICATION) == SecConst.USER_SENDNOTIFICATION)) {                getOutputStream().println(                    "Error : Email field cannot be null when send notification type is given.");                error = true;            }            // Check if username already exists.            try {                if (getAdminSession().findUser(administrator, username) != null) {                    getOutputStream().println("Error : User already exists in the database.");                    error = true;                }            } catch (FinderException e) {            }            if(!error){              getOutputStream().println("Trying to add user:");              getOutputStream().println("Username: "+username);              getOutputStream().println("Password (hashed only): "+password);              getOutputStream().println("DN: "+dn);              getOutputStream().println("CA Name: "+caname);              getOutputStream().println("SubjectAltName: "+subjectaltname);              getOutputStream().println("Email: "+email);              getOutputStream().println("Type: "+type);              getOutputStream().println("Token: "+tokenname);              getOutputStream().println("Certificate profile: "+certificatetypeid);              getOutputStream().println("End entity profile: "+profileid);			  if (password.toUpperCase().equals("NULL"))				  password = null;              if (subjectaltname.toUpperCase().equals("NULL"))                  subjectaltname = null;              if (email.toUpperCase().equals("NULL"))                  email = null;              try{                getAdminSession().addUser(administrator, username, password, dn, subjectaltname, email, false, profileid, certificatetypeid,                                         type, tokenid, hardtokenissuerid, caid);                getOutputStream().println("User '"+username+"' has been added.");                getOutputStream().println();                getOutputStream().println("Note: If batch processing should be possible, \nalso use 'ra setclearpwd "+username+" <pwd>'.");              }catch(AuthorizationDeniedException e){                  getOutputStream().println("Error : " + e.getMessage());              }catch(UserDoesntFullfillEndEntityProfile e){                 getOutputStream().println("Error : Given userdata doesn't fullfill end entity profile. : " +  e.getMessage());              }            }        } catch (Exception e) {            throw new ErrorAdminCommandException(e);        }    }    // execute    /**     *  Returns the tokenid type of the user, returns 0 if invalid tokenname.         */        private int getTokenId(Admin administrator, String tokenname, boolean usehardtokens, IHardTokenSessionRemote hardtokensession) throws RemoteException {        int returnval = 0;                // First check for soft token type        for(int i=0;i< softtokennames.length;i++){        	if(softtokennames[i].equals(tokenname)){        		returnval = softtokenids[i];        		break;        	}        	        }        if (returnval == 0 && usehardtokens) {             returnval = hardtokensession.getHardTokenProfileId(administrator , tokenname);        }        return returnval;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -