📄 endentityprofile.java
字号:
if(data.get(REVERSEFFIELDCHECKS) == null){ return false; } return ((Boolean) data.get(REVERSEFFIELDCHECKS)).booleanValue(); } public void setReverseFieldChecks(boolean reverse){ data.put(REVERSEFFIELDCHECKS, new Boolean(reverse)); } /** * @return indicationg printing of userdata should be done * default is false. */ public boolean getUsePrinting(){ if(data.get(PRINTINGUSE) == null){ return false; } return ((Boolean) data.get(PRINTINGUSE)).booleanValue(); } public void setUsePrinting(boolean use){ data.put(PRINTINGUSE, new Boolean(use)); } /** * @return indicationg printing of userdata should be done * default is false. */ public boolean getPrintingDefault(){ if(data.get(PRINTINGDEFAULT) == null){ return false; } return ((Boolean) data.get(PRINTINGDEFAULT)).booleanValue(); } public void setPrintingDefault(boolean printDefault){ data.put(PRINTINGDEFAULT, new Boolean(printDefault)); } /** * @return indicationg printing of userdata should be done * default is false. */ public boolean getPrintingRequired(){ if(data.get(PRINTINGREQUIRED) == null){ return false; } return ((Boolean) data.get(PRINTINGREQUIRED)).booleanValue(); } public void setPrintingRequired(boolean printRequired){ data.put(PRINTINGREQUIRED, new Boolean(printRequired)); } /** * @return the number of copies that should be printed * default is 1. */ public int getPrintedCopies(){ if(data.get(PRINTINGCOPIES) == null){ return 1; } return ((Integer) data.get(PRINTINGCOPIES)).intValue(); } public void setPrintedCopies(int copies){ data.put(PRINTINGCOPIES, new Integer(copies)); } /** * @return the name of the printer that should be used */ public String getPrinterName(){ if(data.get(PRINTINGPRINTERNAME) == null){ return ""; } return (String) data.get(PRINTINGPRINTERNAME); } public void setPrinterName(String printerName){ data.put(PRINTINGPRINTERNAME, printerName); } /** * @return filename of the uploaded */ public String getPrinterSVGFileName(){ if(data.get(PRINTINGSVGFILENAME) == null){ return ""; } return (String) data.get(PRINTINGSVGFILENAME); } public void setPrinterSVGFileName(String printerSVGFileName){ data.put(PRINTINGSVGFILENAME, printerSVGFileName); } /** * @return the data of the SVG file, if no content have * been uploaded null is returned */ public String getPrinterSVGData(){ if(data.get(PRINTINGSVGDATA) == null){ return null; } return new String(Base64.decode(((String) data.get(PRINTINGSVGDATA)).getBytes())); } public void setPrinterSVGData(String sVGData){ data.put(PRINTINGSVGDATA, new String(Base64.encode(sVGData.getBytes()))); } public void doesUserFullfillEndEntityProfile(String username, String password, String dn, String subjectaltname, String subjectdirattr, String email, int certificateprofileid, boolean clearpwd, boolean administrator, boolean keyrecoverable, boolean sendnotification, int tokentype, int hardwaretokenissuerid, int caid) throws UserDoesntFullfillEndEntityProfile{ if(useAutoGeneratedPasswd()){ if(password !=null) throw new UserDoesntFullfillEndEntityProfile("Autogenerated password must have password==null"); }else{ if(!isModifyable(PASSWORD,0)){ if(!password.equals(getValue(PASSWORD,0))) throw new UserDoesntFullfillEndEntityProfile("Password didn't match requirement of it's profile."); } else if(isRequired(PASSWORD,0)){ if(password == null || password.trim().equals("")) throw new UserDoesntFullfillEndEntityProfile("Password cannot be empty or null."); } } if(!getUse(CLEARTEXTPASSWORD,0) && clearpwd) throw new UserDoesntFullfillEndEntityProfile("Clearpassword (used in batch proccessing) cannot be used."); if(isRequired(CLEARTEXTPASSWORD,0)){ if(getValue(CLEARTEXTPASSWORD,0).equals(TRUE) && !clearpwd) throw new UserDoesntFullfillEndEntityProfile("Clearpassword (used in batch proccessing) cannot be false."); if(getValue(CLEARTEXTPASSWORD,0).equals(FALSE) && clearpwd) throw new UserDoesntFullfillEndEntityProfile("Clearpassword (used in batch proccessing) cannot be true."); } doesUserFullfillEndEntityProfileWithoutPassword(username, dn, subjectaltname, subjectdirattr, email, certificateprofileid, administrator, keyrecoverable, sendnotification, tokentype, hardwaretokenissuerid, caid); } public void doesUserFullfillEndEntityProfileWithoutPassword(String username, String dn, String subjectaltname, String subjectdirattr, String email, int certificateprofileid, boolean administrator, boolean keyrecoverable, boolean sendnotification, int tokentype, int hardwaretokenissuerid, int caid) throws UserDoesntFullfillEndEntityProfile{ DNFieldExtractor subjectdnfields = new DNFieldExtractor(dn, DNFieldExtractor.TYPE_SUBJECTDN); if (subjectdnfields.isIllegal()) { throw new UserDoesntFullfillEndEntityProfile("Subject DN is illegal."); } DNFieldExtractor subjectaltnames = new DNFieldExtractor(subjectaltname, DNFieldExtractor.TYPE_SUBJECTALTNAME); if (subjectaltnames.isIllegal()) { throw new UserDoesntFullfillEndEntityProfile("Subject alt names are illegal."); } DNFieldExtractor subjectdirattrs = new DNFieldExtractor(subjectdirattr, DNFieldExtractor.TYPE_SUBJECTDIRATTR); if (subjectdirattrs.isIllegal()) { throw new UserDoesntFullfillEndEntityProfile("Subject directory attributes are illegal."); } // Check that no other than supported dn fields exists in the subject dn. if(subjectdnfields.existsOther()) throw new UserDoesntFullfillEndEntityProfile("Unsupported Subject DN Field found in:" + dn); if(subjectaltnames.existsOther()) throw new UserDoesntFullfillEndEntityProfile("Unsupported Subject Alternate Name Field found in:" + subjectaltname ); if(subjectdirattrs.existsOther()) throw new UserDoesntFullfillEndEntityProfile("Unsupported Subject Directory Attribute Field found in:" + subjectdirattr ); checkIfAllRequiredFieldsExists(subjectdnfields, subjectaltnames, subjectdirattrs, username, email); checkIfForIllegalNumberOfFields(subjectdnfields, subjectaltnames, subjectdirattrs); // Check contents of username. checkIfDataFullfillProfile(USERNAME,0,username, "Username",null); // Check Email address. if(email == null) email = ""; checkIfDomainFullfillProfile(EMAIL,0,email,"Email"); // Check contents of Subject DN fields. HashMap subjectdnfieldnumbers = subjectdnfields.getNumberOfFields(); Integer[] dnids = DNFieldExtractor.getUseFields(DNFieldExtractor.TYPE_SUBJECTDN); for(int i = 0; i < dnids.length; i++){ Integer dnid = dnids[i]; int nof = ((Integer)subjectdnfieldnumbers.get(dnid)).intValue(); if(getReverseFieldChecks()){ for(int j=getNumberOfField(DnComponents.dnIdToProfileName(dnid.intValue())) -1; j >= 0; j--){ checkIfDataFullfillProfile(DnComponents.dnIdToProfileName(dnid.intValue()),j,subjectdnfields.getField(dnid.intValue(),--nof), DnComponents.getErrTextFromDnId(dnid.intValue()), email); } }else{ for(int j=0; j < nof; j++){ checkIfDataFullfillProfile(DnComponents.dnIdToProfileName(dnid.intValue()),j,subjectdnfields.getField(dnid.intValue(),j), DnComponents.getErrTextFromDnId(dnid.intValue()), email); } } } // Check contents of Subject Alternative Name fields. HashMap subjectaltnamesnumbers = subjectaltnames.getNumberOfFields(); Integer[] altnameids = DNFieldExtractor.getUseFields(DNFieldExtractor.TYPE_SUBJECTALTNAME); for(int i = 0; i < altnameids.length; i++){ Integer altnameid = altnameids[i]; int nof = ((Integer)subjectaltnamesnumbers.get(altnameid)).intValue(); if(getReverseFieldChecks()){ for(int j=getNumberOfField(DnComponents.dnIdToProfileName(altnameid.intValue())) -1; j >= 0; j--){ if(i == DNFieldExtractor.UPN){ checkIfDomainFullfillProfile(DnComponents.UPN,j,subjectaltnames.getField(altnameid.intValue(),--nof),"UPN"); }else{ checkIfDataFullfillProfile(DnComponents.dnIdToProfileName(altnameid.intValue()),j,subjectaltnames.getField(altnameid.intValue(),--nof), DnComponents.getErrTextFromDnId(altnameid.intValue()), email); } } }else{ for(int j=0; j < nof; j++){ if(altnameid.intValue() == DNFieldExtractor.UPN){ checkIfDomainFullfillProfile(DnComponents.UPN,j,subjectaltnames.getField(altnameid.intValue(),j),"UPN"); }else{ checkIfDataFullfillProfile(DnComponents.dnIdToProfileName(altnameid.intValue()),j,subjectaltnames.getField(altnameid.intValue(),j), DnComponents.getErrTextFromDnId(altnameid.intValue()), email); } } } } // Check contents of Subject Directory Attributes fields. HashMap subjectdirattrnumbers = subjectdirattrs.getNumberOfFields(); Integer[] dirattrids = DNFieldExtractor.getUseFields(DNFieldExtractor.TYPE_SUBJECTDIRATTR); for(int i = 0; i < dirattrids.length; i++){ Integer dirattrid = dirattrids[i]; int nof = ((Integer)subjectdirattrnumbers.get(dirattrid)).intValue(); for(int j=0; j < nof; j++){ checkForIllegalChars(subjectdirattrs.getField(dirattrid.intValue(),j)); if(dirattrid.intValue() == DNFieldExtractor.COUNTRYOFCITIZENSHIP){ checkIfISO3166FullfillProfile(DnComponents.COUNTRYOFCITIZENSHIP,j,subjectdirattrs.getField(dirattrid.intValue(),j),"COUNTRYOFCITIZENSHIP"); } else if(dirattrid.intValue() == DNFieldExtractor.COUNTRYOFRESIDENCE){ checkIfISO3166FullfillProfile(DnComponents.COUNTRYOFRESIDENCE,j,subjectdirattrs.getField(dirattrid.intValue(),j),"COUNTRYOFRESIDENCE"); } else if(dirattrid.intValue() == DNFieldExtractor.DATEOFBIRTH){ checkIfDateFullfillProfile(DnComponents.DATEOFBIRTH,j,subjectdirattrs.getField(dirattrid.intValue(),j),"DATEOFBIRTH"); } else if(dirattrid.intValue() == DNFieldExtractor.GENDER){ checkIfGenderFullfillProfile(DnComponents.GENDER,j,subjectdirattrs.getField(dirattrid.intValue(),j),"GENDER"); }else{ checkIfDataFullfillProfile(DnComponents.dnIdToProfileName(dirattrid.intValue()),j,subjectdirattrs.getField(dirattrid.intValue(),j), DnComponents.getErrTextFromDnId(dirattrid.intValue()), email); } } } // Check for administrator flag. if(!getUse(ADMINISTRATOR,0) && administrator) throw new UserDoesntFullfillEndEntityProfile("Administrator cannot be set."); if(isRequired(ADMINISTRATOR,0)){ if(getValue(ADMINISTRATOR,0).equals(TRUE) && !administrator) throw new UserDoesntFullfillEndEntityProfile("Administrator flag is required."); if(getValue(ADMINISTRATOR,0).equals(FALSE) && administrator) throw new UserDoesntFullfillEndEntityProfile("Administrator flag cannot be set in current end entity profile."); } // Check for keyrecoverable flag. if(!getUse(KEYRECOVERABLE,0) && keyrecoverable) throw new UserDoesntFullfillEndEntityProfile("Key Recoverable cannot be used."); if(isRequired(KEYRECOVERABLE,0)){ if(getValue(KEYRECOVERABLE,0).equals(TRUE) && !keyrecoverable) throw new UserDoesntFullfillEndEntityProfile("Key Recoverable is required."); if(getValue(KEYRECOVERABLE,0).equals(FALSE) && keyrecoverable) throw new UserDoesntFullfillEndEntityProfile("Key Recoverable cannot be set in current end entity profile."); } // Check for send notification flag. if(!getUse(SENDNOTIFICATION,0) && sendnotification) throw new UserDoesntFullfillEndEntityProfile("Email notification cannot be used."); if(isRequired(SENDNOTIFICATION,0)){ if(getValue(SENDNOTIFICATION,0).equals(TRUE) && !sendnotification) throw new UserDoesntFullfillEndEntityProfile("Email notification is required."); if(getValue(SENDNOTIFICATION,0).equals(FALSE) && sendnotification) throw new UserDoesntFullfillEndEntityProfile("Email notification cannot be set in current end entity profile."); } // Check if certificate profile is among available certificate profiles. String[] availablecertprofiles; try{ availablecertprofiles = getValue(AVAILCERTPROFILES,0).split(SPLITCHAR);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -