summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/publish
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2012-01-11 12:57:53 -0500
committerAde Lee <alee@redhat.com>2012-01-11 13:49:04 -0500
commit10cfe7756e967ac91c66d33b392aeab9cf3780fb (patch)
treed5ac9b58442265d2ce5ef60e31f041ddacba1b4f /pki/base/common/src/com/netscape/cms/publish
parentedcb24f65cc3700e75d0a1d14dc2483f210b0ee4 (diff)
downloadpki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.gz
pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.xz
pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.zip
Formatting (no line wrap in comments or code)
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/publish')
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/AVAPattern.java139
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapCaSimpleMap.java141
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertCompsMap.java47
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertExactMap.java53
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertSubjMap.java106
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapCrlIssuerCompsMap.java49
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapDNCompsMap.java156
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapEnhancedMap.java290
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/LdapSimpleMap.java108
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/MapAVAPattern.java227
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/MapDNPattern.java76
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/MapRDNPattern.java73
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/mappers/NoMap.java24
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java171
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java168
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertSubjPublisher.java91
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertificatePairPublisher.java85
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java129
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/LdapEncryptCertPublisher.java53
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java104
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java164
-rw-r--r--pki/base/common/src/com/netscape/cms/publish/publishers/Utils.java7
22 files changed, 1205 insertions, 1256 deletions
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/AVAPattern.java b/pki/base/common/src/com/netscape/cms/publish/mappers/AVAPattern.java
index d7d496d46..0cb367031 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/AVAPattern.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/AVAPattern.java
@@ -20,7 +20,6 @@
package com.netscape.cms.publish.mappers;
-
///////////////////////
// import statements //
///////////////////////
@@ -49,7 +48,6 @@ import com.netscape.certsrv.ldap.ELdapException;
import com.netscape.certsrv.publish.ECompSyntaxErr;
import com.netscape.certsrv.request.IRequest;
-
//////////////////////
// class definition //
//////////////////////
@@ -60,13 +58,15 @@ import com.netscape.certsrv.request.IRequest;
* subject name, extension or request attributes.
* <p>
*
- * The syntax is
+ * The syntax is
+ *
* <pre>
* avaPattern := constant-value |
* "$subj" "." attrName [ "." attrNumber ] |
* "$req" "." [ prefix .] attrName [ "." attrNumber ] |
- * "$ext" "." extName [ "." nameType ] [ "." attrNumber ]
+ * "$ext" "." extName [ "." nameType ] [ "." attrNumber ]
* </pre>
+ *
* <pre>
* Example: <i>$ext.SubjectAlternativeName.RFC822Name.1</i>
* cert subjectAltName is rfc822Name: jjames@mcom.com
@@ -77,9 +77,9 @@ import com.netscape.certsrv.request.IRequest;
* The first rfc822name value in the subjAltName extension. <br>
* <p>
* </pre>
- * If a request attribute or subject DN component does not exist,
- * the attribute is skipped.
- *
+ *
+ * If a request attribute or subject DN component does not exist, the attribute is skipped.
+ *
* @version $Revision$, $Date$
*/
class AVAPattern {
@@ -101,12 +101,12 @@ class AVAPattern {
"EDIName",
"URIName",
"IPAddress",
- "OIDName"};
+ "OIDName" };
private static final char[] endChars = new char[] { '+', ',' };
- private static final LdapV3DNStrConverter mLdapDNStrConverter =
- new LdapV3DNStrConverter();
+ private static final LdapV3DNStrConverter mLdapDNStrConverter =
+ new LdapV3DNStrConverter();
/* the list of request attributes needed by this AVA */
protected String[] mReqAttrs = null;
@@ -140,7 +140,7 @@ class AVAPattern {
/////////////
public AVAPattern(String component)
- throws ELdapException {
+ throws ELdapException {
if (component == null || component.length() == 0) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", component));
}
@@ -148,13 +148,13 @@ class AVAPattern {
parse(new PushbackReader(new StringReader(component)));
}
- public AVAPattern(PushbackReader in)
- throws ELdapException {
+ public AVAPattern(PushbackReader in)
+ throws ELdapException {
parse(in);
}
private void parse(PushbackReader in)
- throws ELdapException {
+ throws ELdapException {
int c;
// skip spaces
@@ -169,7 +169,7 @@ class AVAPattern {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "All blank"));
}
- if (c == -1) {
+ if (c == -1) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "All blank"));
}
@@ -189,9 +189,9 @@ class AVAPattern {
if (c == 'r') {
try {
- if (in.read() != 'e' ||
- in.read() != 'q' ||
- in.read() != '.') {
+ if (in.read() != 'e' ||
+ in.read() != 'q' ||
+ in.read() != '.') {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $req in ava pattern"));
}
@@ -204,10 +204,10 @@ class AVAPattern {
//System.out.println("---- mtype $req");
} else if (c == 's') {
try {
- if (in.read() != 'u' ||
- in.read() != 'b' ||
- in.read() != 'j' ||
- in.read() != '.') {
+ if (in.read() != 'u' ||
+ in.read() != 'b' ||
+ in.read() != 'j' ||
+ in.read() != '.') {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $subj in ava pattern"));
}
@@ -220,9 +220,9 @@ class AVAPattern {
//System.out.println("----- mtype $subj");
} else if (c == 'e') {
try {
- if (in.read() != 'x' ||
- in.read() != 't' ||
- in.read() != '.') {
+ if (in.read() != 'x' ||
+ in.read() != 't' ||
+ in.read() != '.') {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $ext in ava pattern"));
}
@@ -235,7 +235,7 @@ class AVAPattern {
//System.out.println("----- mtype $ext");
} else {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
- "unknown keyword. expecting $subj $ext or $req."));
+ "unknown keyword. expecting $subj $ext or $req."));
}
// get request attribute or
@@ -245,14 +245,14 @@ class AVAPattern {
StringBuffer valueBuf = new StringBuffer();
try {
- while ((c = in.read()) != ',' &&
- c != -1 && c != '.' && c != '+') {
+ while ((c = in.read()) != ',' &&
+ c != -1 && c != '.' && c != '+') {
//System.out.println("mValue read "+(char)c);
valueBuf.append((char) c);
}
if (c == '+' || c == ',') { // either ',' or '+'
- in.unread(c); // pushback last , or +
+ in.unread(c); // pushback last , or +
}
} catch (IOException e) {
throw new ELdapException(
@@ -260,7 +260,7 @@ class AVAPattern {
}
mValue = valueBuf.toString().trim();
- if (mValue.length() == 0) {
+ if (mValue.length() == 0) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"$subj $ext or $req attribute name expected"));
}
@@ -272,13 +272,13 @@ class AVAPattern {
try {
while ((c = in.read()) != ',' && c != -1 && c != '.'
- && c != '+') {
+ && c != '+') {
//System.out.println("mElement read "+(char)c);
attrNumberBuf.append((char) c);
}
if (c == ',' || c == '+') { // either ',' or '+'
- in.unread(c); // pushback last , or +
+ in.unread(c); // pushback last , or +
}
} catch (IOException e) {
throw new ELdapException(
@@ -304,7 +304,7 @@ class AVAPattern {
} else {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"Invalid format in nth element " +
- "$req $ext or $subj"));
+ "$req $ext or $subj"));
}
// get nth request attribute .
@@ -313,14 +313,14 @@ class AVAPattern {
try {
while ((c = in.read()) != ',' &&
- c != -1 && c != '+') {
+ c != -1 && c != '+') {
//System.out.println("mElement read "+
// (char)c);
attrNumberBuf1.append((char) c);
}
- if (c != -1) { // either ',' or '+'
- in.unread(c); // pushback last , or +
+ if (c != -1) { // either ',' or '+'
+ in.unread(c); // pushback last , or +
}
} catch (IOException ex) {
throw new ELdapException(
@@ -328,18 +328,18 @@ class AVAPattern {
}
String attrNumber1 =
- attrNumberBuf1.toString().trim();
+ attrNumberBuf1.toString().trim();
if (attrNumber1.length() == 0) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "nth element $req or $ext expected"));
}
- try {
- mElement = Integer.parseInt(attrNumber1) - 1;
+ try {
+ mElement = Integer.parseInt(attrNumber1) - 1;
} catch (NumberFormatException ex) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"Invalid format in nth element " +
- "$req or $ext."));
+ "$req or $ext."));
}
}
}
@@ -361,7 +361,7 @@ class AVAPattern {
}
if (c == '+' || c == ',') { // either ',' or '+'
- in.unread(c); // pushback last , or +
+ in.unread(c); // pushback last , or +
}
} catch (IOException e) {
throw new ELdapException(
@@ -383,9 +383,9 @@ class AVAPattern {
}
public String formAVA(IRequest req,
- X500Name subject,
- CertificateExtensions extensions)
- throws ELdapException {
+ X500Name subject,
+ CertificateExtensions extensions)
+ throws ELdapException {
if (TYPE_CONSTANT.equals(mType)) {
return mValue;
}
@@ -393,7 +393,7 @@ class AVAPattern {
if (TYPE_SUBJ.equals(mType)) {
String dn = subject.toString();
- if (mTestDN != null) {
+ if (mTestDN != null) {
dn = mTestDN;
}
@@ -410,8 +410,8 @@ class AVAPattern {
for (int j = 0; j < avas.length; j++) {
String[] exploded = explodeAVA(avas[j]);
- if (exploded[0].equalsIgnoreCase(mValue) &&
- ++nFound == mElement) {
+ if (exploded[0].equalsIgnoreCase(mValue) &&
+ ++nFound == mElement) {
value = exploded[1];
break;
}
@@ -431,10 +431,10 @@ class AVAPattern {
for (int i = 0; i < extensions.size(); i++) {
Extension ext = (Extension)
- extensions.elementAt(i);
+ extensions.elementAt(i);
String extName =
- OIDMap.getName(ext.getExtensionId());
+ OIDMap.getName(ext.getExtensionId());
int index = extName.lastIndexOf(".");
@@ -450,9 +450,9 @@ class AVAPattern {
SubjectAlternativeNameExtension.NAME)) {
try {
GeneralNames subjectNames = (GeneralNames)
- ((SubjectAlternativeNameExtension)
+ ((SubjectAlternativeNameExtension)
ext).get(
- SubjectAlternativeNameExtension.SUBJECT_NAME);
+ SubjectAlternativeNameExtension.SUBJECT_NAME);
if (subjectNames.size() == 0) {
break;
@@ -461,11 +461,10 @@ class AVAPattern {
int j = 0;
for (Enumeration<GeneralNameInterface> n =
- subjectNames.elements();
- n.hasMoreElements();) {
+ subjectNames.elements(); n.hasMoreElements();) {
GeneralName gn = (GeneralName)
- n.nextElement();
+ n.nextElement();
String gname = gn.toString();
@@ -476,7 +475,7 @@ class AVAPattern {
}
String gType =
- gname.substring(0, index);
+ gname.substring(0, index);
if (mGNType != null) {
if (mGNType.equalsIgnoreCase(gType)) {
@@ -497,12 +496,12 @@ class AVAPattern {
j++;
}
}
- } catch (IOException e) {
+ } catch (IOException e) {
CMS.debug(
- "AVAPattern: Publishing attr not formed " +
- "from extension " +
- "-- no attr : " +
- mValue);
+ "AVAPattern: Publishing attr not formed " +
+ "from extension " +
+ "-- no attr : " +
+ mValue);
}
}
}
@@ -510,10 +509,10 @@ class AVAPattern {
}
CMS.debug(
- "AVAPattern: Publishing:attr not formed " +
- "from extension " +
- "-- no attr : " +
- mValue);
+ "AVAPattern: Publishing:attr not formed " +
+ "from extension " +
+ "-- no attr : " +
+ mValue);
return null;
}
@@ -522,8 +521,7 @@ class AVAPattern {
// mPrefix and mValue are looked up case-insensitive
String reqAttr = req.getExtDataInString(mPrefix, mValue);
if (reqAttr == null) {
- throw new
- ELdapException(
+ throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_NO_REQUEST", mValue, ""));
}
@@ -550,10 +548,10 @@ class AVAPattern {
}
/**
- * Explode RDN into AVAs.
- * Does not handle escaped '+'
+ * Explode RDN into AVAs.
+ * Does not handle escaped '+'
* Java ldap library does not yet support multiple avas per rdn.
- * If RDN is malformed returns empty array.
+ * If RDN is malformed returns empty array.
*/
public static String[] explodeRDN(String rdn) {
int plus = rdn.indexOf('+');
@@ -578,7 +576,7 @@ class AVAPattern {
}
/**
- * Explode AVA into name and value.
+ * Explode AVA into name and value.
* Does not handle escaped '='
* If AVA is malformed empty array is returned.
*/
@@ -593,4 +591,3 @@ class AVAPattern {
ava.substring(equals + 1).trim() };
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCaSimpleMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCaSimpleMap.java
index 3cf1bca82..368143442 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCaSimpleMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCaSimpleMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.io.IOException;
import java.security.cert.X509Certificate;
import java.util.Locale;
@@ -48,20 +47,19 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
+/**
* Maps a request to an entry in the LDAP server.
* Takes a dnPattern to form the baseDN from the request attributes
- * and certificate subject name.Do a base search for the entry
+ * and certificate subject name.Do a base search for the entry
* in the directory to publish the cert or crl.
* The restriction of this mapper is that the ldap dn components must
* be part of certificate subject name or request attributes or constant.
- *
+ *
* @version $Revision$, $Date$
*/
public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
- protected static final String PROP_DNPATTERN = "dnPattern";
- protected static final String PROP_CREATECA = "createCAEntry";
+ protected static final String PROP_DNPATTERN = "dnPattern";
+ protected static final String PROP_CREATECA = "createCAEntry";
protected String mDnPattern = null;
protected boolean mCreateCAEntry = true;
@@ -79,13 +77,13 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
protected String[] mCertAttrs = null;
/* default dn pattern if left blank or not set in the config */
- public static final String DEFAULT_DNPATTERN =
- "UID=$req.HTTP_PARAMS.UID, OU=people, O=$subj.o, C=$subj.c";
+ public static final String DEFAULT_DNPATTERN =
+ "UID=$req.HTTP_PARAMS.UID, OU=people, O=$subj.o, C=$subj.c";
- /**
+ /**
* Constructor.
- *
- * @param dnPattern The base DN.
+ *
+ * @param dnPattern The base DN.
*/
public LdapCaSimpleMap(String dnPattern) {
try {
@@ -93,7 +91,7 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
} catch (EBaseException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString()));
}
-
+
}
/**
@@ -105,11 +103,11 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
public String[] getExtendedPluginInfo(Locale locale) {
String params[] = {
"dnPattern;string;Describes how to form the Ldap Subject name in" +
- " the directory. Example 1: 'uid=CertMgr, o=Fedora'. Example 2:" +
- " 'uid=$req.HTTP_PARAMS.uid, E=$ext.SubjectAlternativeName.RFC822Name, ou=$subj.ou'. " +
- "$req means: take the attribute from the request. " +
- "$subj means: take the attribute from the certificate subject name. " +
- "$ext means: take the attribute from the certificate extension",
+ " the directory. Example 1: 'uid=CertMgr, o=Fedora'. Example 2:" +
+ " 'uid=$req.HTTP_PARAMS.uid, E=$ext.SubjectAlternativeName.RFC822Name, ou=$subj.ou'. " +
+ "$req means: take the attribute from the request. " +
+ "$subj means: take the attribute from the certificate subject name. " +
+ "$ext means: take the attribute from the certificate extension",
"createCAEntry;boolean;If checked, CA entry will be created automatically",
IExtendedPluginInfo.HELP_TOKEN + ";configuration-ldappublish-mapper-casimplemapper",
IExtendedPluginInfo.HELP_TEXT + ";Describes how to form the LDAP DN of the entry to publish to"
@@ -122,11 +120,11 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
return mConfig;
}
- /**
+ /**
* for initializing from config store.
*/
- public void init(IConfigStore config)
- throws EBaseException {
+ public void init(IConfigStore config)
+ throws EBaseException {
mConfig = config;
String dnPattern = mConfig.getString(PROP_DNPATTERN);
@@ -138,12 +136,12 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
* common initialization routine.
*/
protected void init(String dnPattern)
- throws EBaseException {
- if (mInited)
+ throws EBaseException {
+ if (mInited)
return;
mDnPattern = dnPattern;
- if (mDnPattern == null || mDnPattern.length() == 0)
+ if (mDnPattern == null || mDnPattern.length() == 0)
mDnPattern = DEFAULT_DNPATTERN;
try {
mPattern = new MapDNPattern(mDnPattern);
@@ -151,7 +149,7 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
String[] mCertAttrs = mPattern.getCertAttrs();
} catch (ELdapException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_DN_PATTERN_INIT", dnPattern, e.toString()));
- throw new EBaseException("falied to init with pattern " +
+ throw new EBaseException("falied to init with pattern " +
dnPattern + " " + e);
}
@@ -162,12 +160,12 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
* Maps a X500 subject name to LDAP entry.
* Uses DN pattern to form a DN for a LDAP base search.
*
- * @param conn the LDAP connection.
- * @param obj the object to map.
+ * @param conn the LDAP connection.
+ * @param obj the object to map.
* @exception ELdapException if any LDAP exceptions occured.
- */
+ */
public String map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, null, obj);
}
@@ -175,13 +173,13 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
* Maps a X500 subject name to LDAP entry.
* Uses DN pattern to form a DN for a LDAP base search.
*
- * @param conn the LDAP connection.
- * @param req the request to map.
- * @param obj the object to map.
+ * @param conn the LDAP connection.
+ * @param req the request to map.
+ * @param obj the object to map.
* @exception ELdapException if any LDAP exceptions occured.
- */
+ */
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null)
return null;
String dn = null;
@@ -204,26 +202,26 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
String[] attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO, "searching for dn: " + dn + " filter:"
- + filter + " scope: base");
+ + filter + " scope: base");
- LDAPSearchResults results =
- conn.search(dn, scope, filter, attrs, false);
+ LDAPSearchResults results =
+ conn.search(dn, scope, filter, attrs, false);
LDAPEntry entry = results.next();
if (results.hasMoreElements()) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", dn,
- ((req == null) ? "" : req.getRequestId().toString())));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", dn,
+ ((req == null) ? "" : req.getRequestId().toString())));
throw new ELdapException(
- CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
- ((req == null) ? "" : req.getRequestId().toString())));
+ CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
+ ((req == null) ? "" : req.getRequestId().toString())));
}
if (entry != null)
return entry.getDN();
else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND", dn,
- ((req == null) ? "" : req.getRequestId().toString())));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND", dn,
+ ((req == null) ? "" : req.getRequestId().toString())));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND",
"null entry"));
}
@@ -232,7 +230,7 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else if (e.getLDAPResultCode() == LDAPException.NO_SUCH_OBJECT && mCreateCAEntry) {
try {
@@ -246,8 +244,7 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_CA_ENTRY_NOT_CREATED1"));
}
- throw new
- ELdapException(CMS.getUserMessage("CMS_LDAP_CREATE_CA_FAILED", dn));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_CREATE_CA_FAILED", dn));
}
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", dn, e.toString()));
@@ -260,19 +257,19 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
}
private void createCAEntry(LDAPConnection conn, String dn)
- throws LDAPException {
+ throws LDAPException {
LDAPAttributeSet attrs = new LDAPAttributeSet();
// OID 2.5.6.16
- String caOc[] = new String[] {"top",
- "person",
- "organizationalPerson",
- "inetOrgPerson"};
-
- String oOc[] = {"top",
- "organization"};
- String oiOc[] = {"top",
- "organizationalunit"};
-
+ String caOc[] = new String[] { "top",
+ "person",
+ "organizationalPerson",
+ "inetOrgPerson" };
+
+ String oOc[] = { "top",
+ "organization" };
+ String oiOc[] = { "top",
+ "organizationalunit" };
+
DN dnobj = new DN(dn);
String attrval[] = dnobj.explodeDN(true);
@@ -286,6 +283,7 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
/**
* form a dn from component in the request and cert subject name
+ *
* @param req The request
* @param obj The certificate or crl
*/
@@ -296,13 +294,13 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509Certificate cert = (X509Certificate) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509Certificate) cert).getSubjectDN();
CMS.debug("LdapCaSimpleMap: cert subject dn:" + subjectDN.toString());
X509CertInfo info = (X509CertInfo)
- ((X509CertImpl) cert).get(
- X509CertImpl.NAME + "." + X509CertImpl.INFO);
+ ((X509CertImpl) cert).get(
+ X509CertImpl.NAME + "." + X509CertImpl.INFO);
certExt = (CertificateExtensions) info.get(
CertificateExtensions.NAME);
@@ -316,12 +314,12 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509CRLImpl crl = (X509CRLImpl) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509CRLImpl) crl).getIssuerDN();
CMS.debug("LdapCaSimpleMap: crl issuer dn: " +
- subjectDN.toString());
- }catch (ClassCastException ex) {
+ subjectDN.toString());
+ } catch (ClassCastException ex) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISH_OBJ_NOT_SUPPORTED",
((req == null) ? "" : req.getRequestId().toString())));
return null;
@@ -332,9 +330,9 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
return dn;
} catch (ELdapException e) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_CANT_FORM_DN",
- ((req == null) ? "" : req.getRequestId().toString()), e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_CANT_FORM_DN",
+ ((req == null) ? "" : req.getRequestId().toString()), e.toString()));
throw new EBaseException("falied to form dn for request: " +
((req == null) ? "" : req.getRequestId().toString()) + " " + e);
}
@@ -362,9 +360,9 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
try {
if (mDnPattern == null) {
v.addElement(PROP_DNPATTERN + "=");
- }else {
+ } else {
v.addElement(PROP_DNPATTERN + "=" +
- mConfig.getString(PROP_DNPATTERN));
+ mConfig.getString(PROP_DNPATTERN));
}
v.addElement(PROP_CREATECA + "=" + mConfig.getBoolean(PROP_CREATECA, true));
} catch (Exception e) {
@@ -374,8 +372,7 @@ public class LdapCaSimpleMap implements ILdapMapper, IExtendedPluginInfo {
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCaSimpleMapper: " + msg);
+ "LdapCaSimpleMapper: " + msg);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertCompsMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertCompsMap.java
index 17c562ce1..2373e3c66 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertCompsMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertCompsMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.security.cert.CRLException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
@@ -34,9 +33,8 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
- * Maps a X509 certificate to a LDAP entry using AVAs in the certificate's
+/**
+ * Maps a X509 certificate to a LDAP entry using AVAs in the certificate's
* subject name to form the ldap search dn and filter.
* Takes a optional root search dn.
* The DN comps are used to form a LDAP entry to begin a subtree search.
@@ -45,11 +43,11 @@ import com.netscape.certsrv.request.IRequest;
* If the baseDN is null and none of the DN comps matched, it is an error.
* If none of the DN comps and filter comps matched, it is an error.
* If just the filter comps is null, a base search is performed.
- *
+ *
* @version $Revision$, $Date$
*/
-public class LdapCertCompsMap
- extends LdapDNCompsMap implements ILdapMapper {
+public class LdapCertCompsMap
+ extends LdapDNCompsMap implements ILdapMapper {
ILogger mLogger = CMS.getLogger();
public LdapCertCompsMap() {
@@ -57,9 +55,9 @@ public class LdapCertCompsMap
// via configuration
}
- /**
+ /**
* Constructor.
- *
+ *
* The DN comps are used to form a LDAP entry to begin a subtree search.
* The filter comps are used to form a search filter for the subtree.
* If none of the DN comps matched, baseDN is used for the subtree.
@@ -67,12 +65,12 @@ public class LdapCertCompsMap
* If none of the DN comps and filter comps matched, it is an error.
* If just the filter comps is null, a base search is performed.
*
- * @param baseDN The base DN.
+ * @param baseDN The base DN.
* @param dnComps Components to form the LDAP base dn for search.
* @param filterComps Components to form the LDAP search filter.
*/
public LdapCertCompsMap(String baseDN, ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ ObjectIdentifier[] filterComps) {
init(baseDN, dnComps, filterComps);
}
@@ -99,20 +97,20 @@ public class LdapCertCompsMap
/**
* constructor using non-standard certificate attribute.
*/
- public LdapCertCompsMap(String certAttr, String baseDN,
- ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ public LdapCertCompsMap(String certAttr, String baseDN,
+ ObjectIdentifier[] dnComps,
+ ObjectIdentifier[] filterComps) {
super(certAttr, baseDN, dnComps, filterComps);
}
protected void init(String baseDN, ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ ObjectIdentifier[] filterComps) {
super.init(baseDN, dnComps, filterComps);
}
/**
* Maps a certificate to LDAP entry.
- * Uses DN components and filter components to form a DN and
+ * Uses DN components and filter components to form a DN and
* filter for a LDAP search.
* If the formed DN is null the baseDN will be used.
* If the formed DN is null and baseDN is null an error is thrown.
@@ -123,16 +121,16 @@ public class LdapCertCompsMap
* @param obj - the X509Certificate.
*/
public String
- map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ map(LDAPConnection conn, Object obj)
+ throws ELdapException {
if (conn == null)
return null;
try {
X509Certificate cert = (X509Certificate) obj;
String result = null;
// form dn and filter for search.
- X500Name subjectDN =
- (X500Name) ((X509Certificate) cert).getSubjectDN();
+ X500Name subjectDN =
+ (X500Name) ((X509Certificate) cert).getSubjectDN();
CMS.debug("LdapCertCompsMap: " + subjectDN.toString());
@@ -148,8 +146,8 @@ public class LdapCertCompsMap
try {
X509CRLImpl crl = (X509CRLImpl) obj;
String result = null;
- X500Name issuerDN =
- (X500Name) ((X509CRLImpl) crl).getIssuerDN();
+ X500Name issuerDN =
+ (X500Name) ((X509CRLImpl) crl).getIssuerDN();
CMS.debug("LdapCertCompsMap: " + issuerDN.toString());
@@ -168,14 +166,13 @@ public class LdapCertCompsMap
}
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, obj);
}
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCertCompsMap: " + msg);
+ "LdapCertCompsMap: " + msg);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertExactMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertExactMap.java
index 7eded9cdd..a1f79a481 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertExactMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertExactMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.security.cert.X509Certificate;
import java.util.Locale;
import java.util.Vector;
@@ -41,11 +40,10 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
+/**
* Maps a X509 certificate to a LDAP entry by using the subject name
* of the certificate as the LDAP entry DN.
- *
+ *
* @version $Revision$, $Date$
*/
public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
@@ -64,7 +62,7 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
}
public void init(IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
if (mInited == true)
return;
mConfig = config;
@@ -74,9 +72,9 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
public String[] getExtendedPluginInfo(Locale locale) {
String[] params = {
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-mapper-certexactmapper",
+ ";configuration-ldappublish-mapper-certexactmapper",
IExtendedPluginInfo.HELP_TEXT +
- ";Literally uses the subject name of the certificate as the DN to publish to"
+ ";Literally uses the subject name of the certificate as the DN to publish to"
};
return params;
@@ -95,7 +93,7 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
return v;
}
-
+
public Vector<String> getInstanceParams() {
Vector<String> v = new Vector<String>();
@@ -103,15 +101,15 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
}
/**
- * Finds the entry for the certificate by looking for the cert
+ * Finds the entry for the certificate by looking for the cert
* subject name in the subject name attribute.
*
* @param conn - the LDAP connection.
* @param obj - the X509Certificate.
- */
+ */
public String
- map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ map(LDAPConnection conn, Object obj)
+ throws ELdapException {
if (conn == null)
return null;
@@ -120,7 +118,7 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509Certificate cert = (X509Certificate) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509Certificate) cert).getSubjectDN();
CMS.debug("LdapCertExactMap: cert subject dn:" + subjectDN.toString());
@@ -128,12 +126,12 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509CRLImpl crl = (X509CRLImpl) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509CRLImpl) crl).getIssuerDN();
CMS.debug("LdapCertExactMap: crl issuer dn: " +
- subjectDN.toString());
- }catch (ClassCastException ex) {
+ subjectDN.toString());
+ } catch (ClassCastException ex) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_NOT_SUPPORTED_OBJECT"));
return null;
}
@@ -141,19 +139,19 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
try {
boolean hasCert = false;
boolean hasSubjectName = false;
- String[] attrs = new String[] { LDAPv3.NO_ATTRS };
+ String[] attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO, "Searching for " + subjectDN.toString());
- LDAPSearchResults results =
- conn.search(subjectDN.toString(), LDAPv2.SCOPE_BASE,
- "(objectclass=*)", attrs, false);
-
+ LDAPSearchResults results =
+ conn.search(subjectDN.toString(), LDAPv2.SCOPE_BASE,
+ "(objectclass=*)", attrs, false);
+
LDAPEntry entry = results.next();
if (results.hasMoreElements()) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", "", subjectDN.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", "", subjectDN.toString()));
}
if (entry != null) {
log(ILogger.LL_INFO, "entry found");
@@ -165,7 +163,7 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", e.toString()));
@@ -190,14 +188,13 @@ public class LdapCertExactMap implements ILdapMapper, IExtendedPluginInfo {
}
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, obj);
}
private void log(int level, String msg) {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCertExactMap: " + msg);
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
+ "LdapCertExactMap: " + msg);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertSubjMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertSubjMap.java
index 42db2b279..e12606b27 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertSubjMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCertSubjMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.security.cert.X509Certificate;
import java.util.Locale;
import java.util.Vector;
@@ -41,11 +40,10 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
+/**
* Maps a X509 certificate to a LDAP entry by finding an LDAP entry
* which has an attribute whose contents are equal to the cert subject name.
- *
+ *
* @version $Revision$, $Date$
*/
public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
@@ -64,8 +62,9 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
/**
* constructs a certificate subject name mapper with search base.
- * @param searchBase the dn to start searching for the certificate
- * subject name.
+ *
+ * @param searchBase the dn to start searching for the certificate
+ * subject name.
*/
public LdapCertSubjMap(String searchBase) {
if (searchBase == null)
@@ -82,10 +81,10 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
* @param certSubjNameAttr attribute for certificate subject names.
* @param certAttr attribute to find certificate.
*/
- public LdapCertSubjMap(String searchBase,
- String certSubjNameAttr, String certAttr) {
- if (searchBase == null ||
- certSubjNameAttr == null || certAttr == null)
+ public LdapCertSubjMap(String searchBase,
+ String certSubjNameAttr, String certAttr) {
+ if (searchBase == null ||
+ certSubjNameAttr == null || certAttr == null)
throw new IllegalArgumentException(
"a null argument to constructor " + this.getClass().getName());
mCertSubjNameAttr = certSubjNameAttr;
@@ -93,10 +92,10 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
mInited = true;
}
- public LdapCertSubjMap(String searchBase,
- String certSubjNameAttr, String certAttr, boolean useAllEntries) {
- if (searchBase == null ||
- certSubjNameAttr == null || certAttr == null)
+ public LdapCertSubjMap(String searchBase,
+ String certSubjNameAttr, String certAttr, boolean useAllEntries) {
+ if (searchBase == null ||
+ certSubjNameAttr == null || certAttr == null)
throw new IllegalArgumentException(
"a null argument to constructor " + this.getClass().getName());
mCertSubjNameAttr = certSubjNameAttr;
@@ -128,15 +127,15 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
"searchBase;string;Base DN to search from",
"useAllEntries;boolean;Use all entries for publishing",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-mapper-certsubjmapper",
+ ";configuration-ldappublish-mapper-certsubjmapper",
IExtendedPluginInfo.HELP_TEXT +
- ";This plugin assumes you want to publish to an LDAP entry which has " +
- "an attribute whose contents are equal to the cert subject name"
+ ";This plugin assumes you want to publish to an LDAP entry which has " +
+ "an attribute whose contents are equal to the cert subject name"
};
return params;
}
-
+
public Vector<String> getInstanceParams() {
Vector<String> v = new Vector<String>();
@@ -159,7 +158,7 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
}
public void init(IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
if (mInited == true)
return;
mConfig = config;
@@ -171,15 +170,15 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
}
/**
- * Finds the entry for the certificate by looking for the cert
+ * Finds the entry for the certificate by looking for the cert
* subject name in the subject name attribute.
*
* @param conn - the LDAP connection.
* @param obj - the X509Certificate.
- */
+ */
public String
- map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ map(LDAPConnection conn, Object obj)
+ throws ELdapException {
if (conn == null)
return null;
X500Name subjectDN = null;
@@ -187,7 +186,7 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509Certificate cert = (X509Certificate) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509Certificate) cert).getSubjectDN();
CMS.debug("LdapCertSubjMap: cert subject dn:" + subjectDN.toString());
@@ -195,12 +194,12 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509CRLImpl crl = (X509CRLImpl) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509CRLImpl) crl).getIssuerDN();
CMS.debug("LdapCertSubjMap: crl issuer dn: " +
- subjectDN.toString());
- }catch (ClassCastException ex) {
+ subjectDN.toString());
+ } catch (ClassCastException ex) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_NOT_SUPPORTED_OBJECT"));
return null;
}
@@ -208,20 +207,20 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
try {
boolean hasCert = false;
boolean hasSubjectName = false;
- String[] attrs = new String[] { LDAPv3.NO_ATTRS };
+ String[] attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO, "search " + mSearchBase +
- " (" + mCertSubjNameAttr + "=" + subjectDN + ") " + mCertSubjNameAttr);
+ " (" + mCertSubjNameAttr + "=" + subjectDN + ") " + mCertSubjNameAttr);
+
+ LDAPSearchResults results =
+ conn.search(mSearchBase, LDAPv2.SCOPE_SUB,
+ "(" + mCertSubjNameAttr + "=" + subjectDN + ")", attrs, false);
- LDAPSearchResults results =
- conn.search(mSearchBase, LDAPv2.SCOPE_SUB,
- "(" + mCertSubjNameAttr + "=" + subjectDN + ")", attrs, false);
-
LDAPEntry entry = results.next();
if (results.hasMoreElements()) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", "", subjectDN.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", "", subjectDN.toString()));
}
if (entry != null) {
log(ILogger.LL_INFO, "entry found");
@@ -233,11 +232,11 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "LDAPException", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "LDAPException", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND", e.toString()));
}
}
@@ -259,12 +258,12 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
}
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, obj);
}
public Vector<String> mapAll(LDAPConnection conn, Object obj)
- throws ELdapException {
+ throws ELdapException {
Vector<String> v = new Vector<String>();
if (conn == null)
@@ -282,20 +281,20 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
try {
boolean hasCert = false;
boolean hasSubjectName = false;
- String[] attrs = new String[] { LDAPv3.NO_ATTRS };
+ String[] attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO, "search " + mSearchBase +
- " (" + mCertSubjNameAttr + "=" + subjectDN + ") " + mCertSubjNameAttr);
+ " (" + mCertSubjNameAttr + "=" + subjectDN + ") " + mCertSubjNameAttr);
+
+ LDAPSearchResults results =
+ conn.search(mSearchBase, LDAPv2.SCOPE_SUB,
+ "(" + mCertSubjNameAttr + "=" + subjectDN + ")", attrs, false);
- LDAPSearchResults results =
- conn.search(mSearchBase, LDAPv2.SCOPE_SUB,
- "(" + mCertSubjNameAttr + "=" + subjectDN + ")", attrs, false);
-
while (results.hasMoreElements()) {
LDAPEntry entry = results.next();
String dn = entry.getDN();
v.addElement(dn);
- CMS.debug("LdapCertSubjMap: dn="+dn);
+ CMS.debug("LdapCertSubjMap: dn=" + dn);
}
CMS.debug("LdapCertSubjMap: Number of entries: " + v.size());
} catch (LDAPException e) {
@@ -303,11 +302,11 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "LDAPException", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "LDAPException", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND", e.toString()));
}
}
@@ -316,13 +315,13 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
}
public Vector<String> mapAll(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
return mapAll(conn, obj);
}
private void log(int level, String msg) {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCertSubjMap: " + msg);
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
+ "LdapCertSubjMap: " + msg);
}
/**
@@ -344,4 +343,3 @@ public class LdapCertSubjMap implements ILdapMapper, IExtendedPluginInfo {
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCrlIssuerCompsMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCrlIssuerCompsMap.java
index 40283e985..4451706a3 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCrlIssuerCompsMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapCrlIssuerCompsMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.security.cert.CRLException;
import java.util.Vector;
@@ -32,16 +31,15 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
- * Default crl mapper.
+/**
+ * Default crl mapper.
* maps the crl to a ldap entry by using components in the issuer name
* to find the CA's entry.
- *
+ *
* @version $Revision$, $Date$
*/
-public class LdapCrlIssuerCompsMap
- extends LdapDNCompsMap implements ILdapMapper {
+public class LdapCrlIssuerCompsMap
+ extends LdapDNCompsMap implements ILdapMapper {
ILogger mLogger = CMS.getLogger();
public LdapCrlIssuerCompsMap() {
@@ -49,9 +47,9 @@ public class LdapCrlIssuerCompsMap
// via configuration
}
- /**
+ /**
* Constructor.
- *
+ *
* The DN comps are used to form a LDAP entry to begin a subtree search.
* The filter comps are used to form a search filter for the subtree.
* If none of the DN comps matched, baseDN is used for the subtree.
@@ -59,21 +57,21 @@ public class LdapCrlIssuerCompsMap
* If none of the DN comps and filter comps matched, it is an error.
* If just the filter comps is null, a base search is performed.
*
- * @param baseDN The base DN.
+ * @param baseDN The base DN.
* @param dnComps Components to form the LDAP base dn for search.
* @param filterComps Components to form the LDAP search filter.
*/
public LdapCrlIssuerCompsMap(String baseDN, ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ ObjectIdentifier[] filterComps) {
init(baseDN, dnComps, filterComps);
}
/**
* constructor using non-standard certificate attribute.
*/
- public LdapCrlIssuerCompsMap(String crlAttr, String baseDN,
- ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ public LdapCrlIssuerCompsMap(String crlAttr, String baseDN,
+ ObjectIdentifier[] dnComps,
+ ObjectIdentifier[] filterComps) {
super(crlAttr, baseDN, dnComps, filterComps);
}
@@ -99,14 +97,14 @@ public class LdapCrlIssuerCompsMap
}
protected void init(String baseDN, ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ ObjectIdentifier[] filterComps) {
//mLdapAttr = LdapCrlPublisher.LDAP_CRL_ATTR;
super.init(baseDN, dnComps, filterComps);
}
/**
* Maps a crl to LDAP entry.
- * Uses issuer DN components and filter components to form a DN and
+ * Uses issuer DN components and filter components to form a DN and
* filter for a LDAP search.
* If the formed DN is null the baseDN will be used.
* If the formed DN is null and baseDN is null an error is thrown.
@@ -116,18 +114,18 @@ public class LdapCrlIssuerCompsMap
* @param conn - the LDAP connection.
* @param obj - the X509Certificate.
* @return the result. LdapCertMapResult is also used for CRL.
- */
+ */
public String
- map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ map(LDAPConnection conn, Object obj)
+ throws ELdapException {
if (conn == null)
return null;
X509CRLImpl crl = (X509CRLImpl) obj;
try {
String result = null;
- X500Name issuerDN =
- (X500Name) ((X509CRLImpl) crl).getIssuerDN();
+ X500Name issuerDN =
+ (X500Name) ((X509CRLImpl) crl).getIssuerDN();
CMS.debug("LdapCrlIssuerCompsMap: " + issuerDN.toString());
@@ -136,14 +134,14 @@ public class LdapCrlIssuerCompsMap
result = super.map(conn, issuerDN, crlbytes);
return result;
} catch (CRLException e) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_CANT_DECODE_CRL", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_CANT_DECODE_CRL", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CRL_FAILED", e.toString()));
}
}
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, obj);
}
@@ -152,8 +150,7 @@ public class LdapCrlIssuerCompsMap
*/
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCrlCompsMap: " + msg);
+ "LdapCrlCompsMap: " + msg);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapDNCompsMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapDNCompsMap.java
index a9df7dae2..e2457b882 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapDNCompsMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapDNCompsMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.io.IOException;
import java.util.Enumeration;
import java.util.Locale;
@@ -46,8 +45,7 @@ import com.netscape.certsrv.ldap.ELdapServerDownException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPlugin;
-
-/**
+/**
* Maps a Subject name to an entry in the LDAP server.
* subject name to form the ldap search dn and filter.
* Takes a optional root search dn.
@@ -57,11 +55,11 @@ import com.netscape.certsrv.publish.ILdapPlugin;
* If the baseDN is null and none of the DN comps matched, it is an error.
* If none of the DN comps and filter comps matched, it is an error.
* If just the filter comps is null, a base search is performed.
- *
+ *
* @version $Revision$, $Date$
*/
-public class LdapDNCompsMap
- implements ILdapPlugin, IExtendedPluginInfo {
+public class LdapDNCompsMap
+ implements ILdapPlugin, IExtendedPluginInfo {
//protected String mLdapAttr = null;
protected String mBaseDN = null;
protected ObjectIdentifier[] mDnComps = null;
@@ -71,9 +69,9 @@ public class LdapDNCompsMap
private boolean mInited = false;
protected IConfigStore mConfig = null;
- /**
+ /**
* Constructor.
- *
+ *
* The DN comps are used to form a LDAP entry to begin a subtree search.
* The filter comps are used to form a search filter for the subtree.
* If none of the DN comps matched, baseDN is used for the subtree.
@@ -81,13 +79,13 @@ public class LdapDNCompsMap
* If none of the DN comps and filter comps matched, it is an error.
* If just the filter comps is null, a base search is performed.
*
- * @param baseDN The base DN.
+ * @param baseDN The base DN.
* @param dnComps Components to form the LDAP base dn for search.
* @param filterComps Components to form the LDAP search filter.
*/
- public LdapDNCompsMap(String ldapAttr, String baseDN,
- ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
+ public LdapDNCompsMap(String ldapAttr, String baseDN,
+ ObjectIdentifier[] dnComps,
+ ObjectIdentifier[] filterComps) {
//mLdapAttr = ldapAttr;
init(baseDN, dnComps, filterComps);
}
@@ -102,17 +100,17 @@ public class LdapDNCompsMap
return mConfig;
}
- /**
+ /**
* for initializing from config store.
*/
- public void init(IConfigStore config)
- throws EBaseException {
+ public void init(IConfigStore config)
+ throws EBaseException {
mConfig = config;
String baseDN = mConfig.getString("baseDN");
- ObjectIdentifier[] dnComps =
- getCompsFromString(mConfig.getString("dnComps"));
- ObjectIdentifier[] filterComps =
- getCompsFromString(mConfig.getString("filterComps"));
+ ObjectIdentifier[] dnComps =
+ getCompsFromString(mConfig.getString("dnComps"));
+ ObjectIdentifier[] filterComps =
+ getCompsFromString(mConfig.getString("filterComps"));
init(baseDN, dnComps, filterComps);
}
@@ -131,12 +129,12 @@ public class LdapDNCompsMap
"dnComps;string;Comma-separated list of attributes to put in the DN",
"filterComps;string;Comma-separated list of attributes to form the filter",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-mapper-dncompsmapper",
+ ";configuration-ldappublish-mapper-dncompsmapper",
IExtendedPluginInfo.HELP_TEXT +
- ";More complex mapper. Used when there is not enough information " +
- "in the cert request to form the complete LDAP DN. Using this " +
- "plugin, you can specify additional LDAP filters to narrow down the " +
- "search"
+ ";More complex mapper. Used when there is not enough information " +
+ "in the cert request to form the complete LDAP DN. Using this " +
+ "plugin, you can specify additional LDAP filters to narrow down the " +
+ "search"
};
return s;
@@ -163,14 +161,14 @@ public class LdapDNCompsMap
if (mDnComps == null) {
v.addElement("dnComps=");
} else {
- v.addElement("dnComps=" +
- mConfig.getString("dnComps"));
+ v.addElement("dnComps=" +
+ mConfig.getString("dnComps"));
}
if (mFilterComps == null) {
v.addElement("filterComps=");
} else {
- v.addElement("filterComps=" +
- mConfig.getString("filterComps"));
+ v.addElement("filterComps=" +
+ mConfig.getString("filterComps"));
}
} catch (Exception e) {
}
@@ -181,8 +179,8 @@ public class LdapDNCompsMap
* common initialization routine.
*/
protected void init(String baseDN, ObjectIdentifier[] dnComps,
- ObjectIdentifier[] filterComps) {
- if (mInited)
+ ObjectIdentifier[] filterComps) {
+ if (mInited)
return;
mBaseDN = baseDN;
@@ -191,36 +189,36 @@ public class LdapDNCompsMap
if (filterComps != null)
mFilterComps = (ObjectIdentifier[]) filterComps.clone();
- // log debug info.
+ // log debug info.
for (int i = 0; i < mDnComps.length; i++) {
CMS.debug(
- "LdapDNCompsMap: dnComp " + X500NameAttrMap.getDefault().getName(mDnComps[i]));
+ "LdapDNCompsMap: dnComp " + X500NameAttrMap.getDefault().getName(mDnComps[i]));
}
for (int i = 0; i < mFilterComps.length; i++) {
CMS.debug("LdapDNCompsMap: filterComp " +
- X500NameAttrMap.getDefault().getName(mFilterComps[i]));
+ X500NameAttrMap.getDefault().getName(mFilterComps[i]));
}
mInited = true;
}
/**
* Maps a X500 subject name to LDAP entry.
- * Uses DN components and filter components to form a DN and
+ * Uses DN components and filter components to form a DN and
* filter for a LDAP search.
* If the formed DN is null the baseDN will be used.
* If the formed DN is null and baseDN is null an error is thrown.
* If the filter is null a base search is performed.
* If both are null an error is thrown.
*
- * @param conn the LDAP connection.
- * @param x500name the dn to map.
- * @param obj the object
+ * @param conn the LDAP connection.
+ * @param x500name the dn to map.
+ * @param obj the object
* @exception ELdapException if any LDAP exceptions occured.
* @return the DN of the entry.
- */
- public String map(LDAPConnection conn, X500Name x500name,
- byte[] obj)
- throws ELdapException {
+ */
+ public String map(LDAPConnection conn, X500Name x500name,
+ byte[] obj)
+ throws ELdapException {
try {
if (conn == null)
return null;
@@ -240,11 +238,11 @@ public class LdapDNCompsMap
// x500name.toString());
// }
if (mBaseDN == null) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_BASE"));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_NO_BASE"));
throw new ELdapException(
- CMS.getUserMessage("CMS_LDAP_NO_DN_COMPS_AND_BASEDN",
- x500name.toString()));
+ CMS.getUserMessage("CMS_LDAP_NO_DN_COMPS_AND_BASEDN",
+ x500name.toString()));
}
dn = mBaseDN;
}
@@ -261,23 +259,23 @@ public class LdapDNCompsMap
attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO, "searching for " + dn + " " + filter + " " +
- ((scope == LDAPv2.SCOPE_SUB) ? "sub" : "base"));
+ ((scope == LDAPv2.SCOPE_SUB) ? "sub" : "base"));
- LDAPSearchResults results =
- conn.search(dn, scope, filter, attrs, false);
+ LDAPSearchResults results =
+ conn.search(dn, scope, filter, attrs, false);
LDAPEntry entry = results.next();
if (results.hasMoreElements()) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", "", x500name.toString()));
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
- x500name.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", "", x500name.toString()));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
+ x500name.toString()));
}
if (entry != null) {
return entry.getDN();
} else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND", "", x500name.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND", "", x500name.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND",
"null entry"));
}
@@ -286,11 +284,11 @@ public class LdapDNCompsMap
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "LDAPException", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "LDAPException", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND", e.toString()));
}
}
@@ -298,15 +296,16 @@ public class LdapDNCompsMap
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapDNCompsMap: " + msg);
+ "LdapDNCompsMap: " + msg);
}
/**
* form a dn and filter from component in the cert subject name
+ *
* @param subjName subject name
*/
public String[] formDNandFilter(X500Name subjName)
- throws ELdapException {
+ throws ELdapException {
Vector<RDN> dnRdns = new Vector<RDN>();
SearchFilter filter = new SearchFilter();
X500NameAttrMap attrMap = X500NameAttrMap.getDefault();
@@ -328,16 +327,16 @@ public class LdapDNCompsMap
DerValue val = ava.getValue();
AVA newAVA = new AVA(mailOid, val);
RDN newRDN = new RDN(new AVA[] { newAVA }
- );
+ );
- CMS.debug(
- "LdapDNCompsMap: Converted " + rdn.toLdapDNString() + " to " +
- newRDN.toLdapDNString() + " in DN");
+ CMS.debug(
+ "LdapDNCompsMap: Converted " + rdn.toLdapDNString() + " to " +
+ newRDN.toLdapDNString() + " in DN");
rdn = newRDN;
}
dnRdns.addElement(rdn);
CMS.debug(
- "LdapDNCompsMap: adding dn comp " + rdn.toLdapDNString());
+ "LdapDNCompsMap: adding dn comp " + rdn.toLdapDNString());
break;
}
}
@@ -348,13 +347,13 @@ public class LdapDNCompsMap
AVA newAVA = new AVA(mailOid, val);
CMS.debug(
- "LdapDNCompsMap: Converted " + ava.toLdapDNString() + " to " +
- newAVA.toLdapDNString() + " in filter");
+ "LdapDNCompsMap: Converted " + ava.toLdapDNString() + " to " +
+ newAVA.toLdapDNString() + " in filter");
ava = newAVA;
}
filter.addElement(ava.toLdapDNString());
CMS.debug(
- "LdapDNCompsMap: adding filter comp " + ava.toLdapDNString());
+ "LdapDNCompsMap: adding filter comp " + ava.toLdapDNString());
break;
}
}
@@ -363,14 +362,14 @@ public class LdapDNCompsMap
// return to caller to decide.
if (dnRdns.size() != 0) {
dnStr = new X500Name(dnRdns).toLdapDNString();
- }
+ }
if (filter.size() != 0) {
filterStr = filter.toFilterString();
}
}
} catch (IOException e) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_FROM_SUBJ_TO_DN", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_FROM_SUBJ_TO_DN", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_FORM_DN_COMPS_FAILED", e.toString()));
}
@@ -386,12 +385,13 @@ public class LdapDNCompsMap
}
/**
- * class for forming search filters for ldap searching from
+ * class for forming search filters for ldap searching from
* name=value components. components are anded.
*/
public static class SearchFilter extends Vector<Object> {
private static final long serialVersionUID = 4210302171279891828L;
+
public String toFilterString() {
StringBuffer buf = new StringBuffer();
@@ -412,21 +412,22 @@ public class LdapDNCompsMap
}
/**
- * useful routine for parsing components given as string to
- * arrays of objectidentifiers.
- * The string is expected to be comma separated AVA attribute names.
+ * useful routine for parsing components given as string to
+ * arrays of objectidentifiers.
+ * The string is expected to be comma separated AVA attribute names.
* For example, "uid,cn,o,ou". Attribute names are case insensitive.
+ *
* @param val the string specifying the comps
* @exception ELdapException if any error occurs.
*/
public static ObjectIdentifier[] getCompsFromString(String val)
- throws ELdapException {
+ throws ELdapException {
StringTokenizer tokens;
ObjectIdentifier[] comps;
String attr;
ObjectIdentifier oid;
- if (val == null || val.length() == 0)
+ if (val == null || val.length() == 0)
return new ObjectIdentifier[0];
tokens = new StringTokenizer(val, ", \t\n\r");
@@ -439,7 +440,7 @@ public class LdapDNCompsMap
while (tokens.hasMoreTokens()) {
attr = tokens.nextToken().trim();
// mail -> E hack to look for E in subject names.
- if (attr.equalsIgnoreCase("mail"))
+ if (attr.equalsIgnoreCase("mail"))
attr = "E";
oid = X500NameAttrMap.getDefault().getOid(attr);
if (oid != null) {
@@ -453,4 +454,3 @@ public class LdapDNCompsMap
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapEnhancedMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapEnhancedMap.java
index c3c269515..52074a939 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapEnhancedMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapEnhancedMap.java
@@ -20,7 +20,6 @@
package com.netscape.cms.publish.mappers;
-
///////////////////////
// import statements //
///////////////////////
@@ -56,35 +55,32 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
//////////////////////
// class definition //
//////////////////////
-/**
+/**
* Maps a request to an entry in the LDAP server.
* Takes a dnPattern to form the baseDN from the
* request attributes and certificate subject name.
* Does a base search for the entry in the directory
- * to publish the cert or crl. The restriction of
+ * to publish the cert or crl. The restriction of
* this mapper is that the ldap dn components must
* be part of certificate subject name or request
- * attributes or constant. The difference of this
- * mapper and LdapSimpleMap is that if the ldap
+ * attributes or constant. The difference of this
+ * mapper and LdapSimpleMap is that if the ldap
* entry is not found, it has the option to create
* the ldap entry given the dn and attributes
* formulated.
- *
+ *
* @version $Revision$, $Date$
*/
public class LdapEnhancedMap
- implements ILdapMapper, IExtendedPluginInfo {
+ implements ILdapMapper, IExtendedPluginInfo {
////////////////////////
// default parameters //
////////////////////////
-
-
//////////////////////////////////////
// local LdapEnhancedMap parameters //
//////////////////////////////////////
@@ -107,7 +103,7 @@ public class LdapEnhancedMap
////////////////////////////
/* mapper plug-in fields */
- protected static final String PROP_DNPATTERN = "dnPattern";
+ protected static final String PROP_DNPATTERN = "dnPattern";
protected static final String PROP_CREATE = "createEntry";
// the object class of the entry to be created. xxxx not done yet
protected static final String PROP_OBJCLASS = "objectClass";
@@ -145,9 +141,9 @@ public class LdapEnhancedMap
/* miscellaneous constants local to this mapper plug-in */
// default dn pattern if left blank or not set in the config
- public static final String DEFAULT_DNPATTERN =
- "UID=$req.HTTP_PARAMS.UID, " +
- "OU=people, O=$subj.o, C=$subj.c";
+ public static final String DEFAULT_DNPATTERN =
+ "UID=$req.HTTP_PARAMS.UID, " +
+ "OU=people, O=$subj.o, C=$subj.c";
private static final int MAX_ATTRS = 10;
protected static final int DEFAULT_ATTRNUM = 1;
@@ -159,8 +155,6 @@ public class LdapEnhancedMap
// IExtendedPluginInfo parameters //
////////////////////////////////////
-
-
///////////////////////
// Logger parameters //
///////////////////////
@@ -185,14 +179,14 @@ public class LdapEnhancedMap
* common initialization routine.
*/
protected void init(String dnPattern)
- throws EBaseException {
+ throws EBaseException {
if (mInited) {
return;
}
mDnPattern = dnPattern;
if (mDnPattern == null ||
- mDnPattern.length() == 0) {
+ mDnPattern.length() == 0) {
mDnPattern = DEFAULT_DNPATTERN;
}
@@ -202,11 +196,11 @@ public class LdapEnhancedMap
String[] mCertAttrs = mPattern.getCertAttrs();
} catch (ELdapException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_PATTERN_INIT",
- dnPattern, e.toString()));
+ CMS.getLogMessage("PUBLISH_DN_PATTERN_INIT",
+ dnPattern, e.toString()));
throw new EBaseException(
- "falied to init with pattern " +
- dnPattern + " " + e);
+ "falied to init with pattern " +
+ dnPattern + " " + e);
}
mInited = true;
@@ -214,43 +208,44 @@ public class LdapEnhancedMap
/**
* form a dn from component in the request and cert subject name
+ *
* @param req The request
* @param obj The certificate or crl
*/
private String formDN(IRequest req, Object obj)
- throws EBaseException {
+ throws EBaseException {
CertificateExtensions certExt = null;
X500Name subjectDN = null;
try {
X509Certificate cert = (X509Certificate) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509Certificate) cert).getSubjectDN();
CMS.debug(
- "LdapEnhancedMap: cert subject dn:" +
- subjectDN.toString());
+ "LdapEnhancedMap: cert subject dn:" +
+ subjectDN.toString());
//certExt = (CertificateExtensions)
// ((X509CertImpl)cert).get(
// X509CertInfo.EXTENSIONS);
X509CertInfo info = (X509CertInfo)
- ((X509CertImpl) cert).get(
- X509CertImpl.NAME +
- "." +
- X509CertImpl.INFO);
+ ((X509CertImpl) cert).get(
+ X509CertImpl.NAME +
+ "." +
+ X509CertImpl.INFO);
certExt = (CertificateExtensions)
info.get(CertificateExtensions.NAME);
} catch (java.security.cert.CertificateParsingException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_CANT_GET_EXT", e.toString()));
+ CMS.getLogMessage("PUBLISH_CANT_GET_EXT", e.toString()));
} catch (IOException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_CANT_GET_EXT", e.toString()));
+ CMS.getLogMessage("PUBLISH_CANT_GET_EXT", e.toString()));
} catch (java.security.cert.CertificateException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_CANT_GET_EXT", e.toString()));
+ CMS.getLogMessage("PUBLISH_CANT_GET_EXT", e.toString()));
} catch (ClassCastException e) {
try {
@@ -260,14 +255,14 @@ public class LdapEnhancedMap
((X509CRLImpl) crl).getIssuerDN();
CMS.debug(
- "LdapEnhancedMap: crl issuer dn: " +
+ "LdapEnhancedMap: crl issuer dn: " +
- subjectDN.toString());
+ subjectDN.toString());
} catch (ClassCastException ex) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_PUBLISH_OBJ_NOT_SUPPORTED",
- ((req == null) ? ""
- : req.getRequestId().toString())));
+ CMS.getLogMessage("PUBLISH_PUBLISH_OBJ_NOT_SUPPORTED",
+ ((req == null) ? ""
+ : req.getRequestId().toString())));
return null;
}
}
@@ -289,26 +284,26 @@ public class LdapEnhancedMap
return dn;
} catch (ELdapException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_CANT_FORM_DN",
- ((req == null) ? ""
- : req.getRequestId().toString()), e.toString()));
+ CMS.getLogMessage("PUBLISH_CANT_FORM_DN",
+ ((req == null) ? ""
+ : req.getRequestId().toString()), e.toString()));
throw new EBaseException(
"failed to form dn for request: " +
- ((req == null) ? ""
- : req.getRequestId().toString()) +
- " " + e);
+ ((req == null) ? ""
+ : req.getRequestId().toString()) +
+ " " + e);
}
}
private void createEntry(LDAPConnection conn, String dn)
- throws LDAPException {
+ throws LDAPException {
LDAPAttributeSet attrs = new LDAPAttributeSet();
// OID 2.5.6.16
- String caOc[] = { "top",
- "person",
- "organizationalPerson",
+ String caOc[] = { "top",
+ "person",
+ "organizationalPerson",
"inetOrgPerson" };
DN dnobj = new DN(dn);
@@ -319,10 +314,10 @@ public class LdapEnhancedMap
attrs.add(new LDAPAttribute("objectclass", caOc));
for (int i = 0; i < mNumAttrs; i++) {
- if (mLdapNames[i] != null &&
- !mLdapNames[i].trim().equals("") &&
- mLdapValues[i] != null &&
- !mLdapValues[i].trim().equals("")) {
+ if (mLdapNames[i] != null &&
+ !mLdapNames[i].trim().equals("") &&
+ mLdapValues[i] != null &&
+ !mLdapValues[i].trim().equals("")) {
attrs.add(new LDAPAttribute(mLdapNames[i],
mLdapValues[i]));
}
@@ -337,14 +332,14 @@ public class LdapEnhancedMap
// ILdapMapper methods //
/////////////////////////
- /**
+ /**
* for initializing from config store.
- *
+ *
* implementation for extended
* ILdapPlugin interface method
*/
- public void init(IConfigStore config)
- throws EBaseException {
+ public void init(IConfigStore config)
+ throws EBaseException {
mConfig = config;
mDnPattern = mConfig.getString(PROP_DNPATTERN,
@@ -364,16 +359,16 @@ public class LdapEnhancedMap
for (int i = 0; i < mNumAttrs; i++) {
mLdapNames[i] =
mConfig.getString(PROP_ATTR_NAME +
- Integer.toString(i),
- "");
+ Integer.toString(i),
+ "");
mLdapPatterns[i] =
mConfig.getString(PROP_ATTR_PATTERN +
- Integer.toString(i),
- "");
+ Integer.toString(i),
+ "");
if (mLdapPatterns[i] != null &&
- !mLdapPatterns[i].trim().equals("")) {
+ !mLdapPatterns[i].trim().equals("")) {
mPatterns[i] = new AVAPattern(mLdapPatterns[i]);
}
}
@@ -381,7 +376,7 @@ public class LdapEnhancedMap
init(mDnPattern);
}
- /**
+ /**
* implementation for extended
* ILdapPlugin interface method
*/
@@ -407,34 +402,34 @@ public class LdapEnhancedMap
try {
if (mDnPattern == null) {
v.addElement(PROP_DNPATTERN + "=");
- }else {
+ } else {
v.addElement(PROP_DNPATTERN + "=" +
- mConfig.getString(PROP_DNPATTERN));
+ mConfig.getString(PROP_DNPATTERN));
}
v.addElement(PROP_CREATE + "=" +
- mConfig.getBoolean(PROP_CREATE,
- true));
+ mConfig.getBoolean(PROP_CREATE,
+ true));
v.addElement(PROP_ATTRNUM + "=" +
- mConfig.getInteger(PROP_ATTRNUM,
- DEFAULT_NUM_ATTRS));
+ mConfig.getInteger(PROP_ATTRNUM,
+ DEFAULT_NUM_ATTRS));
for (int i = 0; i < mNumAttrs; i++) {
if (mLdapNames[i] != null) {
v.addElement(PROP_ATTR_NAME + i +
- "=" + mLdapNames[i]);
+ "=" + mLdapNames[i]);
} else {
v.addElement(PROP_ATTR_NAME + i +
- "=");
+ "=");
}
if (mLdapPatterns[i] != null) {
v.addElement(PROP_ATTR_PATTERN + i +
- "=" + mLdapPatterns[i]);
+ "=" + mLdapPatterns[i]);
} else {
v.addElement(PROP_ATTR_PATTERN + i +
- "=");
+ "=");
}
}
} catch (Exception e) {
@@ -447,12 +442,12 @@ public class LdapEnhancedMap
* Maps an X500 subject name to an LDAP entry.
* Uses DN pattern to form a DN for an LDAP base search.
*
- * @param conn the LDAP connection.
- * @param obj the object to map.
- * @exception ELdapException if any LDAP exceptions occurred.
- */
+ * @param conn the LDAP connection.
+ * @param obj the object to map.
+ * @exception ELdapException if any LDAP exceptions occurred.
+ */
public String map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, null, obj);
}
@@ -460,13 +455,13 @@ public class LdapEnhancedMap
* Maps an X500 subject name to an LDAP entry.
* Uses DN pattern to form a DN for an LDAP base search.
*
- * @param conn the LDAP connection.
- * @param req the request to map.
- * @param obj the object to map.
- * @exception ELdapException if any LDAP exceptions occurred.
- */
+ * @param conn the LDAP connection.
+ * @param req the request to map.
+ * @param obj the object to map.
+ * @exception ELdapException if any LDAP exceptions occurred.
+ */
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null) {
return null;
}
@@ -477,7 +472,7 @@ public class LdapEnhancedMap
dn = formDN(req, obj);
if (dn == null) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_NOT_FORMED"));
+ CMS.getLogMessage("PUBLISH_DN_NOT_FORMED"));
String s1 = "";
@@ -494,9 +489,9 @@ public class LdapEnhancedMap
String[] attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO,
- "searching for dn: " +
- dn + " filter:" +
- filter + " scope: base");
+ "searching for dn: " +
+ dn + " filter:" +
+ filter + " scope: base");
LDAPSearchResults results = conn.search(dn,
scope,
@@ -508,27 +503,27 @@ public class LdapEnhancedMap
if (results.hasMoreElements()) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY",
- dn +
- ((req == null) ? ""
- : req.getRequestId().toString())));
+ CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY",
+ dn +
+ ((req == null) ? ""
+ : req.getRequestId().toString())));
throw new ELdapException(
- CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
- ((req == null) ? ""
- : req.getRequestId().toString())));
+ CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
+ ((req == null) ? ""
+ : req.getRequestId().toString())));
}
if (entry != null) {
return entry.getDN();
} else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND",
- dn +
- ((req == null) ? ""
- : req.getRequestId().toString())));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND",
+ dn +
+ ((req == null) ? ""
+ : req.getRequestId().toString())));
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND",
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND",
"null entry"));
}
} catch (LDAPException e) {
@@ -536,48 +531,48 @@ public class LdapEnhancedMap
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else if (e.getLDAPResultCode() ==
- LDAPException.NO_SUCH_OBJECT && mCreateEntry) {
+ LDAPException.NO_SUCH_OBJECT && mCreateEntry) {
try {
createEntry(conn, dn);
log(ILogger.LL_INFO,
- "Entry " +
- dn +
- " Created");
+ "Entry " +
+ dn +
+ " Created");
return dn;
} catch (LDAPException e1) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION",
- dn,
- e.toString()));
+ CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION",
+ dn,
+ e.toString()));
log(ILogger.LL_FAILURE,
- "Entry is not created. " +
- "This may because there are " +
- "entries in the directory " +
- "hierachy not exit.");
+ "Entry is not created. " +
+ "This may because there are " +
+ "entries in the directory " +
+ "hierachy not exit.");
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_CREATE_ENTRY", dn));
}
} else {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION",
- dn,
- e.toString()));
+ CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION",
+ dn,
+ e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND", e.toString()));
}
} catch (EBaseException e) {
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_EXCEPTION_CAUGHT",
- e.toString()));
+ CMS.getLogMessage("PUBLISH_EXCEPTION_CAUGHT",
+ e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND", e.toString()));
}
@@ -591,46 +586,46 @@ public class LdapEnhancedMap
Vector v = new Vector();
v.addElement(PROP_DNPATTERN +
- ";string;Describes how to form the Ldap " +
- "Subject name in the directory. " +
- "Example 1: 'uid=CertMgr, o=Fedora'. " +
- "Example 2: 'uid=$req.HTTP_PARAMS.uid, " +
- "E=$ext.SubjectAlternativeName.RFC822Name, " +
- "ou=$subj.ou'. " +
- "$req means: take the attribute from the " +
- "request. " +
- "$subj means: take the attribute from the " +
- "certificate subject name. " +
- "$ext means: take the attribute from the " +
- "certificate extension");
+ ";string;Describes how to form the Ldap " +
+ "Subject name in the directory. " +
+ "Example 1: 'uid=CertMgr, o=Fedora'. " +
+ "Example 2: 'uid=$req.HTTP_PARAMS.uid, " +
+ "E=$ext.SubjectAlternativeName.RFC822Name, " +
+ "ou=$subj.ou'. " +
+ "$req means: take the attribute from the " +
+ "request. " +
+ "$subj means: take the attribute from the " +
+ "certificate subject name. " +
+ "$ext means: take the attribute from the " +
+ "certificate extension");
v.addElement(PROP_CREATE +
- ";boolean;If checked, An entry will be " +
- "created automatically");
+ ";boolean;If checked, An entry will be " +
+ "created automatically");
v.addElement(PROP_ATTRNUM +
- ";string;How many attributes to add.");
+ ";string;How many attributes to add.");
v.addElement(IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-mapper-enhancedmapper");
+ ";configuration-ldappublish-mapper-enhancedmapper");
v.addElement(IExtendedPluginInfo.HELP_TEXT +
- ";Describes how to form the LDAP DN of the " +
- "entry to publish to");
+ ";Describes how to form the LDAP DN of the " +
+ "entry to publish to");
for (int i = 0; i < MAX_ATTRS; i++) {
v.addElement(PROP_ATTR_NAME +
- Integer.toString(i) +
- ";string;" +
- "The name of LDAP attribute " +
- "to be added. e.g. mail");
+ Integer.toString(i) +
+ ";string;" +
+ "The name of LDAP attribute " +
+ "to be added. e.g. mail");
v.addElement(PROP_ATTR_PATTERN +
- Integer.toString(i) +
- ";string;" +
- "How to create the LDAP attribute value. " +
- "e.g. $req.HTTP_PARAMS.csrRequestorEmail, " +
- "$subj.E or " +
- "$ext.SubjectAlternativeName.RFC822Name");
+ Integer.toString(i) +
+ ";string;" +
+ "How to create the LDAP attribute value. " +
+ "e.g. $req.HTTP_PARAMS.csrRequestorEmail, " +
+ "$subj.E or " +
+ "$ext.SubjectAlternativeName.RFC822Name");
}
String params[] =
- com.netscape.cmsutil.util.Utils.getStringArrayFromVector(v);
+ com.netscape.cmsutil.util.Utils.getStringArrayFromVector(v);
return params;
}
@@ -641,7 +636,6 @@ public class LdapEnhancedMap
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapEnhancedMapper: " + msg);
+ "LdapEnhancedMapper: " + msg);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapSimpleMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapSimpleMap.java
index c08ec8493..2757bc588 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/LdapSimpleMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/LdapSimpleMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.io.IOException;
import java.security.cert.X509Certificate;
import java.util.Locale;
@@ -45,19 +44,18 @@ import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
+/**
* Maps a request to an entry in the LDAP server.
* Takes a dnPattern to form the baseDN from the request attributes
- * and certificate subject name.Do a base search for the entry
+ * and certificate subject name.Do a base search for the entry
* in the directory to publish the cert or crl.
* The restriction of this mapper is that the ldap dn components must
* be part of certificate subject name or request attributes or constant.
- *
+ *
* @version $Revision$, $Date$
*/
public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
- protected static final String PROP_DNPATTERN = "dnPattern";
+ protected static final String PROP_DNPATTERN = "dnPattern";
protected String mDnPattern = null;
private ILogger mLogger = CMS.getLogger();
@@ -74,13 +72,13 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
protected String[] mCertAttrs = null;
/* default dn pattern if left blank or not set in the config */
- public static final String DEFAULT_DNPATTERN =
- "UID=$req.HTTP_PARAMS.UID, OU=people, O=$subj.o, C=$subj.c";
+ public static final String DEFAULT_DNPATTERN =
+ "UID=$req.HTTP_PARAMS.UID, OU=people, O=$subj.o, C=$subj.c";
- /**
+ /**
* Constructor.
- *
- * @param dnPattern The base DN.
+ *
+ * @param dnPattern The base DN.
*/
public LdapSimpleMap(String dnPattern) {
try {
@@ -88,7 +86,7 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
} catch (EBaseException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("OPERATION_ERROR", e.toString()));
}
-
+
}
/**
@@ -100,11 +98,11 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
public String[] getExtendedPluginInfo(Locale locale) {
String params[] = {
"dnPattern;string;Describes how to form the Ldap Subject name in" +
- " the directory. Example 1: 'uid=CertMgr, o=Fedora'. Example 2:" +
- " 'uid=$req.HTTP_PARAMS.uid, E=$ext.SubjectAlternativeName.RFC822Name, ou=$subj.ou'. " +
- "$req means: take the attribute from the request. " +
- "$subj means: take the attribute from the certificate subject name. " +
- "$ext means: take the attribute from the certificate extension",
+ " the directory. Example 1: 'uid=CertMgr, o=Fedora'. Example 2:" +
+ " 'uid=$req.HTTP_PARAMS.uid, E=$ext.SubjectAlternativeName.RFC822Name, ou=$subj.ou'. " +
+ "$req means: take the attribute from the request. " +
+ "$subj means: take the attribute from the certificate subject name. " +
+ "$ext means: take the attribute from the certificate extension",
IExtendedPluginInfo.HELP_TOKEN + ";configuration-ldappublish-mapper-simplemapper",
IExtendedPluginInfo.HELP_TEXT + ";Describes how to form the LDAP DN of the entry to publish to"
};
@@ -116,11 +114,11 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
return mConfig;
}
- /**
+ /**
* for initializing from config store.
*/
- public void init(IConfigStore config)
- throws EBaseException {
+ public void init(IConfigStore config)
+ throws EBaseException {
mConfig = config;
String dnPattern = mConfig.getString(PROP_DNPATTERN);
@@ -131,12 +129,12 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
* common initialization routine.
*/
protected void init(String dnPattern)
- throws EBaseException {
- if (mInited)
+ throws EBaseException {
+ if (mInited)
return;
mDnPattern = dnPattern;
- if (mDnPattern == null || mDnPattern.length() == 0)
+ if (mDnPattern == null || mDnPattern.length() == 0)
mDnPattern = DEFAULT_DNPATTERN;
try {
mPattern = new MapDNPattern(mDnPattern);
@@ -145,7 +143,7 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
} catch (ELdapException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_DN_PATTERN_INIT",
dnPattern, e.toString()));
- throw new EBaseException("falied to init with pattern " +
+ throw new EBaseException("falied to init with pattern " +
dnPattern + " " + e);
}
@@ -156,12 +154,12 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
* Maps a X500 subject name to LDAP entry.
* Uses DN pattern to form a DN for a LDAP base search.
*
- * @param conn the LDAP connection.
- * @param obj the object to map.
+ * @param conn the LDAP connection.
+ * @param obj the object to map.
* @exception ELdapException if any LDAP exceptions occured.
- */
+ */
public String map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ throws ELdapException {
return map(conn, null, obj);
}
@@ -169,13 +167,13 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
* Maps a X500 subject name to LDAP entry.
* Uses DN pattern to form a DN for a LDAP base search.
*
- * @param conn the LDAP connection.
- * @param req the request to map.
- * @param obj the object to map.
+ * @param conn the LDAP connection.
+ * @param req the request to map.
+ * @param obj the object to map.
* @exception ELdapException if any LDAP exceptions occured.
- */
+ */
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null)
return null;
String dn = null;
@@ -198,22 +196,22 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
String[] attrs = new String[] { LDAPv3.NO_ATTRS };
log(ILogger.LL_INFO, "searching for dn: " + dn + " filter:"
- + filter + " scope: base");
+ + filter + " scope: base");
- LDAPSearchResults results =
- conn.search(dn, scope, filter, attrs, false);
+ LDAPSearchResults results =
+ conn.search(dn, scope, filter, attrs, false);
LDAPEntry entry = results.next();
if (results.hasMoreElements()) {
- log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", dn, ((req == null) ? "" : req.getRequestId().toString())));
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
- ((req == null) ? "" : req.getRequestId().toString())));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_MORE_THAN_ONE_ENTRY", dn, ((req == null) ? "" : req.getRequestId().toString())));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_MORE_THAN_ONE_ENTRY",
+ ((req == null) ? "" : req.getRequestId().toString())));
}
if (entry != null)
return entry.getDN();
else {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND", dn, ((req == null) ? "" : req.getRequestId().toString())));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_ENTRY_NOT_FOUND", dn, ((req == null) ? "" : req.getRequestId().toString())));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_MATCH_FOUND",
"null entry"));
}
@@ -224,7 +222,7 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_DN_MAP_EXCEPTION", "", e.toString()));
@@ -238,6 +236,7 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
/**
* form a dn from component in the request and cert subject name
+ *
* @param req The request
* @param obj The certificate or crl
*/
@@ -249,15 +248,15 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509Certificate cert = (X509Certificate) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509Certificate) cert).getSubjectDN();
CMS.debug("LdapSimpleMap: cert subject dn:" + subjectDN.toString());
//certExt = (CertificateExtensions)
// ((X509CertImpl)cert).get(X509CertInfo.EXTENSIONS);
X509CertInfo info = (X509CertInfo)
- ((X509CertImpl) cert).get(
- X509CertImpl.NAME + "." + X509CertImpl.INFO);
+ ((X509CertImpl) cert).get(
+ X509CertImpl.NAME + "." + X509CertImpl.INFO);
certExt = (CertificateExtensions) info.get(
CertificateExtensions.NAME);
@@ -271,15 +270,15 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
try {
X509CRLImpl crl = (X509CRLImpl) obj;
- subjectDN =
+ subjectDN =
(X500Name) ((X509CRLImpl) crl).getIssuerDN();
CMS.debug("LdapSimpleMap: crl issuer dn: " +
- subjectDN.toString());
- }catch (ClassCastException ex) {
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_PUBLISH_OBJ_NOT_SUPPORTED",
- ((req == null) ? "" : req.getRequestId().toString())));
+ subjectDN.toString());
+ } catch (ClassCastException ex) {
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("PUBLISH_PUBLISH_OBJ_NOT_SUPPORTED",
+ ((req == null) ? "" : req.getRequestId().toString())));
return null;
}
}
@@ -315,9 +314,9 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
try {
if (mDnPattern == null) {
v.addElement(PROP_DNPATTERN + "=");
- }else {
+ } else {
v.addElement(PROP_DNPATTERN + "=" +
- mConfig.getString(PROP_DNPATTERN));
+ mConfig.getString(PROP_DNPATTERN));
}
} catch (Exception e) {
}
@@ -326,8 +325,7 @@ public class LdapSimpleMap implements ILdapMapper, IExtendedPluginInfo {
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapSimpleMapper: " + msg);
+ "LdapSimpleMapper: " + msg);
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/MapAVAPattern.java b/pki/base/common/src/com/netscape/cms/publish/mappers/MapAVAPattern.java
index 265030401..00ddbde57 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/MapAVAPattern.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/MapAVAPattern.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;
@@ -41,26 +40,26 @@ import com.netscape.certsrv.ldap.ELdapException;
import com.netscape.certsrv.publish.ECompSyntaxErr;
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 "=" "$ext" "." extName [ "." nameType ] [ "." attrNumber ]
- * name "=" "$req" "." attrName [ "." attrNumber ] |
- * "$rdn" "." number
+ * name "=" "$subj" "." attrName [ "." attrNumber ] |
+ * name "=" "$ext" "." extName [ "." nameType ] [ "." 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
@@ -71,7 +70,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, OU=people, , O=mcom.com</i>
* cert subject name: dn: UID=jjames, OU=IS, OU=people, , O=mcom.com
* request attributes: uid: cmanager
@@ -96,10 +95,9 @@ import com.netscape.certsrv.request.IRequest;
* O = the string 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$
*/
class MapAVAPattern {
@@ -119,11 +117,11 @@ class MapAVAPattern {
"EDIName",
"URIName",
"IPAddress",
- "OIDName"};
+ "OIDName" };
private static final char[] endChars = new char[] { '+', ',' };
- private static final LdapV3DNStrConverter mLdapDNStrConverter =
- new LdapV3DNStrConverter();
+ private static final LdapV3DNStrConverter mLdapDNStrConverter =
+ new LdapV3DNStrConverter();
/* the list of request attributes needed by this AVA */
protected String[] mReqAttrs = null;
@@ -135,7 +133,7 @@ class MapAVAPattern {
protected String mType = null;
/* the attribute in the AVA pair */
- protected String mAttr = null;
+ protected String mAttr = null;
/* value - could be name of a request attribute or
* cert subject dn attribute. */
@@ -153,19 +151,19 @@ class MapAVAPattern {
protected String mTestDN = null;
public MapAVAPattern(String component)
- throws ELdapException {
- if (component == null || component.length() == 0)
+ throws ELdapException {
+ if (component == null || component.length() == 0)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", component));
parse(new PushbackReader(new StringReader(component)));
}
- public MapAVAPattern(PushbackReader in)
- throws ELdapException {
+ public MapAVAPattern(PushbackReader in)
+ throws ELdapException {
parse(in);
}
private void parse(PushbackReader in)
- throws ELdapException {
+ throws ELdapException {
int c;
// mark ava beginning.
@@ -181,19 +179,19 @@ class MapAVAPattern {
} catch (IOException e) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "All blank"));
}
- if (c == -1)
+ if (c == -1)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "All blank"));
- // $rdn "." number syntax.
+ // $rdn "." number syntax.
if (c == '$') {
//System.out.println("$rdn syntax");
mType = TYPE_RDN;
try {
- if (in.read() != 'r' ||
- in.read() != 'd' ||
- in.read() != 'n' ||
- in.read() != '.')
+ if (in.read() != 'r' ||
+ in.read() != 'd' ||
+ in.read() != 'n' ||
+ in.read() != '.')
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "Invalid $ syntax, expecting $rdn"));
} catch (IOException e) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "Invalid $ syntax, expecting $rdn"));
@@ -215,7 +213,7 @@ class MapAVAPattern {
String rdnNumber = rdnNumberBuf.toString().trim();
- if (rdnNumber.length() == 0)
+ if (rdnNumber.length() == 0)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "$rdn number not set in ava pattern"));
try {
mElement = Integer.parseInt(rdnNumber) - 1;
@@ -230,15 +228,15 @@ class MapAVAPattern {
// read name
//System.out.println("reading name");
- StringBuffer attrBuf = new StringBuffer();
+ StringBuffer attrBuf = new StringBuffer();
try {
while (c != '=' && c != -1 && c != ',' && c != '+') {
attrBuf.append((char) c);
c = in.read();
//System.out.println("name read "+(char)c);
- }
- if (c == ',' || c == '+')
+ }
+ if (c == ',' || c == '+')
in.unread(c);
} catch (IOException e) {
throw new ELdapException(
@@ -247,11 +245,11 @@ class MapAVAPattern {
if (c != '=')
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "Missing \"=\" in ava pattern"));
- // read value
- //System.out.println("reading value");
+ // read value
+ //System.out.println("reading value");
- // skip spaces
- //System.out.println("skip spaces for value");
+ // skip spaces
+ //System.out.println("skip spaces for value");
try {
while ((c = in.read()) == ' ' || c == '\t') {//System.out.println("spaces2 read "+(char)c);
;
@@ -260,7 +258,7 @@ class MapAVAPattern {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
}
- if (c == -1)
+ if (c == -1)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "no value after = in ava pattern"));
if (c == '$') {
@@ -272,14 +270,14 @@ class MapAVAPattern {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
}
- if (c == -1)
+ if (c == -1)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $subj or $req in ava pattern"));
if (c == 'r') {
try {
- if (in.read() != 'e' ||
- in.read() != 'q' ||
- in.read() != '.')
+ if (in.read() != 'e' ||
+ in.read() != 'q' ||
+ in.read() != '.')
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $req in ava pattern"));
} catch (IOException e) {
@@ -290,10 +288,10 @@ class MapAVAPattern {
//System.out.println("---- mtype $req");
} else if (c == 's') {
try {
- if (in.read() != 'u' ||
- in.read() != 'b' ||
- in.read() != 'j' ||
- in.read() != '.')
+ if (in.read() != 'u' ||
+ in.read() != 'b' ||
+ in.read() != 'j' ||
+ in.read() != '.')
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $subj in ava pattern"));
} catch (IOException e) {
@@ -304,10 +302,10 @@ class MapAVAPattern {
//System.out.println("----- mtype $subj");
} else if (c == 'e') {
try {
- if (in.read() != 'x' ||
- in.read() != 't' ||
- in.read() != '.')
- throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
+ if (in.read() != 'x' ||
+ in.read() != 't' ||
+ in.read() != '.')
+ throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"expecting $ext in ava pattern"));
} catch (IOException e) {
throw new ELdapException(
@@ -317,16 +315,16 @@ class MapAVAPattern {
//System.out.println("----- mtype $ext");
} else {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
- "unknown keyword. expecting $subj $ext or $req."));
+ "unknown keyword. expecting $subj $ext or $req."));
}
// get request attr name of subject dn pattern from above.
String attrName = attrBuf.toString().trim();
//System.out.println("----- attrName "+attrName);
- if (attrName.length() == 0)
+ if (attrName.length() == 0)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX", "attribute name expected"));
- mAttr = attrName;
+ mAttr = attrName;
/*
try {
@@ -345,8 +343,8 @@ class MapAVAPattern {
StringBuffer valueBuf = new StringBuffer();
try {
- while ((c = in.read()) != ',' &&
- c != -1 && c != '.' && c != '+') {
+ while ((c = in.read()) != ',' &&
+ c != -1 && c != '.' && c != '+') {
//System.out.println("mValue read "+(char)c);
valueBuf.append((char) c);
}
@@ -358,31 +356,31 @@ class MapAVAPattern {
}
mValue = valueBuf.toString().trim();
- if (mValue.length() == 0)
+ if (mValue.length() == 0)
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"$subj or $req attribute name expected"));
- //System.out.println("----- mValue "+mValue);
+ //System.out.println("----- mValue "+mValue);
- // get nth dn xxx not nth request attribute .
+ // get nth dn xxx not nth request attribute .
if (c == '.') {
StringBuffer attrNumberBuf = new StringBuffer();
try {
while ((c = in.read()) != ',' && c != -1 && c != '.'
- && c != '+') {
+ && c != '+') {
//System.out.println("mElement read "+(char)c);
attrNumberBuf.append((char) c);
}
if (c == ',' || c == '+') // either ',' or '+'
- in.unread(c); // pushback last , or +
+ in.unread(c); // pushback last , or +
} catch (IOException e) {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
}
String attrNumber = attrNumberBuf.toString().trim();
- if (attrNumber.length() == 0)
- throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
+ if (attrNumber.length() == 0)
+ throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"nth element $req $ext or $subj expected"));
try {
mElement = Integer.parseInt(attrNumber) - 1;
@@ -392,11 +390,11 @@ class MapAVAPattern {
mValue = attrNumber;
} else if (TYPE_EXT.equals(mType)) {
mGNType = attrNumber;
- } else
- throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
+ } else
+ throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"Invalid format in nth element $req $ext or $subj"));
- // get nth request attribute .
+ // get nth request attribute .
if (c == '.') {
StringBuffer attrNumberBuf1 = new StringBuffer();
@@ -406,22 +404,22 @@ class MapAVAPattern {
attrNumberBuf1.append((char) c);
}
if (c != -1) // either ',' or '+'
- in.unread(c); // pushback last , or +
+ in.unread(c); // pushback last , or +
} catch (IOException ex) {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", ex.toString()));
}
String attrNumber1 = attrNumberBuf1.toString().trim();
- if (attrNumber1.length() == 0)
- throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
+ if (attrNumber1.length() == 0)
+ throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"nth element $req expected"));
- try {
- mElement = Integer.parseInt(attrNumber1) - 1;
+ try {
+ mElement = Integer.parseInt(attrNumber1) - 1;
} catch (NumberFormatException ex) {
throw new ECompSyntaxErr(CMS.getUserMessage("CMS_AUTHENTICATION_COMPONENT_SYNTAX",
"Invalid format in nth element $req."));
-
+
}
}
}
@@ -437,8 +435,8 @@ class MapAVAPattern {
valueBuf.append((char) c);
// read forward to get attribute value
try {
- while ((c = in.read()) != ',' &&
- c != -1) {
+ while ((c = in.read()) != ',' &&
+ c != -1) {
valueBuf.append((char) c);
}
if (c == '+' || c == ',') { // either ',' or '+'
@@ -448,8 +446,8 @@ class MapAVAPattern {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
}
- try {
- AVA ava = mLdapDNStrConverter.parseAVA(attrBuf + "=" + valueBuf);
+ try {
+ AVA ava = mLdapDNStrConverter.parseAVA(attrBuf + "=" + valueBuf);
mValue = ava.toLdapDNString();
//System.out.println("----- mValue "+mValue);
@@ -460,19 +458,19 @@ class MapAVAPattern {
}
public String formAVA(IRequest req, X500Name subject, CertificateExtensions extensions)
- throws ELdapException {
+ throws ELdapException {
if (TYPE_CONSTANT.equals(mType))
return mValue;
if (TYPE_RDN.equals(mType)) {
String dn = subject.toString();
- if (mTestDN != null)
+ if (mTestDN != null)
dn = mTestDN;
- //System.out.println("AVAPattern Using dn "+mTestDN);
+ //System.out.println("AVAPattern Using dn "+mTestDN);
String[] rdns = LDAPDN.explodeDN(dn, false);
- if (mElement >= rdns.length)
+ if (mElement >= rdns.length)
return null;
return rdns[mElement];
}
@@ -480,9 +478,9 @@ class MapAVAPattern {
if (TYPE_SUBJ.equals(mType)) {
String dn = subject.toString();
- if (mTestDN != null)
+ if (mTestDN != null)
dn = mTestDN;
- //System.out.println("AVAPattern Using dn "+mTestDN);
+ //System.out.println("AVAPattern Using dn "+mTestDN);
String[] rdns = LDAPDN.explodeDN(dn, false);
String value = null;
int nFound = -1;
@@ -493,8 +491,8 @@ class MapAVAPattern {
for (int j = 0; j < avas.length; j++) {
String[] exploded = explodeAVA(avas[j]);
- if (exploded[0].equalsIgnoreCase(mValue) &&
- ++nFound == mElement) {
+ if (exploded[0].equalsIgnoreCase(mValue) &&
+ ++nFound == mElement) {
value = exploded[1];
break;
}
@@ -502,10 +500,10 @@ class MapAVAPattern {
}
if (value == null) {
CMS.debug(
- "MapAVAPattern: attr " + mAttr +
- " not formed from: cert subject " +
- dn +
- "-- no subject component : " + mValue);
+ "MapAVAPattern: attr " + mAttr +
+ " not formed from: cert subject " +
+ dn +
+ "-- no subject component : " + mValue);
return null;
}
return mAttr + "=" + value;
@@ -515,21 +513,19 @@ class MapAVAPattern {
if (extensions != null) {
for (int i = 0; i < extensions.size(); i++) {
Extension ext = (Extension)
- extensions.elementAt(i);
+ extensions.elementAt(i);
String extName = OIDMap.getName(ext.getExtensionId());
int index = extName.lastIndexOf(".");
if (index != -1)
extName = extName.substring(index + 1);
- if (
- extName.equals(mValue)) {
+ if (extName.equals(mValue)) {
// Check the extensions one by one.
// For now, just give subjectAltName as an example.
- if
- (mValue.equalsIgnoreCase(SubjectAlternativeNameExtension.NAME)) {
+ if (mValue.equalsIgnoreCase(SubjectAlternativeNameExtension.NAME)) {
try {
GeneralNames subjectNames = (GeneralNames)
- ((SubjectAlternativeNameExtension) ext).get(SubjectAlternativeNameExtension.SUBJECT_NAME);
+ ((SubjectAlternativeNameExtension) ext).get(SubjectAlternativeNameExtension.SUBJECT_NAME);
if (subjectNames.size() == 0)
break;
@@ -540,7 +536,8 @@ class MapAVAPattern {
String gname = gn.toString();
index = gname.indexOf(":");
- if (index == -1) break;
+ if (index == -1)
+ break;
String gType = gname.substring(0, index);
if (mGNType != null) {
@@ -562,18 +559,18 @@ class MapAVAPattern {
j++;
}
}
- } catch (IOException e) {
+ } catch (IOException e) {
CMS.debug(
- "MapAVAPattern: Publishing attr not formed from extension." +
- "-- no attr : " + mValue);
+ "MapAVAPattern: Publishing attr not formed from extension." +
+ "-- no attr : " + mValue);
}
}
}
}
}
CMS.debug(
- "MapAVAPattern: Publishing:attr not formed from extension " +
- "-- no attr : " + mValue);
+ "MapAVAPattern: Publishing:attr not formed from extension " +
+ "-- no attr : " + mValue);
return null;
}
@@ -582,8 +579,7 @@ class MapAVAPattern {
// mPrefix and mValue are looked up case-insensitive
String reqAttr = req.getExtDataInString(mPrefix, mValue);
if (reqAttr == null) {
- throw new
- ELdapException(CMS.getUserMessage("CMS_LDAP_NO_REQUEST",
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_NO_REQUEST",
mValue, mAttr));
}
return mAttr + "=" + reqAttr;
@@ -607,20 +603,20 @@ class MapAVAPattern {
}
/**
- * Explode RDN into AVAs.
- * Does not handle escaped '+'
+ * Explode RDN into AVAs.
+ * Does not handle escaped '+'
* Java ldap library does not yet support multiple avas per rdn.
- * If RDN is malformed returns empty array.
+ * If RDN is malformed returns empty array.
*/
public static String[] explodeRDN(String rdn) {
int plus = rdn.indexOf('+');
- if (plus == -1)
+ if (plus == -1)
return new String[] { rdn };
Vector avas = new Vector();
StringTokenizer token = new StringTokenizer(rdn, "+");
- while (token.hasMoreTokens())
+ while (token.hasMoreTokens())
avas.addElement(token.nextToken());
String[] theAvas = new String[avas.size()];
@@ -629,17 +625,16 @@ class MapAVAPattern {
}
/**
- * Explode AVA into name and value.
+ * Explode AVA into name and value.
* Does not handle escaped '='
* If AVA is malformed empty array is returned.
*/
public static String[] explodeAVA(String ava) {
int equals = ava.indexOf('=');
- if (equals == -1)
+ if (equals == -1)
return null;
return new String[] {
- ava.substring(0, equals).trim(), ava.substring(equals + 1).trim()};
+ ava.substring(0, equals).trim(), ava.substring(equals + 1).trim() };
}
}
-
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();
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/MapRDNPattern.java b/pki/base/common/src/com/netscape/cms/publish/mappers/MapRDNPattern.java
index 3720d02dd..ad788b12b 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/MapRDNPattern.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/MapRDNPattern.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;
@@ -30,25 +29,25 @@ import com.netscape.certsrv.apps.CMS;
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
@@ -59,7 +58,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
@@ -72,10 +71,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$
*/
class MapRDNPattern {
@@ -94,16 +92,17 @@ class MapRDNPattern {
protected String mTestDN = null;
- /**
+ /**
* Construct a DN pattern by parsing a pattern string.
+ *
* @param pattenr the DN pattern
- * @exception ELdapException If parsing error occurs.
+ * @exception ELdapException If parsing error occurs.
*/
public MapRDNPattern(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,15 +112,15 @@ class MapRDNPattern {
}
/**
- * Construct a DN pattern from a input stream of pattern
+ * Construct a DN pattern from a input stream of pattern
*/
- public MapRDNPattern(PushbackReader in)
- throws ELdapException {
+ public MapRDNPattern(PushbackReader in)
+ throws ELdapException {
parse(in);
}
private void parse(PushbackReader in)
- throws ELdapException {
+ throws ELdapException {
//System.out.println("_________ begin rdn _________");
Vector avaPatterns = new Vector();
MapAVAPattern avaPattern = null;
@@ -135,18 +134,17 @@ class MapRDNPattern {
//" mAttr "+avaPattern.mAttr+
//" mValue "+avaPattern.mValue+
//" mElement "+avaPattern.mElement);
- try {
- lastChar = in.read();
+ try {
+ lastChar = in.read();
} catch (IOException e) {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
}
- }
- while (lastChar == '+');
+ } while (lastChar == '+');
if (lastChar != -1) {
try {
- in.unread(lastChar); // pushback last ,
+ in.unread(lastChar); // pushback last ,
} catch (IOException e) {
throw new ELdapException(
CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
@@ -161,7 +159,7 @@ class MapRDNPattern {
for (int i = 0; i < mAVAPatterns.length; i++) {
String avaAttr = mAVAPatterns[i].getReqAttr();
- if (avaAttr == null || avaAttr.length() == 0)
+ if (avaAttr == null || avaAttr.length() == 0)
continue;
reqAttrs.addElement(avaAttr);
}
@@ -173,7 +171,7 @@ class MapRDNPattern {
for (int i = 0; i < mAVAPatterns.length; i++) {
String avaAttr = mAVAPatterns[i].getCertAttr();
- if (avaAttr == null || avaAttr.length() == 0)
+ if (avaAttr == null || avaAttr.length() == 0)
continue;
certAttrs.addElement(avaAttr);
}
@@ -183,16 +181,17 @@ class MapRDNPattern {
/**
* 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 formRDN(IRequest req, X500Name subject, CertificateExtensions ext)
- throws ELdapException {
+ throws ELdapException {
StringBuffer formedRDN = new StringBuffer();
for (int i = 0; i < mAVAPatterns.length; i++) {
- if (mTestDN != null)
+ if (mTestDN != null)
mAVAPatterns[i].mTestDN = mTestDN;
String ava = mAVAPatterns[i].formAVA(req, subject, ext);
diff --git a/pki/base/common/src/com/netscape/cms/publish/mappers/NoMap.java b/pki/base/common/src/com/netscape/cms/publish/mappers/NoMap.java
index b1d109020..cddc589bd 100644
--- a/pki/base/common/src/com/netscape/cms/publish/mappers/NoMap.java
+++ b/pki/base/common/src/com/netscape/cms/publish/mappers/NoMap.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.mappers;
-
import java.util.Locale;
import java.util.Vector;
@@ -30,10 +29,9 @@ import com.netscape.certsrv.ldap.ELdapException;
import com.netscape.certsrv.publish.ILdapMapper;
import com.netscape.certsrv.request.IRequest;
-
-/**
+/**
* No Map
- *
+ *
* @version $Revision$, $Date$
*/
public class NoMap implements ILdapMapper, IExtendedPluginInfo {
@@ -56,14 +54,14 @@ public class NoMap implements ILdapMapper, IExtendedPluginInfo {
}
public IConfigStore getConfigStore() {
- return mConfig;
+ return mConfig;
}
- /**
+ /**
* for initializing from config store.
*/
- public void init(IConfigStore config)
- throws EBaseException {
+ public void init(IConfigStore config)
+ throws EBaseException {
mConfig = config;
}
@@ -71,17 +69,17 @@ public class NoMap implements ILdapMapper, IExtendedPluginInfo {
* Maps a X500 subject name to LDAP entry.
* Uses DN pattern to form a DN for a LDAP base search.
*
- * @param conn the LDAP connection.
- * @param obj the object to map.
+ * @param conn the LDAP connection.
+ * @param obj the object to map.
* @exception ELdapException if any LDAP exceptions occured.
- */
+ */
public String map(LDAPConnection conn, Object obj)
- throws ELdapException {
+ throws ELdapException {
return null;
}
public String map(LDAPConnection conn, IRequest req, Object obj)
- throws ELdapException {
+ throws ELdapException {
return null;
}
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
index f0154e446..aa49225c0 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/FileBasedPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
@@ -47,10 +46,10 @@ import com.netscape.certsrv.ldap.ELdapException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-/**
+/**
* This publisher writes certificate and CRL into
* a directory.
- *
+ *
* @version $Revision$, $Date$
*/
public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
@@ -74,10 +73,10 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
protected String mLinkExt = null;
protected int mZipLevel = 9;
- public void setIssuingPointId(String crlIssuingPointId)
- {
+ public void setIssuingPointId(String crlIssuingPointId) {
mCrlIssuingPointId = crlIssuingPointId;
}
+
/**
* Returns the implementation name.
*/
@@ -99,14 +98,14 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
PROP_DER + ";boolean;Store certificates or CRLs into *.der files.",
PROP_B64 + ";boolean;Store certificates or CRLs into *.b64 files.",
PROP_GMT + ";choice(LocalTime,GMT);Use local time or GMT to time stamp CRL file name with CRL's 'thisUpdate' field.",
- PROP_LNK + ";boolean;Generate link to the latest binary CRL. It requires '"+PROP_DER+"' to be enabled.",
+ PROP_LNK + ";boolean;Generate link to the latest binary CRL. It requires '" + PROP_DER + "' to be enabled.",
PROP_EXT + ";string;Name extension used by link to the latest CRL. Default name extension is 'der'.",
PROP_ZIP + ";boolean;Generate compressed CRLs.",
PROP_LEV + ";choice(0,1,2,3,4,5,6,7,8,9);Set compression level from 0 to 9.",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-filepublisher",
+ ";configuration-ldappublish-publisher-filepublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";Stores the certificates or CRLs into files. Certificate is named as cert-<serialno>.der or *.b64, and CRL is named as <IssuingPoint>-<thisUpdate-time>.der or *.b64."
+ ";Stores the certificates or CRLs into files. Certificate is named as cert-<serialno>.der or *.b64, and CRL is named as <IssuingPoint>-<thisUpdate-time>.der or *.b64."
};
return params;
@@ -139,14 +138,14 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
try {
if (mTimeStamp == null || (!mTimeStamp.equals("GMT")))
mTimeStamp = "LocalTime";
- v.addElement(PROP_DIR+"=" + dir);
- v.addElement(PROP_DER+"=" + mConfig.getBoolean(PROP_DER,true));
- v.addElement(PROP_B64+"=" + mConfig.getBoolean(PROP_B64,false));
- v.addElement(PROP_GMT+"=" + mTimeStamp);
- v.addElement(PROP_LNK+"=" + mConfig.getBoolean(PROP_LNK,false));
- v.addElement(PROP_EXT+"=" + ext);
- v.addElement(PROP_ZIP+"=" + mConfig.getBoolean(PROP_ZIP,false));
- v.addElement(PROP_LEV+"=" + mZipLevel);
+ v.addElement(PROP_DIR + "=" + dir);
+ v.addElement(PROP_DER + "=" + mConfig.getBoolean(PROP_DER, true));
+ v.addElement(PROP_B64 + "=" + mConfig.getBoolean(PROP_B64, false));
+ v.addElement(PROP_GMT + "=" + mTimeStamp);
+ v.addElement(PROP_LNK + "=" + mConfig.getBoolean(PROP_LNK, false));
+ v.addElement(PROP_EXT + "=" + ext);
+ v.addElement(PROP_ZIP + "=" + mConfig.getBoolean(PROP_ZIP, false));
+ v.addElement(PROP_LEV + "=" + mZipLevel);
} catch (Exception e) {
}
return v;
@@ -158,14 +157,14 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
public Vector<String> getDefaultParams() {
Vector<String> v = new Vector<String>();
- v.addElement(PROP_DIR+"=");
- v.addElement(PROP_DER+"=true");
- v.addElement(PROP_B64+"=false");
- v.addElement(PROP_GMT+"=LocalTime");
- v.addElement(PROP_LNK+"=false");
- v.addElement(PROP_EXT+"=");
- v.addElement(PROP_ZIP+"=false");
- v.addElement(PROP_LEV+"=9");
+ v.addElement(PROP_DIR + "=");
+ v.addElement(PROP_DER + "=true");
+ v.addElement(PROP_B64 + "=false");
+ v.addElement(PROP_GMT + "=LocalTime");
+ v.addElement(PROP_LNK + "=false");
+ v.addElement(PROP_EXT + "=");
+ v.addElement(PROP_ZIP + "=false");
+ v.addElement(PROP_LEV + "=9");
return v;
}
@@ -193,7 +192,7 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
}
// convert to forward slash
- dir = dir.replace('\\', '/');
+ dir = dir.replace('\\', '/');
config.putString(PROP_DIR, dir);
File dirCheck = new File(dir);
@@ -209,7 +208,7 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
} catch (Exception e) {
throw new RuntimeException("Invalid Instance Dir " + e);
}
- dirCheck = new File(mInstanceRoot +
+ dirCheck = new File(mInstanceRoot +
File.separator + dir);
if (dirCheck.isDirectory()) {
mDir = mInstanceRoot + File.separator + dir;
@@ -224,7 +223,7 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
}
private String[] getCrlNamePrefix(X509CRL crl, boolean useGMT) {
- String[] namePrefix = {"crl", "crl"};
+ String[] namePrefix = { "crl", "crl" };
if (mCrlIssuingPointId != null && mCrlIssuingPointId.length() != 0) {
namePrefix[0] = mCrlIssuingPointId;
@@ -232,10 +231,11 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
}
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss");
TimeZone tz = TimeZone.getTimeZone("GMT");
- if (useGMT) format.setTimeZone(tz);
+ if (useGMT)
+ format.setTimeZone(tz);
String timeStamp = format.format(crl.getThisUpdate()).toString();
namePrefix[0] += "-" + timeStamp;
- if (((netscape.security.x509.X509CRLImpl)crl).isDeltaCRL()) {
+ if (((netscape.security.x509.X509CRLImpl) crl).isDeltaCRL()) {
namePrefix[0] += "-delta";
namePrefix[1] += "-delta";
}
@@ -243,23 +243,23 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
return namePrefix;
}
- private void createLink(String linkName, String fileName) {
+ private void createLink(String linkName, String fileName) {
String cmd = "ln -s " + fileName + " " + linkName + ".new";
if (com.netscape.cmsutil.util.Utils.exec(cmd)) {
File oldLink = new File(linkName + ".old");
- if (oldLink.exists()) { // remove old link if exists
+ if (oldLink.exists()) { // remove old link if exists
oldLink.delete();
}
File link = new File(linkName);
- if (link.exists()) { // current link becomes an old link
+ if (link.exists()) { // current link becomes an old link
link.renameTo(new File(linkName + ".old"));
}
File newLink = new File(linkName + ".new");
- if (newLink.exists()) { // new link becomes current link
+ if (newLink.exists()) { // new link becomes current link
newLink.renameTo(new File(linkName));
}
oldLink = new File(linkName + ".old");
- if (oldLink.exists()) { // remove a new old link
+ if (oldLink.exists()) { // remove a new old link
oldLink.delete();
}
} else {
@@ -270,38 +270,36 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
/**
* Publishs a object to the ldap directory.
*
- * @param conn a Ldap connection
- * (null if LDAP publishing is not enabled)
+ * @param conn a Ldap connection
+ * (null if LDAP publishing is not enabled)
* @param dn dn of the ldap entry to publish cert
- * (null if LDAP publishing is not enabled)
+ * (null if LDAP publishing is not enabled)
* @param object object to publish
- * (java.security.cert.X509Certificate or,
- * java.security.cert.X509CRL)
+ * (java.security.cert.X509Certificate or,
+ * java.security.cert.X509CRL)
*/
public void publish(LDAPConnection conn, String dn, Object object)
- throws ELdapException {
+ throws ELdapException {
CMS.debug("FileBasedPublisher: publish");
try {
if (object instanceof X509Certificate) {
X509Certificate cert = (X509Certificate) object;
BigInteger sno = cert.getSerialNumber();
String name = mDir +
- File.separator + "cert-" +
- sno.toString();
- if (mDerAttr)
- {
+ File.separator + "cert-" +
+ sno.toString();
+ if (mDerAttr) {
String fileName = name + ".der";
FileOutputStream fos = new FileOutputStream(fileName);
fos.write(cert.getEncoded());
fos.close();
}
- if (mB64Attr)
- {
+ if (mB64Attr) {
String fileName = name + ".b64";
FileOutputStream fos = new FileOutputStream(fileName);
ByteArrayOutputStream output = new ByteArrayOutputStream();
Base64OutputStream b64 =
- new Base64OutputStream(new PrintStream(new FilterOutputStream(output)));
+ new Base64OutputStream(new PrintStream(new FilterOutputStream(output)));
b64.write(cert.getEncoded());
b64.flush();
(new PrintStream(fos)).print(output.toString("8859_1"));
@@ -314,7 +312,7 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
String tempFile = baseName + ".temp";
FileOutputStream fos;
ZipOutputStream zos;
- byte [] encodedArray = null;
+ byte[] encodedArray = null;
File destFile = null;
String destName = null;
File renameFile = null;
@@ -325,16 +323,16 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
fos.write(encodedArray);
fos.close();
if (mZipCRL) {
- zos = new ZipOutputStream(new FileOutputStream(baseName+".zip"));
+ zos = new ZipOutputStream(new FileOutputStream(baseName + ".zip"));
zos.setLevel(mZipLevel);
- zos.putNextEntry(new ZipEntry(baseName+".der"));
+ zos.putNextEntry(new ZipEntry(baseName + ".der"));
zos.write(encodedArray, 0, encodedArray.length);
zos.closeEntry();
zos.close();
}
destName = baseName + ".der";
destFile = new File(destName);
-
+
if (destFile.exists())
destFile.delete();
renameFile = new File(tempFile);
@@ -348,58 +346,57 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
linkExt += "der";
}
String linkName = mDir + File.separator + namePrefix[1] + linkExt;
- createLink(linkName, destName);
+ createLink(linkName, destName);
if (mZipCRL) {
linkName = mDir + File.separator + namePrefix[1] + ".zip";
- createLink(linkName, baseName+".zip");
+ createLink(linkName, baseName + ".zip");
}
}
}
-
+
// output base64 file
- if(mB64Attr==true)
- {
- if (encodedArray ==null)
- encodedArray = crl.getEncoded();
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
-
- fos = new FileOutputStream(tempFile);
- fos.write(com.netscape.osutil.OSUtil.BtoA(encodedArray).getBytes());
- fos.close();
- destName = baseName + ".b64";
- destFile = new File(destName);
-
- if(destFile.exists())
- destFile.delete();
- renameFile = new File(tempFile);
- renameFile.renameTo(destFile);
- }
+ if (mB64Attr == true) {
+ if (encodedArray == null)
+ encodedArray = crl.getEncoded();
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ fos = new FileOutputStream(tempFile);
+ fos.write(com.netscape.osutil.OSUtil.BtoA(encodedArray).getBytes());
+ fos.close();
+ destName = baseName + ".b64";
+ destFile = new File(destName);
+
+ if (destFile.exists())
+ destFile.delete();
+ renameFile = new File(tempFile);
+ renameFile.renameTo(destFile);
+ }
}
} catch (IOException e) {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
} catch (CertificateEncodingException e) {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
} catch (CRLException e) {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_FILE_PUBLISHER_ERROR", e.toString()));
}
}
/**
* Unpublishs a object to the ldap directory.
- *
+ *
* @param conn the Ldap connection
- * (null if LDAP publishing is not enabled)
+ * (null if LDAP publishing is not enabled)
* @param dn dn of the ldap entry to unpublish cert
- * (null if LDAP publishing is not enabled)
- * @param object object to unpublish
- * (java.security.cert.X509Certificate)
+ * (null if LDAP publishing is not enabled)
+ * @param object object to unpublish
+ * (java.security.cert.X509Certificate)
*/
public void unpublish(LDAPConnection conn, String dn, Object object)
- throws ELdapException {
+ throws ELdapException {
CMS.debug("FileBasedPublisher: unpublish");
String name = mDir + File.separator;
String fileName;
@@ -425,13 +422,15 @@ public class FileBasedPublisher implements ILdapPublisher, IExtendedPluginInfo {
f = new File(fileName);
f.delete();
}
- /**
+
+ /**
* returns the Der attribute where it'll be published.
*/
public boolean getDerAttr() {
return mDerAttr;
}
- /**
+
+ /**
* returns the B64 attribute where it'll be published.
*/
public boolean getB64Attr() {
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java
index 4727a6907..ac1d26026 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCaCertPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.Locale;
@@ -42,14 +41,13 @@ import com.netscape.certsrv.ldap.ELdapServerDownException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-
-/**
- * Interface for publishing a CA certificate to
- *
+/**
+ * Interface for publishing a CA certificate to
+ *
* @version $Revision$, $Date$
*/
-public class LdapCaCertPublisher
- implements ILdapPublisher, IExtendedPluginInfo {
+public class LdapCaCertPublisher
+ implements ILdapPublisher, IExtendedPluginInfo {
public static final String LDAP_CACERT_ATTR = "caCertificate;binary";
public static final String LDAP_CA_OBJECTCLASS = "pkiCA";
public static final String LDAP_ARL_ATTR = "authorityRevocationList;binary";
@@ -64,7 +62,6 @@ public class LdapCaCertPublisher
private boolean mInited = false;
protected IConfigStore mConfig = null;
private String mcrlIssuingPointId;
-
/**
* constructor constructs default values.
@@ -76,13 +73,13 @@ public class LdapCaCertPublisher
String s[] = {
"caCertAttr;string;Name of Ldap attribute in which to store certificate",
"caObjectClass;string;The name of the objectclasses which should be " +
- "added to this entry, if they do not already exist. This can be " +
- "'certificationAuthority' (if using RFC 2256) or 'pkiCA' (if using RFC 4523)",
+ "added to this entry, if they do not already exist. This can be " +
+ "'certificationAuthority' (if using RFC 2256) or 'pkiCA' (if using RFC 4523)",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-cacertpublisher",
+ ";configuration-ldappublish-publisher-cacertpublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";This plugin knows how to publish the CA cert to " +
- "'certificateAuthority' and 'pkiCA' -type entries"
+ ";This plugin knows how to publish the CA cert to " +
+ "'certificateAuthority' and 'pkiCA' -type entries"
};
return s;
@@ -117,12 +114,12 @@ public class LdapCaCertPublisher
}
public void init(IConfigStore config)
- throws EBaseException {
- if (mInited)
+ throws EBaseException {
+ if (mInited)
return;
mConfig = config;
mCaCertAttr = mConfig.getString("caCertAttr", LDAP_CACERT_ATTR);
- mCaObjectclass = mConfig.getString("caObjectClass",
+ mCaObjectclass = mConfig.getString("caObjectClass",
LDAP_CA_OBJECTCLASS);
mObjAdded = mConfig.getString("caObjectClassAdded", "");
mObjDeleted = mConfig.getString("caObjectClassDeleted", "");
@@ -155,12 +152,13 @@ public class LdapCaCertPublisher
* Adds the cert to the multi-valued certificate attribute as a
* DER encoded binary blob. Does not check if cert already exists.
* Converts the class to certificateAuthority.
+ *
* @param conn the LDAP connection
* @param dn dn of the entry to publish the certificate
- * @param certObj the certificate object.
+ * @param certObj the certificate object.
*/
public void publish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null) {
log(ILogger.LL_INFO, "LdapCaCertPublisher: no LDAP connection");
return;
@@ -176,31 +174,30 @@ public class LdapCaCertPublisher
// see if we should create local connection
LDAPConnection altConn = null;
try {
- String host = mConfig.getString("host", null);
- String port = mConfig.getString("port", null);
- if (host != null && port != null) {
- int portVal = Integer.parseInt(port);
- int version = Integer.parseInt(mConfig.getString("version", "2"));
- String cert_nick = mConfig.getString("clientCertNickname", null);
- LDAPSSLSocketFactoryExt sslSocket = null;
- if (cert_nick != null) {
- sslSocket = CMS.getLdapJssSSLSocketFactory(cert_nick);
+ String host = mConfig.getString("host", null);
+ String port = mConfig.getString("port", null);
+ if (host != null && port != null) {
+ int portVal = Integer.parseInt(port);
+ int version = Integer.parseInt(mConfig.getString("version", "2"));
+ String cert_nick = mConfig.getString("clientCertNickname", null);
+ LDAPSSLSocketFactoryExt sslSocket = null;
+ if (cert_nick != null) {
+ sslSocket = CMS.getLdapJssSSLSocketFactory(cert_nick);
+ }
+ String mgr_dn = mConfig.getString("bindDN", null);
+ String mgr_pwd = mConfig.getString("bindPWD", null);
+
+ altConn = CMS.getBoundConnection(host, portVal,
+ version,
+ sslSocket, mgr_dn, mgr_pwd);
+ conn = altConn;
}
- String mgr_dn = mConfig.getString("bindDN", null);
- String mgr_pwd = mConfig.getString("bindPWD", null);
-
- altConn = CMS.getBoundConnection(host, portVal,
- version,
- sslSocket, mgr_dn, mgr_pwd);
- conn = altConn;
- }
} catch (LDAPException e) {
- CMS.debug("Failed to create alt connection " + e);
+ CMS.debug("Failed to create alt connection " + e);
} catch (EBaseException e) {
- CMS.debug("Failed to create alt connection " + e);
+ CMS.debug("Failed to create alt connection " + e);
}
-
if (!(certObj instanceof X509Certificate))
throw new IllegalArgumentException("Illegal arg to publish");
@@ -210,40 +207,40 @@ public class LdapCaCertPublisher
byte[] certEnc = cert.getEncoded();
/* search for attribute names to determine existence of attributes */
- LDAPSearchResults res =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { LDAP_CRL_ATTR, LDAP_ARL_ATTR }, true);
+ LDAPSearchResults res =
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { LDAP_CRL_ATTR, LDAP_ARL_ATTR }, true);
LDAPEntry entry = res.next();
LDAPAttribute arls = entry.getAttribute(LDAP_ARL_ATTR);
LDAPAttribute crls = entry.getAttribute(LDAP_CRL_ATTR);
/* search for objectclass and caCert values */
- LDAPSearchResults res1 =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { "objectclass", mCaCertAttr }, false);
+ LDAPSearchResults res1 =
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { "objectclass", mCaCertAttr }, false);
LDAPEntry entry1 = res1.next();
LDAPAttribute ocs = entry1.getAttribute("objectclass");
LDAPAttribute certs = entry1.getAttribute(mCaCertAttr);
- boolean hasCert =
- LdapUserCertPublisher.ByteValueExists(certs, certEnc);
+ boolean hasCert =
+ LdapUserCertPublisher.ByteValueExists(certs, certEnc);
LDAPModificationSet modSet = new LDAPModificationSet();
if (hasCert) {
log(ILogger.LL_INFO, "publish: CA " + dn + " already has Cert");
- } else {
+ } else {
/*
fix for 360458 - if no cert, use add, if has cert but
not equal, use replace
*/
if (certs == null) {
- modSet.add(LDAPModification.ADD,
- new LDAPAttribute(mCaCertAttr, certEnc));
+ modSet.add(LDAPModification.ADD,
+ new LDAPAttribute(mCaCertAttr, certEnc));
log(ILogger.LL_INFO, "CA cert added");
} else {
- modSet.add(LDAPModification.REPLACE,
- new LDAPAttribute(mCaCertAttr, certEnc));
+ modSet.add(LDAPModification.REPLACE,
+ new LDAPAttribute(mCaCertAttr, certEnc));
log(ILogger.LL_INFO, "CA cert replaced");
}
}
@@ -251,22 +248,22 @@ public class LdapCaCertPublisher
String[] oclist = mCaObjectclass.split(",");
boolean attrsAdded = false;
- for (int i=0; i < oclist.length; i++) {
+ for (int i = 0; i < oclist.length; i++) {
String oc = oclist[i].trim();
boolean hasoc = LdapUserCertPublisher.StringValueExists(ocs, oc);
if (!hasoc) {
log(ILogger.LL_INFO, "adding CA objectclass " + oc + " to " + dn);
modSet.add(LDAPModification.ADD,
- new LDAPAttribute("objectclass", oc));
+ new LDAPAttribute("objectclass", oc));
if ((!attrsAdded) && oc.equalsIgnoreCase("certificationAuthority")) {
// add MUST attributes
- if (arls == null)
+ if (arls == null)
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_ARL_ATTR, ""));
+ new LDAPAttribute(LDAP_ARL_ATTR, ""));
if (crls == null)
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_CRL_ATTR, ""));
+ new LDAPAttribute(LDAP_CRL_ATTR, ""));
attrsAdded = true;
}
}
@@ -275,15 +272,15 @@ public class LdapCaCertPublisher
// delete objectclasses that have been deleted from config
String[] delList = mObjDeleted.split(",");
if (delList.length > 0) {
- for (int i=0; i< delList.length; i++) {
+ for (int i = 0; i < delList.length; i++) {
String deloc = delList[i].trim();
boolean hasoc = LdapUserCertPublisher.StringValueExists(ocs, deloc);
boolean match = false;
- for (int j=0; j< oclist.length; j++) {
+ for (int j = 0; j < oclist.length; j++) {
if ((oclist[j].trim()).equals(deloc)) {
match = true;
break;
- }
+ }
}
if (!match && hasoc) {
log(ILogger.LL_INFO, "deleting CA objectclass " + deloc + " from " + dn);
@@ -294,7 +291,7 @@ public class LdapCaCertPublisher
}
// reset mObjAdded and mObjDeleted, if needed
- if ((!mObjAdded.equals("")) || (!mObjDeleted.equals(""))) {
+ if ((!mObjAdded.equals("")) || (!mObjDeleted.equals(""))) {
mObjAdded = "";
mObjDeleted = "";
mConfig.putString("caObjectClassAdded", "");
@@ -305,8 +302,9 @@ public class LdapCaCertPublisher
log(ILogger.LL_INFO, "Failure in updating mObjAdded and mObjDeleted");
}
}
-
- if (modSet.size() > 0) conn.modify(dn, modSet);
+
+ if (modSet.size() > 0)
+ conn.modify(dn, modSet);
} catch (CertificateEncodingException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_CANT_DECODE_CERT", dn));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -315,20 +313,20 @@ public class LdapCaCertPublisher
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISHER_EXCEPTION", "", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_CACERT_ERROR", e.toString()));
}
} finally {
- if (altConn != null) {
- try {
- altConn.disconnect();
- } catch (LDAPException e) {
- // safely ignored
- }
- }
+ if (altConn != null) {
+ try {
+ altConn.disconnect();
+ } catch (LDAPException e) {
+ // safely ignored
+ }
+ }
}
return;
@@ -340,7 +338,7 @@ public class LdapCaCertPublisher
* objectclass.
*/
public void unpublish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (!(certObj instanceof X509Certificate))
throw new IllegalArgumentException("Illegal arg to publish");
@@ -355,16 +353,16 @@ public class LdapCaCertPublisher
try {
byte[] certEnc = cert.getEncoded();
- LDAPSearchResults res =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { mCaCertAttr, "objectclass" }, false);
+ LDAPSearchResults res =
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { mCaCertAttr, "objectclass" }, false);
LDAPEntry entry = res.next();
LDAPAttribute certs = entry.getAttribute(mCaCertAttr);
LDAPAttribute ocs = entry.getAttribute("objectclass");
- boolean hasCert =
- LdapUserCertPublisher.ByteValueExists(certs, certEnc);
+ boolean hasCert =
+ LdapUserCertPublisher.ByteValueExists(certs, certEnc);
if (!hasCert) {
log(ILogger.LL_INFO, "unpublish: " + dn + " has not cert already");
@@ -376,22 +374,22 @@ public class LdapCaCertPublisher
LDAPModificationSet modSet = new LDAPModificationSet();
modSet.add(LDAPModification.DELETE,
- new LDAPAttribute(mCaCertAttr, certEnc));
+ new LDAPAttribute(mCaCertAttr, certEnc));
if (certs.size() == 1) {
// if last ca cert, remove oc also.
- String[] oclist = mCaObjectclass.split(",");
- for (int i =0 ; i < oclist.length; i++) {
+ String[] oclist = mCaObjectclass.split(",");
+ for (int i = 0; i < oclist.length; i++) {
String oc = oclist[i].trim();
- boolean hasOC = LdapUserCertPublisher.StringValueExists(ocs, oc);
+ boolean hasOC = LdapUserCertPublisher.StringValueExists(ocs, oc);
if (hasOC) {
log(ILogger.LL_INFO, "unpublish: deleting CA oc" + oc + " from " + dn);
modSet.add(LDAPModification.DELETE,
- new LDAPAttribute("objectclass", oc));
+ new LDAPAttribute("objectclass", oc));
}
- }
+ }
}
- conn.modify(dn, modSet);
+ conn.modify(dn, modSet);
} catch (CertificateEncodingException e) {
CMS.debug("LdapCaCertPublisher: unpublish: Cannot decode cert for " + dn);
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -400,7 +398,7 @@ public class LdapCaCertPublisher
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
@@ -415,7 +413,7 @@ public class LdapCaCertPublisher
*/
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCaPublisher: " + msg);
+ "LdapCaPublisher: " + msg);
}
}
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertSubjPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertSubjPublisher.java
index 50cfd7c5a..791b8acc9 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertSubjPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertSubjPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.io.IOException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
@@ -44,12 +43,11 @@ import com.netscape.certsrv.ldap.ELdapServerDownException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-
-/**
- * Interface for mapping a X509 certificate to a LDAP entry
+/**
+ * Interface for mapping a X509 certificate to a LDAP entry
* Publishes a certificate as binary and its subject name.
- * there is one subject name value for each certificate.
- *
+ * there is one subject name value for each certificate.
+ *
* @version $Revision$, $Date$
*/
public class LdapCertSubjPublisher implements ILdapPublisher {
@@ -97,19 +95,19 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
}
public void init(IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
if (mInited)
return;
mConfig = config;
- mCertAttr = mConfig.getString("certAttr",
+ mCertAttr = mConfig.getString("certAttr",
LdapUserCertPublisher.LDAP_USERCERT_ATTR);
- mSubjNameAttr = mConfig.getString("certSubjectName",
+ mSubjNameAttr = mConfig.getString("certSubjectName",
LDAP_CERTSUBJNAME_ATTR);
mInited = true;
}
/**
- * constrcutor using specified certificate attribute and
+ * constrcutor using specified certificate attribute and
* certificate subject name attribute.
*/
public LdapCertSubjPublisher(String certAttr, String subjNameAttr) {
@@ -138,15 +136,16 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
* Adds the cert to the multi-valued certificate attribute as a
* DER encoded binary blob. Does not check if cert already exists.
* Then adds the subject name of the cert to the subject name attribute.
+ *
* @param conn the LDAP connection
* @param dn dn of the entry to publish the certificate
- * @param certObj the certificate object.
- * @exception ELdapException if cert or subject name already exists,
- * if cert encoding fails, if getting cert subject name fails.
- * Use ELdapException.getException() to find underlying exception.
+ * @param certObj the certificate object.
+ * @exception ELdapException if cert or subject name already exists,
+ * if cert encoding fails, if getting cert subject name fails.
+ * Use ELdapException.getException() to find underlying exception.
*/
public void publish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null) {
log(ILogger.LL_INFO, "LdapCertSubjPublisher: no LDAP connection");
return;
@@ -162,9 +161,9 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
byte[] certEnc = cert.getEncoded();
String subjName = ((X500Name) cert.getSubjectDN()).toLdapDNString();
- LDAPSearchResults res =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { mCertAttr, mSubjNameAttr }, false);
+ LDAPSearchResults res =
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { mCertAttr, mSubjNameAttr }, false);
LDAPEntry entry = res.next();
LDAPAttribute certs = entry.getAttribute(mCertAttr);
@@ -177,14 +176,14 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
// check if has subject name already.
if (subjnames != null) {
- hasSubjname =
+ hasSubjname =
LdapUserCertPublisher.StringValueExists(subjnames, subjName);
}
// if has both, done.
if (hasCert && hasSubjname) {
- log(ILogger.LL_INFO,
- "publish: " + subjName + " already has cert & subject name");
+ log(ILogger.LL_INFO,
+ "publish: " + subjName + " already has cert & subject name");
return;
}
@@ -193,14 +192,14 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
if (!hasCert) {
log(ILogger.LL_INFO, "publish: adding cert to " + subjName);
- modSet.add(LDAPModification.ADD,
- new LDAPAttribute(mCertAttr, certEnc));
+ modSet.add(LDAPModification.ADD,
+ new LDAPAttribute(mCertAttr, certEnc));
}
// add subject name if not already there.
if (!hasSubjname) {
log(ILogger.LL_INFO, "publish: adding " + subjName + " to " + dn);
- modSet.add(LDAPModification.ADD,
- new LDAPAttribute(mSubjNameAttr, subjName));
+ modSet.add(LDAPModification.ADD,
+ new LDAPAttribute(mSubjNameAttr, subjName));
}
conn.modify(dn, modSet);
} catch (CertificateEncodingException e) {
@@ -211,7 +210,7 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISHER_EXCEPTION", "", e.toString()));
@@ -230,7 +229,7 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
* with the same subject name.
*/
public void unpublish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (!(certObj instanceof X509Certificate))
throw new IllegalArgumentException("Illegal arg to publish");
@@ -242,9 +241,9 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
byte[] certEnc = cert.getEncoded();
- LDAPSearchResults res =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { mCertAttr, mSubjNameAttr }, false);
+ LDAPSearchResults res =
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { mCertAttr, mSubjNameAttr }, false);
LDAPEntry entry = res.next();
LDAPAttribute certs = entry.getAttribute(mCertAttr);
@@ -266,8 +265,8 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
try {
X509CertImpl certval = new X509CertImpl(val);
// XXX use some sort of X500name equals function here.
- String subjnam =
- ((X500Name) certval.getSubjectDN()).toLdapDNString();
+ String subjnam =
+ ((X500Name) certval.getSubjectDN()).toLdapDNString();
if (subjnam.equalsIgnoreCase(subjName)) {
hasAnotherCert = true;
@@ -275,25 +274,25 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
} catch (CertificateEncodingException e) {
// ignore this certificate.
CMS.debug(
- "LdapCertSubjPublisher: unpublish: an invalid cert in dn entry encountered");
+ "LdapCertSubjPublisher: unpublish: an invalid cert in dn entry encountered");
} catch (CertificateException e) {
// ignore this certificate.
CMS.debug(
- "LdapCertSubjPublisher: unpublish: an invalid cert in dn entry encountered");
+ "LdapCertSubjPublisher: unpublish: an invalid cert in dn entry encountered");
}
}
}
// check if doesn't have subject name already.
if (subjnames != null) {
- hasSubjname =
+ hasSubjname =
LdapUserCertPublisher.StringValueExists(subjnames, subjName);
}
// if doesn't have both, done.
if (!hasCert && !hasSubjname) {
- log(ILogger.LL_INFO,
- "unpublish: " + subjName + " already has not cert & subjname");
+ log(ILogger.LL_INFO,
+ "unpublish: " + subjName + " already has not cert & subjname");
return;
}
@@ -301,19 +300,19 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
LDAPModificationSet modSet = new LDAPModificationSet();
if (hasCert) {
- log(ILogger.LL_INFO,
- "unpublish: deleting cert " + subjName + " from " + dn);
+ log(ILogger.LL_INFO,
+ "unpublish: deleting cert " + subjName + " from " + dn);
modSet.add(LDAPModification.DELETE,
- new LDAPAttribute(mCertAttr, certEnc));
+ new LDAPAttribute(mCertAttr, certEnc));
}
// delete subject name if no other cert has the same name.
if (hasSubjname && !hasAnotherCert) {
- log(ILogger.LL_INFO,
- "unpublish: deleting subject name " + subjName + " from " + dn);
+ log(ILogger.LL_INFO,
+ "unpublish: deleting subject name " + subjName + " from " + dn);
modSet.add(LDAPModification.DELETE,
- new LDAPAttribute(mSubjNameAttr, subjName));
+ new LDAPAttribute(mSubjNameAttr, subjName));
}
- conn.modify(dn, modSet);
+ conn.modify(dn, modSet);
} catch (CertificateEncodingException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -325,7 +324,7 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
@@ -337,7 +336,7 @@ public class LdapCertSubjPublisher implements ILdapPublisher {
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCertSubjPublisher: " + msg);
+ "LdapCertSubjPublisher: " + msg);
}
}
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertificatePairPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertificatePairPublisher.java
index e4a7e0b7c..152a1efb6 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertificatePairPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCertificatePairPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.util.Locale;
import java.util.Vector;
@@ -39,15 +38,14 @@ import com.netscape.certsrv.ldap.ELdapServerDownException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-
-/**
+/**
* module for publishing a cross certificate pair to ldap
* crossCertificatePair attribute
- *
+ *
* @version $Revision$, $Date$
*/
-public class LdapCertificatePairPublisher
- implements ILdapPublisher, IExtendedPluginInfo {
+public class LdapCertificatePairPublisher
+ implements ILdapPublisher, IExtendedPluginInfo {
public static final String LDAP_CROSS_CERT_PAIR_ATTR = "crossCertificatePair;binary";
public static final String LDAP_CA_OBJECTCLASS = "pkiCA";
public static final String LDAP_ARL_ATTR = "authorityRevocationList;binary";
@@ -73,13 +71,13 @@ public class LdapCertificatePairPublisher
String s[] = {
"crossCertPairAttr;string;Name of Ldap attribute in which to store cross certificates",
"caObjectClass;string;The name of the objectclasses which should be " +
- "added to this entry, if they do not already exist. This can be " +
- "'certificationAuthority' (if using RFC 2256) or 'pkiCA' (if using RFC 4523)",
+ "added to this entry, if they do not already exist. This can be " +
+ "'certificationAuthority' (if using RFC 2256) or 'pkiCA' (if using RFC 4523)",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-crosscertpairpublisher",
+ ";configuration-ldappublish-publisher-crosscertpairpublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";This plugin knows how to publish the CA cert to " +
- "'certificateAuthority' and 'pkiCA' -type entries"
+ ";This plugin knows how to publish the CA cert to " +
+ "'certificateAuthority' and 'pkiCA' -type entries"
};
return s;
@@ -118,12 +116,12 @@ public class LdapCertificatePairPublisher
}
public void init(IConfigStore config)
- throws EBaseException {
- if (mInited)
+ throws EBaseException {
+ if (mInited)
return;
mConfig = config;
mCrossCertPairAttr = mConfig.getString("crossCertPairAttr", LDAP_CROSS_CERT_PAIR_ATTR);
- mCaObjectclass = mConfig.getString("caObjectClass",
+ mCaObjectclass = mConfig.getString("caObjectClass",
LDAP_CA_OBJECTCLASS);
mObjAdded = mConfig.getString("caObjectClassAdded", "");
mObjDeleted = mConfig.getString("caObjectClassDeleted", "");
@@ -154,26 +152,28 @@ public class LdapCertificatePairPublisher
/**
* publish a certificatePair
- * -should not be called from listeners.
+ * -should not be called from listeners.
+ *
* @param conn the LDAP connection
* @param dn dn of the entry to publish the XcertificatePair
- * @param pair the Xcertificate bytes object.
+ * @param pair the Xcertificate bytes object.
*/
public synchronized void publish(LDAPConnection conn, String dn, Object pair)
- throws ELdapException {
+ throws ELdapException {
publish(conn, dn, (byte[]) pair);
}
/**
* publish a certificatePair
- * -should not be called from listeners.
+ * -should not be called from listeners.
+ *
* @param conn the LDAP connection
* @param dn dn of the entry to publish the XcertificatePair
* @param pair the cross cert bytes
*/
public synchronized void publish(LDAPConnection conn, String dn,
- byte[] pair)
- throws ELdapException {
+ byte[] pair)
+ throws ELdapException {
if (conn == null) {
log(ILogger.LL_INFO, "LdapCertificatePairPublisher: no LDAP connection");
@@ -189,17 +189,17 @@ public class LdapCertificatePairPublisher
try {
// search for attributes to determine if they exist
LDAPSearchResults res =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { LDAP_CACERT_ATTR, LDAP_CRL_ATTR, LDAP_ARL_ATTR }, true);
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { LDAP_CACERT_ATTR, LDAP_CRL_ATTR, LDAP_ARL_ATTR }, true);
LDAPEntry entry = res.next();
LDAPAttribute certs = entry.getAttribute(LDAP_CACERT_ATTR);
LDAPAttribute arls = entry.getAttribute(LDAP_ARL_ATTR);
LDAPAttribute crls = entry.getAttribute(LDAP_CRL_ATTR);
// search for objectclass and crosscertpair attributes and values
- LDAPSearchResults res1 =
- conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { "objectclass", mCrossCertPairAttr }, false);
+ LDAPSearchResults res1 =
+ conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
+ new String[] { "objectclass", mCrossCertPairAttr }, false);
LDAPEntry entry1 = res1.next();
LDAPAttribute ocs = entry1.getAttribute("objectclass");
LDAPAttribute certPairs = entry1.getAttribute("crosscertificatepair;binary");
@@ -207,53 +207,53 @@ public class LdapCertificatePairPublisher
LDAPModificationSet modSet = new LDAPModificationSet();
boolean hasCert = LdapUserCertPublisher.ByteValueExists(certPairs, pair);
- if (LdapUserCertPublisher.ByteValueExists(certPairs, pair)) {
+ if (LdapUserCertPublisher.ByteValueExists(certPairs, pair)) {
CMS.debug("LdapCertificatePairPublisher: cross cert pair bytes exist in publishing directory, do not publish again.");
return;
}
if (hasCert) {
log(ILogger.LL_INFO, "publish: CA " + dn + " already has cross cert pair bytes");
} else {
- modSet.add(LDAPModification.ADD,
- new LDAPAttribute(mCrossCertPairAttr, pair));
+ modSet.add(LDAPModification.ADD,
+ new LDAPAttribute(mCrossCertPairAttr, pair));
log(ILogger.LL_INFO, "cross cert pair published with dn=" + dn);
}
String[] oclist = mCaObjectclass.split(",");
boolean attrsAdded = false;
- for (int i=0; i < oclist.length; i++) {
+ for (int i = 0; i < oclist.length; i++) {
String oc = oclist[i].trim();
boolean hasoc = LdapUserCertPublisher.StringValueExists(ocs, oc);
if (!hasoc) {
log(ILogger.LL_INFO, "adding CA objectclass " + oc + " to " + dn);
modSet.add(LDAPModification.ADD,
- new LDAPAttribute("objectclass", oc));
+ new LDAPAttribute("objectclass", oc));
if ((!attrsAdded) && oc.equalsIgnoreCase("certificationAuthority")) {
// add MUST attributes
- if (arls == null)
+ if (arls == null)
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_ARL_ATTR, ""));
+ new LDAPAttribute(LDAP_ARL_ATTR, ""));
if (crls == null)
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_CRL_ATTR, ""));
+ new LDAPAttribute(LDAP_CRL_ATTR, ""));
if (certs == null)
- modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_CACERT_ATTR, ""));
+ modSet.add(LDAPModification.ADD,
+ new LDAPAttribute(LDAP_CACERT_ATTR, ""));
attrsAdded = true;
}
}
- }
+ }
// delete objectclasses that have been deleted from config
String[] delList = mObjDeleted.split(",");
if (delList.length > 0) {
- for (int i=0; i< delList.length; i++) {
+ for (int i = 0; i < delList.length; i++) {
String deloc = delList[i].trim();
boolean hasoc = LdapUserCertPublisher.StringValueExists(ocs, deloc);
boolean match = false;
- for (int j=0; j< oclist.length; j++) {
+ for (int j = 0; j < oclist.length; j++) {
if ((oclist[j].trim()).equals(deloc)) {
match = true;
break;
@@ -280,14 +280,15 @@ public class LdapCertificatePairPublisher
}
}
- if (modSet.size() > 0) conn.modify(dn, modSet);
+ if (modSet.size() > 0)
+ conn.modify(dn, modSet);
CMS.debug("LdapCertificatePairPublisher: in publish() just published");
} catch (LDAPException e) {
if (e.getLDAPResultCode() == LDAPException.UNAVAILABLE) {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISHER_EXCEPTION", "", e.toString()));
@@ -301,7 +302,7 @@ public class LdapCertificatePairPublisher
* unsupported
*/
public void unpublish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
CMS.debug("LdapCertificatePairPublisher: unpublish() is unsupported in this revision");
}
@@ -310,7 +311,7 @@ public class LdapCertificatePairPublisher
*/
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCertificatePairPublisher: " + msg);
+ "LdapCertificatePairPublisher: " + msg);
}
}
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java
index 22dc1294f..07b62e900 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapCrlPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.security.cert.CRLException;
import java.security.cert.X509CRL;
import java.util.Locale;
@@ -42,9 +41,8 @@ import com.netscape.certsrv.ldap.ELdapServerDownException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-
/**
- * For publishing master or global CRL.
+ * For publishing master or global CRL.
* Publishes (replaces) the CRL in the CA's LDAP entry.
*
* @version $Revision$, $Date$
@@ -82,14 +80,14 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
String[] params = {
"crlAttr;string;Name of Ldap attribute in which to store the CRL",
"crlObjectClass;string;The name of the objectclasses which should be " +
- "added to this entry, if they do not already exist. This can be a comma-" +
- "separated list such as 'certificationAuthority,certificationAuthority-V2' " +
- "(if using RFC 2256) or 'pkiCA, deltaCRL' (if using RFC 4523)",
+ "added to this entry, if they do not already exist. This can be a comma-" +
+ "separated list such as 'certificationAuthority,certificationAuthority-V2' " +
+ "(if using RFC 2256) or 'pkiCA, deltaCRL' (if using RFC 4523)",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-crlpublisher",
+ ";configuration-ldappublish-publisher-crlpublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";This plugin knows how to publish CRL's to " +
- "'certificateAuthority' and 'pkiCA' -type entries"
+ ";This plugin knows how to publish CRL's to " +
+ "'certificateAuthority' and 'pkiCA' -type entries"
};
return params;
@@ -115,14 +113,14 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
return mConfig;
}
- public void init(IConfigStore config)
- throws EBaseException {
+ public void init(IConfigStore config)
+ throws EBaseException {
if (mInited)
return;
mConfig = config;
mCrlAttr = mConfig.getString("crlAttr", LDAP_CRL_ATTR);
mCrlObjectClass = mConfig.getString("crlObjectClass",
- LDAP_CRL_OBJECTCLASS);
+ LDAP_CRL_OBJECTCLASS);
mObjAdded = mConfig.getString("crlObjectClassAdded", "");
mObjDeleted = mConfig.getString("crlObjectClassDeleted", "");
@@ -146,7 +144,7 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
* CRL's are published as a DER encoded blob.
*/
public void publish(LDAPConnection conn, String dn, Object crlObj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null) {
log(ILogger.LL_INFO, "publish CRL: no LDAP connection");
return;
@@ -162,28 +160,28 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
// see if we should create local connection
LDAPConnection altConn = null;
try {
- String host = mConfig.getString("host", null);
- String port = mConfig.getString("port", null);
- if (host != null && port != null) {
- int portVal = Integer.parseInt(port);
- int version = Integer.parseInt(mConfig.getString("version", "2"));
- String cert_nick = mConfig.getString("clientCertNickname", null);
- LDAPSSLSocketFactoryExt sslSocket = null;
- if (cert_nick != null) {
- sslSocket = CMS.getLdapJssSSLSocketFactory(cert_nick);
+ String host = mConfig.getString("host", null);
+ String port = mConfig.getString("port", null);
+ if (host != null && port != null) {
+ int portVal = Integer.parseInt(port);
+ int version = Integer.parseInt(mConfig.getString("version", "2"));
+ String cert_nick = mConfig.getString("clientCertNickname", null);
+ LDAPSSLSocketFactoryExt sslSocket = null;
+ if (cert_nick != null) {
+ sslSocket = CMS.getLdapJssSSLSocketFactory(cert_nick);
+ }
+ String mgr_dn = mConfig.getString("bindDN", null);
+ String mgr_pwd = mConfig.getString("bindPWD", null);
+
+ altConn = CMS.getBoundConnection(host, portVal,
+ version,
+ sslSocket, mgr_dn, mgr_pwd);
+ conn = altConn;
}
- String mgr_dn = mConfig.getString("bindDN", null);
- String mgr_pwd = mConfig.getString("bindPWD", null);
-
- altConn = CMS.getBoundConnection(host, portVal,
- version,
- sslSocket, mgr_dn, mgr_pwd);
- conn = altConn;
- }
} catch (LDAPException e) {
- CMS.debug("Failed to create alt connection " + e);
+ CMS.debug("Failed to create alt connection " + e);
} catch (EBaseException e) {
- CMS.debug("Failed to create alt connection " + e);
+ CMS.debug("Failed to create alt connection " + e);
}
try {
@@ -194,10 +192,10 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
LDAPSearchResults res = null;
if (mCrlAttr.equals(LDAP_CRL_ATTR)) {
res = conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { LDAP_CACERT_ATTR, LDAP_ARL_ATTR }, true);
+ new String[] { LDAP_CACERT_ATTR, LDAP_ARL_ATTR }, true);
} else {
res = conn.search(dn, LDAPv2.SCOPE_BASE, "(objectclass=*)",
- new String[] { LDAP_CRL_ATTR, LDAP_CACERT_ATTR, LDAP_ARL_ATTR }, true);
+ new String[] { LDAP_CRL_ATTR, LDAP_CACERT_ATTR, LDAP_ARL_ATTR }, true);
}
LDAPEntry entry = res.next();
@@ -216,26 +214,26 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
String[] oclist = mCrlObjectClass.split(",");
boolean attrsAdded = false;
- for (int i=0; i < oclist.length; i++) {
+ for (int i = 0; i < oclist.length; i++) {
String oc = oclist[i].trim();
boolean hasoc = LdapUserCertPublisher.StringValueExists(ocs, oc);
if (!hasoc) {
log(ILogger.LL_INFO, "adding CRL objectclass " + oc + " to " + dn);
modSet.add(LDAPModification.ADD,
- new LDAPAttribute("objectclass", oc));
+ new LDAPAttribute("objectclass", oc));
if ((!attrsAdded) && oc.equalsIgnoreCase("certificationAuthority")) {
// add MUST attributes
if (arls == null)
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_ARL_ATTR, ""));
+ new LDAPAttribute(LDAP_ARL_ATTR, ""));
if (certs == null)
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_CACERT_ATTR, ""));
+ new LDAPAttribute(LDAP_CACERT_ATTR, ""));
- if ((crls == null) && (!mCrlAttr.equals(LDAP_CRL_ATTR)))
+ if ((crls == null) && (!mCrlAttr.equals(LDAP_CRL_ATTR)))
modSet.add(LDAPModification.ADD,
- new LDAPAttribute(LDAP_CRL_ATTR, ""));
+ new LDAPAttribute(LDAP_CRL_ATTR, ""));
attrsAdded = true;
}
}
@@ -246,11 +244,11 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
// delete objectclasses that have been deleted from config
String[] delList = mObjDeleted.split(",");
if (delList.length > 0) {
- for (int i=0; i< delList.length; i++) {
+ for (int i = 0; i < delList.length; i++) {
String deloc = delList[i].trim();
boolean hasoc = LdapUserCertPublisher.StringValueExists(ocs, deloc);
boolean match = false;
- for (int j=0; j< oclist.length; j++) {
+ for (int j = 0; j < oclist.length; j++) {
if ((oclist[j].trim()).equals(deloc)) {
match = true;
break;
@@ -275,7 +273,7 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
} catch (Exception e) {
log(ILogger.LL_INFO, "Failure in updating mObjAdded and mObjDeleted");
}
- }
+ }
conn.modify(dn, modSet);
} catch (CRLException e) {
@@ -286,31 +284,31 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISH_ERROR", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_CRL_ERROR", e.toString()));
}
} finally {
- if (altConn != null) {
- try {
- altConn.disconnect();
- } catch (LDAPException e) {
- // safely ignored
- }
- }
+ if (altConn != null) {
+ try {
+ altConn.disconnect();
+ } catch (LDAPException e) {
+ // safely ignored
+ }
+ }
}
}
/**
- * There shouldn't be a need to call this.
- * CRLs are always replaced but this is implemented anyway in case
+ * There shouldn't be a need to call this.
+ * CRLs are always replaced but this is implemented anyway in case
* there is ever a reason to remove a global CRL.
*/
public void unpublish(LDAPConnection conn, String dn, Object crlObj)
- throws ELdapException {
+ throws ELdapException {
try {
byte[] crlEnc = ((X509CRL) crlObj).getEncoded();
@@ -320,7 +318,6 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
} catch (EBaseException e) {
}
-
LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
"(objectclass=*)", new String[] { mCrlAttr, "objectclass" }, false);
LDAPEntry e = res.next();
@@ -330,21 +327,21 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
LDAPModificationSet modSet = new LDAPModificationSet();
boolean hasOC = false;
- boolean hasCRL =
- LdapUserCertPublisher.ByteValueExists(crls, crlEnc);
+ boolean hasCRL =
+ LdapUserCertPublisher.ByteValueExists(crls, crlEnc);
if (hasCRL) {
- modSet.add(LDAPModification.DELETE,
- new LDAPAttribute(mCrlAttr, crlEnc));
+ modSet.add(LDAPModification.DELETE,
+ new LDAPAttribute(mCrlAttr, crlEnc));
}
-
+
String[] oclist = mCrlObjectClass.split(",");
- for (int i=0; i < oclist.length; i++) {
+ for (int i = 0; i < oclist.length; i++) {
String oc = oclist[i].trim();
if (LdapUserCertPublisher.StringValueExists(ocs, oc)) {
log(ILogger.LL_INFO, "unpublish: deleting CRL object class " + oc + " from " + dn);
- modSet.add(LDAPModification.DELETE,
- new LDAPAttribute("objectClass", oc));
+ modSet.add(LDAPModification.DELETE,
+ new LDAPAttribute("objectClass", oc));
hasOC = true;
}
}
@@ -353,7 +350,7 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
conn.modify(dn, modSet);
} else {
log(ILogger.LL_INFO,
- "unpublish: " + dn + " already has not CRL");
+ "unpublish: " + dn + " already has not CRL");
}
} catch (CRLException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
@@ -363,7 +360,7 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
@@ -375,6 +372,6 @@ public class LdapCrlPublisher implements ILdapPublisher, IExtendedPluginInfo {
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapCrlPublisher: " + msg);
+ "LdapCrlPublisher: " + msg);
}
}
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapEncryptCertPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapEncryptCertPublisher.java
index 902763b48..67f0fca90 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapEncryptCertPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapEncryptCertPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.io.IOException;
import java.math.BigInteger;
import java.security.cert.CertificateEncodingException;
@@ -51,10 +50,9 @@ import com.netscape.certsrv.ldap.ELdapServerDownException;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-
-/**
- * Interface for mapping a X509 certificate to a LDAP entry
- *
+/**
+ * Interface for mapping a X509 certificate to a LDAP entry
+ *
* @version $Revision$, $Date$
*/
public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPluginInfo {
@@ -82,9 +80,9 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
String[] params = {
"certAttr;string;LDAP attribute in which to store the certificate",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-usercertpublisher",
+ ";configuration-ldappublish-publisher-usercertpublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";This plugin knows how to publish user certificates"
+ ";This plugin knows how to publish user certificates"
};
return params;
@@ -110,7 +108,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
}
public void init(IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
if (mInited)
return;
mConfig = config;
@@ -130,10 +128,10 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
*
* @param conn the LDAP connection
* @param dn dn of the entry to publish the certificate
- * @param certObj the certificate object.
+ * @param certObj the certificate object.
*/
public void publish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null)
return;
@@ -147,7 +145,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
byte[] certEnc = cert.getEncoded();
// check if cert already exists.
- LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
+ LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
"(objectclass=*)", new String[] { mCertAttr }, false);
LDAPEntry entry = res.next();
LDAPAttribute attr = getModificationAttribute(entry.getAttribute(mCertAttr), certEnc);
@@ -160,7 +158,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
// publish
LDAPModification mod = new LDAPModification(LDAPModification.REPLACE, attr);
- conn.modify(dn, mod);
+ conn.modify(dn, mod);
} catch (CertificateEncodingException e) {
CMS.debug("LdapEncryptCertPublisher: error in publish: " + e.toString());
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -169,7 +167,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISH_ERROR", e.toString()));
@@ -180,12 +178,12 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
}
/**
- * unpublish a user certificate
+ * unpublish a user certificate
* deletes the certificate from the list of certificates.
* does not check if certificate is already there.
*/
public void unpublish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (!(certObj instanceof X509Certificate))
throw new IllegalArgumentException("Illegal arg to publish");
@@ -195,7 +193,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
byte[] certEnc = cert.getEncoded();
// check if cert already deleted.
- LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
+ LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
"(objectclass=*)", new String[] { mCertAttr }, false);
LDAPEntry entry = res.next();
@@ -207,7 +205,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
LDAPModification mod = new LDAPModification(LDAPModification.DELETE,
new LDAPAttribute(mCertAttr, certEnc));
- conn.modify(dn, mod);
+ conn.modify(dn, mod);
} catch (CertificateEncodingException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -216,7 +214,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
@@ -228,11 +226,11 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapUserCertPublisher: " + msg);
+ "LdapUserCertPublisher: " + msg);
}
public LDAPAttribute getModificationAttribute(
- LDAPAttribute attr, byte[] bval) {
+ LDAPAttribute attr, byte[] bval) {
LDAPAttribute at = new LDAPAttribute(attr.getName(), bval);
// determine if the given cert is a signing or an encryption
@@ -257,12 +255,12 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
log(ILogger.LL_INFO, "Checking " + cert);
if (CMS.isEncryptionCert(thisCert) &&
- CMS.isEncryptionCert(cert)) {
+ CMS.isEncryptionCert(cert)) {
// skip
log(ILogger.LL_INFO, "SKIP ENCRYPTION " + cert);
revokeCert(cert);
} else if (CMS.isSigningCert(thisCert) &&
- CMS.isSigningCert(cert)) {
+ CMS.isSigningCert(cert)) {
// skip
log(ILogger.LL_INFO, "SKIP SIGNING " + cert);
revokeCert(cert);
@@ -277,8 +275,8 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
}
private RevokedCertImpl formCRLEntry(
- BigInteger serialNo, RevocationReason reason)
- throws EBaseException {
+ BigInteger serialNo, RevocationReason reason)
+ throws EBaseException {
CRLReasonExtension reasonExt = new CRLReasonExtension(reason);
CRLExtensions crlentryexts = new CRLExtensions();
@@ -290,13 +288,13 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_INTERNAL_ERROR", e.toString()));
}
RevokedCertImpl crlentry =
- new RevokedCertImpl(serialNo, new Date(), crlentryexts);
+ new RevokedCertImpl(serialNo, new Date(), crlentryexts);
return crlentry;
}
private void revokeCert(X509CertImpl cert)
- throws EBaseException {
+ throws EBaseException {
try {
if (mConfig.getBoolean(PROP_REVOKE_CERT, true) == false) {
return;
@@ -307,7 +305,7 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
BigInteger serialNum = cert.getSerialNumber();
// need to revoke certificate also
ICertificateAuthority ca = (ICertificateAuthority)
- CMS.getSubsystem("ca");
+ CMS.getSubsystem("ca");
ICAService service = (ICAService) ca.getCAService();
RevokedCertImpl crlEntry = formCRLEntry(
serialNum, RevocationReason.KEY_COMPROMISE);
@@ -354,4 +352,3 @@ public class LdapEncryptCertPublisher implements ILdapPublisher, IExtendedPlugin
}
}
-
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java
index f612d005b..aa1a7ef75 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/LdapUserCertPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.util.Enumeration;
@@ -43,10 +42,9 @@ import com.netscape.certsrv.logging.AuditFormat;
import com.netscape.certsrv.logging.ILogger;
import com.netscape.certsrv.publish.ILdapPublisher;
-
-/**
- * Interface for mapping a X509 certificate to a LDAP entry
- *
+/**
+ * Interface for mapping a X509 certificate to a LDAP entry
+ *
* @version $Revision$, $Date$
*/
public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInfo {
@@ -72,9 +70,9 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
String[] params = {
"certAttr;string;LDAP attribute in which to store the certificate",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-usercertpublisher",
+ ";configuration-ldappublish-publisher-usercertpublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";This plugin knows how to publish user certificates"
+ ";This plugin knows how to publish user certificates"
};
return params;
@@ -100,7 +98,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
}
public void init(IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
if (mInited)
return;
mConfig = config;
@@ -119,10 +117,10 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
*
* @param conn the LDAP connection
* @param dn dn of the entry to publish the certificate
- * @param certObj the certificate object.
+ * @param certObj the certificate object.
*/
public void publish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
if (conn == null)
return;
@@ -130,28 +128,28 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
// see if we should create local connection
LDAPConnection altConn = null;
try {
- String host = mConfig.getString("host", null);
- String port = mConfig.getString("port", null);
- if (host != null && port != null) {
- int portVal = Integer.parseInt(port);
- int version = Integer.parseInt(mConfig.getString("version", "2"));
- String cert_nick = mConfig.getString("clientCertNickname", null);
- LDAPSSLSocketFactoryExt sslSocket = null;
- if (cert_nick != null) {
- sslSocket = CMS.getLdapJssSSLSocketFactory(cert_nick);
+ String host = mConfig.getString("host", null);
+ String port = mConfig.getString("port", null);
+ if (host != null && port != null) {
+ int portVal = Integer.parseInt(port);
+ int version = Integer.parseInt(mConfig.getString("version", "2"));
+ String cert_nick = mConfig.getString("clientCertNickname", null);
+ LDAPSSLSocketFactoryExt sslSocket = null;
+ if (cert_nick != null) {
+ sslSocket = CMS.getLdapJssSSLSocketFactory(cert_nick);
+ }
+ String mgr_dn = mConfig.getString("bindDN", null);
+ String mgr_pwd = mConfig.getString("bindPWD", null);
+
+ altConn = CMS.getBoundConnection(host, portVal,
+ version,
+ sslSocket, mgr_dn, mgr_pwd);
+ conn = altConn;
}
- String mgr_dn = mConfig.getString("bindDN", null);
- String mgr_pwd = mConfig.getString("bindPWD", null);
-
- altConn = CMS.getBoundConnection(host, portVal,
- version,
- sslSocket, mgr_dn, mgr_pwd);
- conn = altConn;
- }
} catch (LDAPException e) {
- CMS.debug("Failed to create alt connection " + e);
+ CMS.debug("Failed to create alt connection " + e);
} catch (EBaseException e) {
- CMS.debug("Failed to create alt connection " + e);
+ CMS.debug("Failed to create alt connection " + e);
}
if (!(certObj instanceof X509Certificate))
@@ -169,7 +167,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
byte[] certEnc = cert.getEncoded();
// check if cert already exists.
- LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
+ LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
"(objectclass=*)", new String[] { mCertAttr }, false);
LDAPEntry entry = res.next();
@@ -181,23 +179,23 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
// publish
LDAPModification mod = null;
if (deleteCert) {
- mod = new LDAPModification(LDAPModification.REPLACE,
- new LDAPAttribute(mCertAttr, certEnc));
+ mod = new LDAPModification(LDAPModification.REPLACE,
+ new LDAPAttribute(mCertAttr, certEnc));
} else {
- mod = new LDAPModification(LDAPModification.ADD,
- new LDAPAttribute(mCertAttr, certEnc));
+ mod = new LDAPModification(LDAPModification.ADD,
+ new LDAPAttribute(mCertAttr, certEnc));
}
- conn.modify(dn, mod);
+ conn.modify(dn, mod);
// log a successful message to the "transactions" log
- mLogger.log( ILogger.EV_AUDIT,
+ mLogger.log(ILogger.EV_AUDIT,
ILogger.S_LDAP,
ILogger.LL_INFO,
AuditFormat.LDAP_PUBLISHED_FORMAT,
new Object[] { "LdapUserCertPublisher",
cert.getSerialNumber().toString(16),
- cert.getSubjectDN() } );
+ cert.getSubjectDN() });
} catch (CertificateEncodingException e) {
CMS.debug("LdapUserCertPublisher: error in publish: " + e.toString());
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -206,31 +204,31 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_PUBLISH_ERROR", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_USERCERT_ERROR", e.toString()));
}
} finally {
- if (altConn != null) {
- try {
- altConn.disconnect();
- } catch (LDAPException e) {
- // safely ignored
- }
- }
+ if (altConn != null) {
+ try {
+ altConn.disconnect();
+ } catch (LDAPException e) {
+ // safely ignored
+ }
+ }
}
return;
}
/**
- * unpublish a user certificate
+ * unpublish a user certificate
* deletes the certificate from the list of certificates.
* does not check if certificate is already there.
*/
public void unpublish(LDAPConnection conn, String dn, Object certObj)
- throws ELdapException {
+ throws ELdapException {
boolean disableUnpublish = false;
try {
@@ -239,8 +237,8 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
}
if (disableUnpublish) {
- CMS.debug("UserCertPublisher: disable unpublish");
- return;
+ CMS.debug("UserCertPublisher: disable unpublish");
+ return;
}
if (!(certObj instanceof X509Certificate))
@@ -252,7 +250,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
byte[] certEnc = cert.getEncoded();
// check if cert already deleted.
- LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
+ LDAPSearchResults res = conn.search(dn, LDAPv2.SCOPE_BASE,
"(objectclass=*)", new String[] { mCertAttr }, false);
LDAPEntry entry = res.next();
@@ -264,7 +262,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
LDAPModification mod = new LDAPModification(LDAPModification.DELETE,
new LDAPAttribute(mCertAttr, certEnc));
- conn.modify(dn, mod);
+ conn.modify(dn, mod);
} catch (CertificateEncodingException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR", e.toString()));
throw new ELdapException(CMS.getUserMessage("CMS_LDAP_GET_DER_ENCODED_CERT_FAILED", e.toString()));
@@ -273,7 +271,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
// need to intercept this because message from LDAP is
// "DSA is unavailable" which confuses with DSA PKI.
log(ILogger.LL_FAILURE,
- CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
+ CMS.getLogMessage("PUBLISH_NO_LDAP_SERVER"));
throw new ELdapServerDownException(CMS.getUserMessage("CMS_LDAP_SERVER_UNAVAILABLE", conn.getHost(), "" + conn.getPort()));
} else {
log(ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_UNPUBLISH_ERROR"));
@@ -285,7 +283,7 @@ public class LdapUserCertPublisher implements ILdapPublisher, IExtendedPluginInf
private void log(int level, String msg) {
mLogger.log(ILogger.EV_SYSTEM, ILogger.S_LDAP, level,
- "LdapUserCertPublisher: " + msg);
+ "LdapUserCertPublisher: " + msg);
}
/**
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java b/pki/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java
index ad37a6669..551bb4d6f 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/OCSPPublisher.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -42,11 +41,10 @@ import com.netscape.certsrv.publish.ILdapPublisher;
import com.netscape.cmsutil.http.HttpRequest;
import com.netscape.cmsutil.http.JssSSLSocketFactory;
-
-/**
+/**
* This publisher writes certificate and CRL into
* a directory.
- *
+ *
* @version $Revision$, $Date$
*/
public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
@@ -86,9 +84,9 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
PROP_NICK + ";string;Nickname of cert used for client authentication",
PROP_CLIENT_AUTH_ENABLE + ";boolean;Client Authentication enabled",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-ldappublish-publisher-ocsppublisher",
+ ";configuration-ldappublish-publisher-ocsppublisher",
IExtendedPluginInfo.HELP_TEXT +
- ";Publishes CRLs to a Online Certificate Status Manager, an OCSP responder provided by CMS."
+ ";Publishes CRLs to a Online Certificate Status Manager, an OCSP responder provided by CMS."
};
return params;
@@ -146,11 +144,10 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
nickname = config.getString("ca.subsystem.nickname", "");
String tokenname = config.getString("ca.subsystem.tokenname", "");
if (!tokenname.equals("internal") && !tokenname.equals("Internal Key Storage Token"))
- nickname = tokenname+":"+nickname;
+ nickname = tokenname + ":" + nickname;
} catch (Exception e) {
}
-
v.addElement(PROP_HOST + "=");
v.addElement(PROP_PORT + "=");
v.addElement(PROP_PATH + "=/ocsp/agent/ocsp/addCRL");
@@ -178,45 +175,44 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
return mConfig;
}
- protected Socket Connect(String host, boolean secure, JssSSLSocketFactory factory)
- {
- Socket socket = null;
- StringTokenizer st = new StringTokenizer(host, " ");
- while (st.hasMoreTokens()) {
- String hp = st.nextToken(); // host:port
- StringTokenizer st1 = new StringTokenizer(hp, ":");
- String h = st1.nextToken();
- int p = Integer.parseInt(st1.nextToken());
- try {
- if (secure) {
- socket = factory.makeSocket(h, p);
- } else {
- socket = new Socket(h, p);
- }
- return socket;
- } catch (Exception e) {
- }
- try {
- Thread.sleep(5000); // 5 seconds delay
- } catch (Exception e) {
- }
- }
- return null;
+ protected Socket Connect(String host, boolean secure, JssSSLSocketFactory factory) {
+ Socket socket = null;
+ StringTokenizer st = new StringTokenizer(host, " ");
+ while (st.hasMoreTokens()) {
+ String hp = st.nextToken(); // host:port
+ StringTokenizer st1 = new StringTokenizer(hp, ":");
+ String h = st1.nextToken();
+ int p = Integer.parseInt(st1.nextToken());
+ try {
+ if (secure) {
+ socket = factory.makeSocket(h, p);
+ } else {
+ socket = new Socket(h, p);
+ }
+ return socket;
+ } catch (Exception e) {
+ }
+ try {
+ Thread.sleep(5000); // 5 seconds delay
+ } catch (Exception e) {
+ }
+ }
+ return null;
}
/**
* Publishs a object to the ldap directory.
*
- * @param conn a Ldap connection
- * (null if LDAP publishing is not enabled)
+ * @param conn a Ldap connection
+ * (null if LDAP publishing is not enabled)
* @param dn dn of the ldap entry to publish cert
- * (null if LDAP publishing is not enabled)
+ * (null if LDAP publishing is not enabled)
* @param object object to publish
- * (java.security.cert.X509Certificate or,
- * java.security.cert.X509CRL)
+ * (java.security.cert.X509Certificate or,
+ * java.security.cert.X509CRL)
*/
public synchronized void publish(LDAPConnection conn, String dn, Object object)
- throws ELdapException {
+ throws ELdapException {
try {
if (!(object instanceof X509CRL))
return;
@@ -226,18 +222,18 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
// open the connection and prepare it to POST
boolean secure = true;
-
+
String host = mHost;
int port = Integer.parseInt(mPort);
String path = mPath;
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_INFO, "OCSPPublisher: " +
- "Host='" + host + "' Port='" + port +
- "' URL='" + path + "'");
- CMS.debug("OCSPPublisher: " +
- "Host='" + host + "' Port='" + port +
- "' URL='" + path + "'");
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_INFO, "OCSPPublisher: " +
+ "Host='" + host + "' Port='" + port +
+ "' URL='" + path + "'");
+ CMS.debug("OCSPPublisher: " +
+ "Host='" + host + "' Port='" + port +
+ "' URL='" + path + "'");
StringBuffer query = new StringBuffer();
query.append("crl=");
@@ -256,23 +252,23 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
}
if (mHost != null && mHost.indexOf(' ') != -1) {
- // support failover hosts configuration
- // host parameter can be
- // "directory.knowledge.com:1050 people.catalog.com 199.254.1.2"
- do {
- socket = Connect(mHost, secure, factory);
- } while (socket == null);
+ // support failover hosts configuration
+ // host parameter can be
+ // "directory.knowledge.com:1050 people.catalog.com 199.254.1.2"
+ do {
+ socket = Connect(mHost, secure, factory);
+ } while (socket == null);
} else {
- if (secure) {
- socket = factory.makeSocket(host, port);
- } else {
- socket = new Socket(host, port);
- }
+ if (secure) {
+ socket = factory.makeSocket(host, port);
+ } else {
+ socket = new Socket(host, port);
+ }
}
- if( socket == null ) {
- CMS.debug( "OCSPPublisher::publish() - socket is null!" );
- throw new ELdapException( "socket is null" );
+ if (socket == null) {
+ CMS.debug("OCSPPublisher::publish() - socket is null!");
+ throw new ELdapException("socket is null");
}
// use HttpRequest and POST
@@ -283,17 +279,17 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
httpReq.setHeader("Connection", "Keep-Alive");
httpReq.setHeader("Content-Type",
- "application/x-www-form-urlencoded");
+ "application/x-www-form-urlencoded");
httpReq.setHeader("Content-Transfer-Encoding", "7bit");
- httpReq.setHeader("Content-Length",
- Integer.toString(query.length()));
+ httpReq.setHeader("Content-Length",
+ Integer.toString(query.length()));
httpReq.setContent(query.toString());
OutputStream os = socket.getOutputStream();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(os, "UTF8");
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_INFO, "OCSPPublisher: start sending CRL");
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_INFO, "OCSPPublisher: start sending CRL");
long startTime = CMS.getCurrentDate().getTime();
CMS.debug("OCSPPublisher: start CRL sending startTime=" + startTime);
httpReq.write(outputStreamWriter);
@@ -301,8 +297,8 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
CMS.debug("OCSPPublisher: done CRL sending endTime=" + endTime + " diff=" + (endTime - startTime));
// Read the response
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_INFO, "OCSPPublisher: start getting response");
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_INFO, "OCSPPublisher: start getting response");
DataInputStream dis = new DataInputStream(socket.getInputStream());
String nextline;
String line = "";
@@ -321,40 +317,40 @@ public class OCSPPublisher implements ILdapPublisher, IExtendedPluginInfo {
}
dis.close();
if (status) {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_INFO, "OCSPPublisher: successful");
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_INFO, "OCSPPublisher: successful");
} else {
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_INFO, "OCSPPublisher: failed - " + error);
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_INFO, "OCSPPublisher: failed - " + error);
}
-
+
} catch (IOException e) {
CMS.debug("OCSPPublisher: publish failed " + e.toString());
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_OCSP_PUBLISHER_ERROR", e.toString()));
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_OCSP_PUBLISHER_ERROR", e.toString()));
} catch (CRLException e) {
CMS.debug("OCSPPublisher: publish failed " + e.toString());
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_OCSP_PUBLISHER_ERROR", e.toString()));
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_OCSP_PUBLISHER_ERROR", e.toString()));
} catch (Exception e) {
CMS.debug("OCSPPublisher: publish failed " + e.toString());
- mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
- ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_OCSP_PUBLISHER_ERROR", e.toString()));
+ mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER,
+ ILogger.LL_FAILURE, CMS.getLogMessage("PUBLISH_OCSP_PUBLISHER_ERROR", e.toString()));
}
}
/**
* Unpublishs a object to the ldap directory.
- *
+ *
* @param conn the Ldap connection
- * (null if LDAP publishing is not enabled)
+ * (null if LDAP publishing is not enabled)
* @param dn dn of the ldap entry to unpublish cert
- * (null if LDAP publishing is not enabled)
- * @param object object to unpublish
- * (java.security.cert.X509Certificate)
+ * (null if LDAP publishing is not enabled)
+ * @param object object to unpublish
+ * (java.security.cert.X509Certificate)
*/
public void unpublish(LDAPConnection conn, String dn, Object object)
- throws ELdapException {
+ throws ELdapException {
// NOT USED
}
}
diff --git a/pki/base/common/src/com/netscape/cms/publish/publishers/Utils.java b/pki/base/common/src/com/netscape/cms/publish/publishers/Utils.java
index d5717aad4..5bd342286 100644
--- a/pki/base/common/src/com/netscape/cms/publish/publishers/Utils.java
+++ b/pki/base/common/src/com/netscape/cms/publish/publishers/Utils.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.publish.publishers;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -29,10 +28,9 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;
-
/**
* Publisher utility class.
- *
+ *
* @version $Revision$, $Date$
*/
public class Utils {
@@ -104,9 +102,10 @@ public class Utils {
}
return true;
}
-
+
/**
* strips out double quotes around String parameter
+ *
* @param s the string potentially bracketed with double quotes
* @return string stripped of surrounding double quotes
*/