📄 certificateprofile.java
字号:
public void setExtendedKeyUsageCritical(boolean critical) { data.put(EXTENDEDKEYUSAGECRITICAL, Boolean.valueOf(critical)); } public boolean getExtendedKeyUsageCritical() { return ((Boolean) data.get(EXTENDEDKEYUSAGECRITICAL)).booleanValue(); } /** * Extended Key Usage is an arraylist of constant Integers. */ public void setExtendedKeyUsage(ArrayList extendedkeyusage) { data.put(EXTENDEDKEYUSAGE, extendedkeyusage); } /** * Extended Key Usage is an arraylist of constant Integers. */ public ArrayList getExtendedKeyUsage() { return (ArrayList) data.get(EXTENDEDKEYUSAGE); } public boolean getUseMicrosoftTemplate(){ return ((Boolean) data.get(USEMICROSOFTTEMPLATE)).booleanValue(); } public void setUseMicrosoftTemplate(boolean use){ data.put(USEMICROSOFTTEMPLATE, Boolean.valueOf(use)); } public String getMicrosoftTemplate(){ return (String) data.get(MICROSOFTTEMPLATE); } public void setMicrosoftTemplate(String mstemplate){ data.put(MICROSOFTTEMPLATE, mstemplate); } public boolean getUseCNPostfix(){ return ((Boolean) data.get(USECNPOSTFIX)).booleanValue(); } public void setUseCNPostfix(boolean use) { data.put(USECNPOSTFIX, Boolean.valueOf(use)); } public String getCNPostfix(){ return (String) data.get(CNPOSTFIX); } public void setCNPostfix(String cnpostfix) { data.put(CNPOSTFIX, cnpostfix); } public boolean getUseSubjectDNSubSet(){ return ((Boolean) data.get(USESUBJECTDNSUBSET)).booleanValue(); } public void setUseSubjectDNSubSet(boolean use) { data.put(USESUBJECTDNSUBSET, Boolean.valueOf(use)); } /** * Returns a collection of Integer (DNFieldExtractor constants) indicating * which subject dn fields that should be used in certificate. * */ public Collection getSubjectDNSubSet(){ return (Collection) data.get(SUBJECTDNSUBSET); } /** * Should contain a collection of Integer (DNFieldExtractor constants) indicating * which subject dn fields that should be used in certificate. * */ public void setSubjectDNSubSet(Collection subjectdns) { data.put(SUBJECTDNSUBSET, subjectdns); } /** * Method taking a full user dn and returns a DN only containing the * DN fields specified in the subjectdn sub set array. * * @param dn * @return a subset of original DN */ public String createSubjectDNSubSet(String dn){ DNFieldExtractor extractor = new DNFieldExtractor(dn,DNFieldExtractor.TYPE_SUBJECTDN); return constructUserData(extractor, getSubjectDNSubSet(), true); } public boolean getUseSubjectAltNameSubSet(){ return ((Boolean) data.get(USESUBJECTALTNAMESUBSET)).booleanValue(); } public void setUseSubjectAltNameSubSet(boolean use) { data.put(USESUBJECTALTNAMESUBSET, Boolean.valueOf(use)); } /** * Returns a collection of Integer (DNFieldExtractor constants) indicating * which subject altnames fields that should be used in certificate. * */ public Collection getSubjectAltNameSubSet(){ return (Collection) data.get(SUBJECTALTNAMESUBSET); } /** * Returns a collection of Integer (DNFieldExtractor constants) indicating * which subject altnames fields that should be used in certificate. * */ public void setSubjectAltNameSubSet(Collection subjectaltnames) { data.put(SUBJECTALTNAMESUBSET, subjectaltnames); } /** * Method taking a full user dn and returns a AltName only containing the * AltName fields specified in the subjectaltname sub set array. * * @param dn * @return a subset of original DN */ public String createSubjectAltNameSubSet(String subjectaltname){ DNFieldExtractor extractor = new DNFieldExtractor(subjectaltname,DNFieldExtractor.TYPE_SUBJECTALTNAME); return constructUserData(extractor, getSubjectAltNameSubSet(), false); } /** * Help method converting a full DN or Subject Alt Name to one usng only specified fields * @param extractor * @param usefields * @return */ protected String constructUserData(DNFieldExtractor extractor, Collection usefields, boolean subjectdn){ String retval = ""; if(usefields instanceof List){ Collections.sort((List) usefields); } Iterator iter = usefields.iterator(); String dnField = null; while(iter.hasNext()){ Integer next = (Integer) iter.next(); dnField = getDNField(extractor, next.intValue(), subjectdn); if (StringUtils.isNotEmpty(dnField)) { if(retval.length() == 0) retval += dnField; // first item, don't start with a comma else retval += "," + dnField; } } log.debug("CertificateProfile: constructed DN or AltName: " + retval ); return retval; } protected String getDNField(DNFieldExtractor extractor, int field, boolean subjectdn){ String retval = ""; String[] fieldnames = DNFieldExtractor.SUBJECTDNFIELDS; int f = field; if(!subjectdn){ fieldnames = DNFieldExtractor.SUBJECTALTNAME; f = field - DNFieldExtractor.SUBJECTALTERNATIVENAMEBOUNDRARY; } int num = extractor.getNumberOfFields(field); for(int i=0;i<num;i++){ if(retval.length() == 0) retval += fieldnames[f] + extractor.getField(field,i); else retval += "," + fieldnames[f] + extractor.getField(field,i); } return retval; } /** * Returns an ArrayList of OID.strings defined in constant EXTENDEDKEYUSAGEOIDSTRINGS. */ public ArrayList getExtendedKeyUsageAsOIDStrings(){ ArrayList returnval = new ArrayList(); ArrayList eku = (ArrayList) data.get(EXTENDEDKEYUSAGE); Iterator i = eku.iterator(); while(i.hasNext()) returnval.add(EXTENDEDKEYUSAGEOIDSTRINGS[((Integer) i.next()).intValue()]); return returnval; } /** * Returns a Collections of caids (Integer), indicating which CAs the profile should * be applicable to. * * If it contains the constant ANYCA then the profile is applicable to all CAs */ public Collection getAvailableCAs(){ return (Collection) data.get(AVAILABLECAS); } /** * Saves the CertificateProfile's list of CAs the cert profile is applicable to. * * @param availablecas a Collection of caids (Integer) */ public void setAvailableCAs(Collection availablecas){ data.put(AVAILABLECAS, availablecas); } public boolean isApplicableToAnyCA(){ return ((Collection) data.get(AVAILABLECAS)).contains(new Integer(ANYCA)); } /** * Returns a Collection of publisher id's (Integer) indicating which publishers a certificate * created with this profile should be published to. */ public Collection getPublisherList(){ return (Collection) data.get(USEDPUBLISHERS); } /** * Saves the CertificateProfile's list of publishers that certificates created with this profile * should be published to. * * @param publishers a Collection of publisherids (Integer) */ public void setPublisherList(Collection publisher){ data.put(USEDPUBLISHERS, publisher); } /** * Method indicating that Path Length Constain should be used in the BasicConstaint * */ public boolean getUsePathLengthConstraint(){ return ((Boolean) data.get(USEPATHLENGTHCONSTRAINT)).booleanValue(); } /** * Method indicating that Path Length Constain should be used in the BasicConstaint * */ public void setUsePathLengthConstraint(boolean use) { data.put(USEPATHLENGTHCONSTRAINT, Boolean.valueOf(use)); } public int getPathLengthConstraint(){ return ((Integer) data.get(PATHLENGTHCONSTRAINT)).intValue(); } public void setPathLengthConstraint(int pathlength) { data.put(PATHLENGTHCONSTRAINT, new Integer(pathlength)); } public boolean getUseOCSPServiceLocator(){ return ((Boolean) data.get(USEOCSPSERVICELOCATOR)).booleanValue(); } public void setUseOCSPServiceLocator(boolean useocspservicelocator) { data.put(USEOCSPSERVICELOCATOR, Boolean.valueOf(useocspservicelocator));} public String getOCSPServiceLocatorURI(){ return (String) data.get(OCSPSERVICELOCATORURI); } public void setOCSPServiceLocatorURI(String ocspservicelocatoruri) { if(ocspservicelocatoruri==null) data.put(OCSPSERVICELOCATORURI,""); else data.put(OCSPSERVICELOCATORURI,ocspservicelocatoruri); } public Object clone() throws CloneNotSupportedException { CertificateProfile clone = new CertificateProfile(); HashMap clonedata = (HashMap) clone.saveData(); Iterator i = (data.keySet()).iterator(); while(i.hasNext()){ Object key = i.next(); clonedata.put(key, data.get(key)); } clone.loadData(clonedata); return clone; } /** Implemtation of UpgradableDataHashMap function getLatestVersion */ public float getLatestVersion(){ return LATEST_VERSION; } /** Implemtation of UpgradableDataHashMap function upgrade. */ public void upgrade(){ log.debug(">upgrade"); if(LATEST_VERSION != getVersion()){ // New version of the class, upgrade log.info("upgrading certificateprofile with version "+getVersion()); data.put(VERSION, new Float(LATEST_VERSION)); if(data.get(ALLOWKEYUSAGEOVERRIDE) == null) data.put(ALLOWKEYUSAGEOVERRIDE, Boolean.TRUE); if(data.get(USEEXTENDEDKEYUSAGE) ==null) data.put(USEEXTENDEDKEYUSAGE, Boolean.FALSE); if(data.get(EXTENDEDKEYUSAGE) ==null) data.put(EXTENDEDKEYUSAGE, new ArrayList()); if(data.get(EXTENDEDKEYUSAGECRITICAL) == null) data.put(EXTENDEDKEYUSAGECRITICAL, Boolean.FALSE); if(data.get(AVAILABLECAS) == null){ ArrayList availablecas = new ArrayList(); availablecas.add(new Integer(ANYCA)); data.put(AVAILABLECAS, availablecas); } if(data.get(USEDPUBLISHERS) == null){ data.put(USEDPUBLISHERS, new ArrayList()); } if(data.get(USEOCSPSERVICELOCATOR) == null){ setUseOCSPServiceLocator(false); setOCSPServiceLocatorURI(""); } if(data.get(USEMICROSOFTTEMPLATE) == null){ setUseMicrosoftTemplate(false); setMicrosoftTemplate(""); } if(data.get(USECNPOSTFIX) == null){ setUseCNPostfix(false); setCNPostfix(""); } if(data.get(USESUBJECTDNSUBSET) == null){ setUseSubjectDNSubSet(false); setSubjectDNSubSet(new ArrayList()); setUseSubjectAltNameSubSet(false); setSubjectAltNameSubSet(new ArrayList()); } if(data.get(USEPATHLENGTHCONSTRAINT) == null){ setUsePathLengthConstraint(false); setPathLengthConstraint(0); } } log.debug("<upgrade"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -