}
if(tokentype.equals(TYPE_ENCHANCEDEID)) {
profiledata = new EnhancedEIDProfile();
}
if(tokentype.equals(TYPE_TURKISHEID)) {
profiledata = new TurkishEIDProfile();
}
}
// Save changes.
// General settings
String value = request.getParameter(TEXTFIELD_SNPREFIX);
if(value != null){
value = value.trim();
profiledata.setHardTokenSNPrefix(value);
}
value = request.getParameter(CHECKBOX_EREASBLE);
if(value != null){
profiledata.setEreasableToken(value.equals(CHECKBOX_VALUE));
}else {
profiledata.setEreasableToken(false);
}
value = request.getParameter(SELECT_NUMOFTOKENCOPIES);
if(value != null){
profiledata.setNumberOfCopies(Integer.parseInt(value));
}
value = request.getParameter(CHECKBOX_USEIDENTICALPINS);
if(value != null){
profiledata.setGenerateIdenticalPINForCopies(value.equals(CHECKBOX_VALUE));
}else {
profiledata.setGenerateIdenticalPINForCopies(false);
}
if(profiledata instanceof HardTokenProfileWithPINEnvelope){
value = request.getParameter(SELECT_ENVELOPETYPE);
if(value != null) {
((HardTokenProfileWithPINEnvelope) profiledata).setPINEnvelopeType(Integer.parseInt(value));
}
value = request.getParameter(SELECT_NUMOFENVELOPECOPIES);
if(value != null) {
((HardTokenProfileWithPINEnvelope) profiledata).setNumberOfPINEnvelopeCopies(Integer.parseInt(value));
}
value = request.getParameter(TEXTFIELD_VISUALVALIDITY);
if(value != null) {
((HardTokenProfileWithPINEnvelope) profiledata).setVisualValidity(Integer.parseInt(value));
}
}
if(profiledata instanceof HardTokenProfileWithVisualLayout){
HardTokenProfileWithVisualLayout visprof = (HardTokenProfileWithVisualLayout) profiledata;
value = request.getParameter(SELECT_VISUALLAYOUTTYPE);
if(value != null) {
visprof.setVisualLayoutType(Integer.parseInt(value));
}
}
if(profiledata instanceof HardTokenProfileWithReceipt){
value = request.getParameter(SELECT_RECEIPTTYPE);
if(value != null) {
((HardTokenProfileWithReceipt) profiledata).setReceiptType(Integer.parseInt(value));
}
value = request.getParameter(SELECT_NUMOFRECEIPTCOPIES);
if(value != null) {
((HardTokenProfileWithReceipt) profiledata).setNumberOfReceiptCopies(Integer.parseInt(value));
}
}
if(profiledata instanceof HardTokenProfileWithAdressLabel){
value = request.getParameter(SELECT_ADRESSLABELTYPE);
if(value != null) {
((HardTokenProfileWithAdressLabel) profiledata).setAdressLabelType(Integer.parseInt(value));
}
value = request.getParameter(SELECT_NUMOFADRESSLABELCOPIES);
if(value != null) {
((HardTokenProfileWithAdressLabel) profiledata).setNumberOfAdressLabelCopies(Integer.parseInt(value));
}
}
if(profiledata instanceof SwedishEIDProfile){
SwedishEIDProfile sweprof = (SwedishEIDProfile) profiledata;
value = request.getParameter(SELECT_MINKEYLENGTH);
if(value!= null){
int val = Integer.parseInt(value);
sweprof.setMinimumKeyLength(SwedishEIDProfile.CERTUSAGE_SIGN, val);
sweprof.setMinimumKeyLength(SwedishEIDProfile.CERTUSAGE_AUTHENC, val);
sweprof.setKeyType(SwedishEIDProfile.CERTUSAGE_SIGN, EIDProfile.KEYTYPE_RSA);
sweprof.setKeyType(SwedishEIDProfile.CERTUSAGE_AUTHENC, EIDProfile.KEYTYPE_RSA);
}
value = request.getParameter(CHECKBOX_CERTWRITABLE);
if(value != null){
sweprof.setCertWritable(SwedishEIDProfile.CERTUSAGE_SIGN, value.equals(CHECKBOX_VALUE));
sweprof.setCertWritable(SwedishEIDProfile.CERTUSAGE_AUTHENC, value.equals(CHECKBOX_VALUE));
}else{
sweprof.setCertWritable(SwedishEIDProfile.CERTUSAGE_SIGN, false);
sweprof.setCertWritable(SwedishEIDProfile.CERTUSAGE_AUTHENC, false);
}
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "0");
if(value!= null) {
sweprof.setCertificateProfileId(SwedishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "0");
if(value!= null) {
sweprof.setCAId(SwedishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_PINTYPE + "0");
if(value!= null) {
sweprof.setPINType(SwedishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_MINPINLENGTH + "0");
if(value!= null) {
sweprof.setMinimumPINLength(SwedishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "1");
if(value!= null) {
sweprof.setCertificateProfileId(SwedishEIDProfile.CERTUSAGE_AUTHENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "1");
if(value!= null) {
sweprof.setCAId(SwedishEIDProfile.CERTUSAGE_AUTHENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_PINTYPE + "1");
if(value!= null) {
sweprof.setPINType(SwedishEIDProfile.CERTUSAGE_AUTHENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_MINPINLENGTH + "1");
if(value!= null) {
sweprof.setMinimumPINLength(SwedishEIDProfile.CERTUSAGE_AUTHENC, Integer.parseInt(value));
}
}
if(profiledata instanceof TurkishEIDProfile){
TurkishEIDProfile turkprof = (TurkishEIDProfile) profiledata;
value = request.getParameter(SELECT_MINKEYLENGTH);
if(value!= null){
int val = Integer.parseInt(value);
turkprof.setMinimumKeyLength(TurkishEIDProfile.CERTUSAGE_SIGN, val);
turkprof.setMinimumKeyLength(TurkishEIDProfile.CERTUSAGE_AUTHENC, val);
turkprof.setKeyType(TurkishEIDProfile.CERTUSAGE_SIGN, EIDProfile.KEYTYPE_RSA);
turkprof.setKeyType(TurkishEIDProfile.CERTUSAGE_AUTHENC, EIDProfile.KEYTYPE_RSA);
}
value = request.getParameter(CHECKBOX_CERTWRITABLE);
if(value != null){
turkprof.setCertWritable(TurkishEIDProfile.CERTUSAGE_SIGN, value.equals(CHECKBOX_VALUE));
turkprof.setCertWritable(TurkishEIDProfile.CERTUSAGE_AUTHENC, value.equals(CHECKBOX_VALUE));
}else{
turkprof.setCertWritable(TurkishEIDProfile.CERTUSAGE_SIGN, false);
turkprof.setCertWritable(TurkishEIDProfile.CERTUSAGE_AUTHENC, false);
}
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "0");
if(value!= null) {
turkprof.setCertificateProfileId(TurkishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "0");
if(value!= null) {
turkprof.setCAId(TurkishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_PINTYPE + "0");
if(value!= null) {
turkprof.setPINType(TurkishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_MINPINLENGTH + "0");
if(value!= null) {
turkprof.setMinimumPINLength(TurkishEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "1");
if(value!= null) {
turkprof.setCertificateProfileId(TurkishEIDProfile.CERTUSAGE_AUTHENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "1");
if(value!= null) {
turkprof.setCAId(TurkishEIDProfile.CERTUSAGE_AUTHENC, Integer.parseInt(value));
}
}
if(profiledata instanceof EnhancedEIDProfile){
EnhancedEIDProfile enhprof = (EnhancedEIDProfile) profiledata;
value = request.getParameter(SELECT_MINKEYLENGTH);
if(value!= null){
int val = Integer.parseInt(value);
enhprof.setMinimumKeyLength(EnhancedEIDProfile.CERTUSAGE_SIGN, val);
enhprof.setMinimumKeyLength(EnhancedEIDProfile.CERTUSAGE_AUTH, val);
enhprof.setMinimumKeyLength(EnhancedEIDProfile.CERTUSAGE_ENC, val);
enhprof.setKeyType(EnhancedEIDProfile.CERTUSAGE_SIGN, EIDProfile.KEYTYPE_RSA);
enhprof.setKeyType(EnhancedEIDProfile.CERTUSAGE_ENC, EIDProfile.KEYTYPE_RSA);
enhprof.setKeyType(EnhancedEIDProfile.CERTUSAGE_ENC, EIDProfile.KEYTYPE_RSA);
}
value = request.getParameter(CHECKBOX_CERTWRITABLE);
if(value != null){
enhprof.setCertWritable(EnhancedEIDProfile.CERTUSAGE_SIGN, value.equals(CHECKBOX_VALUE));
enhprof.setCertWritable(EnhancedEIDProfile.CERTUSAGE_AUTH, value.equals(CHECKBOX_VALUE));
enhprof.setCertWritable(EnhancedEIDProfile.CERTUSAGE_ENC, value.equals(CHECKBOX_VALUE));
}else{
enhprof.setCertWritable(EnhancedEIDProfile.CERTUSAGE_SIGN, false);
enhprof.setCertWritable(EnhancedEIDProfile.CERTUSAGE_AUTH, false);
enhprof.setCertWritable(EnhancedEIDProfile.CERTUSAGE_ENC, false);
}
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "0");
if(value!= null) {
enhprof.setCertificateProfileId(EnhancedEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "0");
if(value!= null) {
enhprof.setCAId(EnhancedEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_PINTYPE + "0");
if(value!= null) {
enhprof.setPINType(EnhancedEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
value = request.getParameter(SELECT_MINPINLENGTH + "0");
if(value!= null) {
enhprof.setMinimumPINLength(EnhancedEIDProfile.CERTUSAGE_SIGN, Integer.parseInt(value));
}
enhprof.setIsKeyRecoverable(EnhancedEIDProfile.CERTUSAGE_SIGN, false);
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "1");
if(value!= null) {
enhprof.setCertificateProfileId(EnhancedEIDProfile.CERTUSAGE_AUTH, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "1");
if(value!= null) {
enhprof.setCAId(EnhancedEIDProfile.CERTUSAGE_AUTH, Integer.parseInt(value));
}
value = request.getParameter(SELECT_PINTYPE + "1");
if(value!= null) {
enhprof.setPINType(EnhancedEIDProfile.CERTUSAGE_AUTH, Integer.parseInt(value));
}
value = request.getParameter(SELECT_MINPINLENGTH + "1");
if(value!= null) {
enhprof.setMinimumPINLength(EnhancedEIDProfile.CERTUSAGE_AUTH, Integer.parseInt(value));
}
enhprof.setIsKeyRecoverable(EnhancedEIDProfile.CERTUSAGE_AUTH, false);
value = request.getParameter(SELECT_CERTIFICATEPROFILE + "2");
if(value!= null) {
enhprof.setCertificateProfileId(EnhancedEIDProfile.CERTUSAGE_ENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_CA + "2");
if(value!= null) {
enhprof.setCAId(EnhancedEIDProfile.CERTUSAGE_ENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_PINTYPE + "2");
if(value!= null) {
enhprof.setPINType(EnhancedEIDProfile.CERTUSAGE_ENC, Integer.parseInt(value));
}
value = request.getParameter(SELECT_MINPINLENGTH + "2");
if(value!= null) {
enhprof.setMinimumPINLength(EnhancedEIDProfile.CERTUSAGE_ENC, Integer.parseInt(value));
}
value = request.getParameter(CHECKBOX_KEYRECOVERABLE + "2");
if(value != null) {
enhprof.setIsKeyRecoverable(EnhancedEIDProfile.CERTUSAGE_ENC, value.equals(CHECKBOX_VALUE));
} else {
enhprof.setIsKeyRecoverable(EnhancedEIDProfile.CERTUSAGE_ENC, false);
}
value = request.getParameter(CHECKBOX_REUSEOLDCERT + "2");
if(value != null) {
enhprof.setReuseOldCertificate(EnhancedEIDProfile.CERTUSAGE_ENC, value.equals(CHECKBOX_VALUE));
} else {
enhprof.setReuseOldCertificate(EnhancedEIDProfile.CERTUSAGE_ENC, false);
}
}
if(request.getParameter(BUTTON_SAVE) != null){
if(!handler.changeHardTokenProfile(profile,profiledata)){
profilemalformed = true;
}
includefile=PAGE_HARDTOKENPROFILES;
}
if(request.getParameter(BUTTON_UPLOADENVELOPETEMP) != null){
uploadmode = UPLOADMODE_ENVELOPE;
includefile=PAGE_UPLOADTEMPLATE;
}
if(request.getParameter(BUTTON_UPLOADVISUALTEMP) != null){
uploadmode = UPLOADMODE_VISUAL;
includefile=PAGE_UPLOADTEMPLATE;
}
if(request.getParameter(BUTTON_UPLOADRECEIPTTEMP) != null){
uploadmode = UPLOADMODE_RECEIPT;
includefile=PAGE_UPLOADTEMPLATE;
}
if(request.getParameter(BUTTON_UPLOADADRESSLABELTEMP) != null){
uploadmode = UPLOADMODE_ADRESSLABEL;
includefile=PAGE_UPLOADTEMPLATE;
}
}
if(request.getParameter(BUTTON_CANCEL) != null){
// Don't save changes.
includefile=PAGE_HARDTOKENPROFILES;
}
}
}
}
if( action.equals(ACTION_CHANGE_PROFILETYPE)){
this.profilename = request.getParameter(HIDDEN_HARDTOKENPROFILENAME);
String value = request.getParameter(SELECT_HARDTOKENTYPE);
if(value!=null){
int profiletype = Integer.parseInt(value);
EIDProfile newprofile = null;
switch(profiletype){
case SwedishEIDProfile.TYPE_SWEDISHEID :
newprofile = new SwedishEIDProfile();
break;
case EnhancedEIDProfile.TYPE_ENHANCEDEID:
newprofile = new EnhancedEIDProfile();
break;
case TurkishEIDProfile.TYPE_TURKISHEID:
newprofile = new TurkishEIDProfile();
break;
}
if(profiledata != null && profiledata instanceof EIDProfile){
((EIDProfile) profiledata).clone(newprofile);
newprofile.reInit();