diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java | 76 |
1 files changed, 37 insertions, 39 deletions
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java b/pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java index 547e370ad..b33698863 100644 --- a/pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java +++ b/pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.publish.mappers; - import java.io.IOException; import java.io.PushbackReader; import java.io.StringReader; @@ -31,25 +30,25 @@ import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.ldap.ELdapException; import com.netscape.certsrv.request.IRequest; - /** - * class for parsing a DN pattern used to construct a ldap dn from - * request attributes and cert subject name.<p> + * class for parsing a DN pattern used to construct a ldap dn from + * request attributes and cert subject name. + * <p> * - * dnpattern is a string representing a ldap dn pattern to formulate from - * the certificate subject name attributes and request attributes . - * If empty or not set, the certificate subject name - * will be used as the ldap dn. <p> + * dnpattern is a string representing a ldap dn pattern to formulate from the certificate subject name attributes and request attributes . If empty or not set, the certificate subject name will be used as the ldap dn. + * <p> + * + * The syntax is * - * The syntax is * <pre> - * dnPattern := rdnPattern *[ "," rdnPattern ] - * rdnPattern := avaPattern *[ "+" avaPattern ] + * dnPattern := rdnPattern *[ "," rdnPattern ] + * rdnPattern := avaPattern *[ "+" avaPattern ] * avaPattern := name "=" value | - * name "=" "$subj" "." attrName [ "." attrNumber ] | - * name "=" "$req" "." attrName [ "." attrNumber ] | - * "$rdn" "." number + * name "=" "$subj" "." attrName [ "." attrNumber ] | + * name "=" "$req" "." attrName [ "." attrNumber ] | + * "$rdn" "." number * </pre> + * * <pre> * Example1: <i>cn=Certificate Manager,ou=people,o=mcom.com</i> * cert subject name: dn: CN=Certificate Manager, OU=people, O=mcom.com @@ -60,7 +59,7 @@ import com.netscape.certsrv.request.IRequest; * <p> * note: Subordinate ca enrollment will use ca mapper. Use predicate * to distinguish the ca itself and the subordinates. - * + * * Example2: <i>UID=$req.HTTP_PARAMS.uid, OU=$subj.ou, O=people, , O=mcom.com</i> * cert subject name: dn: UID=jjames, OU=IS, O=people, , O=mcom.com * request attributes: uid: cmanager @@ -73,10 +72,9 @@ import com.netscape.certsrv.request.IRequest; * O = the string people, mcom.com. <br> * <p> * </pre> - * If an request attribute or subject DN component does not exist, - * the attribute is skipped. There is potential risk that a wrong dn - * will be mapped into. - * + * + * If an request attribute or subject DN component does not exist, the attribute is skipped. There is potential risk that a wrong dn will be mapped into. + * * @version $Revision$, $Date$ */ public class MapDNPattern { @@ -95,16 +93,17 @@ public class MapDNPattern { protected String mTestDN = null; - /** + /** * Construct a DN pattern by parsing a pattern string. + * * @param pattern the DN pattern - * @exception EBaseException If parsing error occurs. + * @exception EBaseException If parsing error occurs. */ public MapDNPattern(String pattern) - throws ELdapException { + throws ELdapException { if (pattern == null || pattern.equals("")) { CMS.debug( - "MapDNPattern: null pattern"); + "MapDNPattern: null pattern"); } else { mPatternString = pattern; PushbackReader in = new PushbackReader(new StringReader(pattern)); @@ -113,13 +112,13 @@ public class MapDNPattern { } } - public MapDNPattern(PushbackReader in) - throws ELdapException { + public MapDNPattern(PushbackReader in) + throws ELdapException { parse(in); } private void parse(PushbackReader in) - throws ELdapException { + throws ELdapException { Vector rdnPatterns = new Vector(); MapRDNPattern rdnPattern = null; int lastChar = -1; @@ -133,8 +132,7 @@ public class MapDNPattern { throw new ELdapException( CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString())); } - } - while (lastChar == ','); + } while (lastChar == ','); mRDNPatterns = new MapRDNPattern[rdnPatterns.size()]; rdnPatterns.copyInto(mRDNPatterns); @@ -144,8 +142,8 @@ public class MapDNPattern { for (int i = 0; i < mRDNPatterns.length; i++) { String[] rdnAttrs = mRDNPatterns[i].getReqAttrs(); - if (rdnAttrs != null && rdnAttrs.length > 0) - for (int j = 0; j < rdnAttrs.length; j++) + if (rdnAttrs != null && rdnAttrs.length > 0) + for (int j = 0; j < rdnAttrs.length; j++) reqAttrs.addElement(rdnAttrs[j]); } mReqAttrs = new String[reqAttrs.size()]; @@ -156,8 +154,8 @@ public class MapDNPattern { for (int i = 0; i < mRDNPatterns.length; i++) { String[] rdnAttrs = mRDNPatterns[i].getCertAttrs(); - if (rdnAttrs != null && rdnAttrs.length > 0) - for (int j = 0; j < rdnAttrs.length; j++) + if (rdnAttrs != null && rdnAttrs.length > 0) + for (int j = 0; j < rdnAttrs.length; j++) certAttrs.addElement(rdnAttrs[j]); } mCertAttrs = new String[certAttrs.size()]; @@ -166,12 +164,13 @@ public class MapDNPattern { /** * Form a Ldap v3 DN string from a request and a cert subject name. + * * @param req the request for (un)publish * @param subject the subjectDN of the certificate - * @return Ldap v3 DN string to use for base ldap search. + * @return Ldap v3 DN string to use for base ldap search. */ public String formDN(IRequest req, X500Name subject, CertificateExtensions ext) - throws ELdapException { + throws ELdapException { StringBuffer formedDN = new StringBuffer(); for (int i = 0; i < mRDNPatterns.length; i++) { @@ -180,11 +179,11 @@ public class MapDNPattern { String rdn = mRDNPatterns[i].formRDN(req, subject, ext); if (rdn != null && rdn.length() != 0) { - if (formedDN.length() != 0) - formedDN.append(","); - formedDN.append(rdn); + if (formedDN.length() != 0) + formedDN.append(","); + formedDN.append(rdn); } else { - throw new ELdapException("pattern not matched"); + throw new ELdapException("pattern not matched"); } } return formedDN.toString(); @@ -198,4 +197,3 @@ public class MapDNPattern { return (String[]) mCertAttrs.clone(); } } - |