usage();
System.exit(-1); // NOPMD, this is not a JEE app
}
UserDataVOWS userdata = new UserDataVOWS();
userdata.setUsername(args[ARG_USERNAME]);
String pwd = args[ARG_PASSWORD];
if (StringUtils.equalsIgnoreCase("null", pwd)) {
pwd = null;
}
userdata.setPassword(pwd);
userdata.setClearPwd(args[ARG_CLEARPWD].equalsIgnoreCase("true"));
userdata.setSubjectDN(args[ARG_SUBJECTDN]);
if(!args[ARG_SUBJECTALTNAME].equalsIgnoreCase("NULL")){
userdata.setSubjectAltName(args[ARG_SUBJECTALTNAME]);
}
if(!args[ARG_EMAIL].equalsIgnoreCase("NULL")){
userdata.setEmail(args[ARG_EMAIL]);
}
userdata.setCaName(args[ARG_CA]);
userdata.setTokenType(args[ARG_TOKEN]);
userdata.setStatus(getStatus(args[ARG_STATUS]));
userdata.setEndEntityProfileName(args[ARG_ENDENTITYPROFILE]);
userdata.setCertificateProfileName(args[ARG_CERTIFICATEPROFILE]);
int type = Integer.parseInt(args[ARG_TYPE]);
if((type & SecConst.USER_SENDNOTIFICATION) != 0){
userdata.setSendNotification(true);
}
if((type & SecConst.USER_KEYRECOVERABLE) != 0){
userdata.setKeyRecoverable(true);
}
if(args.length > 13){
if(!args[ARG_ISSUERALIAS].equalsIgnoreCase("NULL")){
userdata.setHardTokenIssuerName(args[ARG_ISSUERALIAS]);
}
}
if(args.length > 14){
if(!args[ARG_STARTTIME].equalsIgnoreCase("NULL")){
userdata.setStartTime(args[ARG_STARTTIME]);
}
}
if(args.length > 15){
if(!args[ARG_ENDTIME].equalsIgnoreCase("NULL")){
userdata.setEndTime(args[ARG_ENDTIME]);
}
}
getPrintStream().println("Trying to add user:");
getPrintStream().println("Username: "+userdata.getUsername());
getPrintStream().println("Subject DN: "+userdata.getSubjectDN());
getPrintStream().println("Subject Altname: "+userdata.getSubjectAltName());
getPrintStream().println("Email: "+userdata.getEmail());
getPrintStream().println("CA Name: "+userdata.getCaName());
getPrintStream().println("Type: "+type);
getPrintStream().println("Token: "+userdata.getTokenType());
getPrintStream().println("Status: "+userdata.getStatus());
getPrintStream().println("End entity profile: "+userdata.getEndEntityProfileName());
getPrintStream().println("Certificate profile: "+userdata.getCertificateProfileName());
if(userdata.getHardTokenIssuerName() == null){
getPrintStream().println("Hard Token Issuer Alias: NONE");
}else{
getPrintStream().println("Hard Token Issuer Alias: " + userdata.getHardTokenIssuerName());
}
if(userdata.getStartTime() == null){
getPrintStream().println("Start time: NONE");
}else{
getPrintStream().println("Start time: "+userdata.getStartTime());
}
if(userdata.getEndTime() == null){
getPrintStream().println("End time: NONE");
}else{
getPrintStream().println("End time: "+userdata.getEndTime());
}
try{
getEjbcaRAWS().editUser(userdata);
getPrintStream().println("User '"+userdata.getUsername()+"' has been added/edited.");
getPrintStream().println();
}catch(AuthorizationDeniedException_Exception e){
getPrintStream().println("Error : " + e.getMessage());
}catch(UserDoesntFullfillEndEntityProfile_Exception e){
getPrintStream().println("Error : Given userdata doesn't fullfill end entity profile. : " + e.getMessage());