summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java249
1 files changed, 109 insertions, 140 deletions
diff --git a/pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java b/pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java
index 7b9bcd52..a2de8447 100644
--- a/pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java
+++ b/pki/base/common/src/com/netscape/cms/profile/def/FreshestCRLExtDefault.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.profile.def;
-
import java.io.IOException;
import java.util.Enumeration;
import java.util.Locale;
@@ -42,12 +41,10 @@ import com.netscape.certsrv.property.EPropertyException;
import com.netscape.certsrv.property.IDescriptor;
import com.netscape.certsrv.request.IRequest;
-
/**
- * This class implements an enrollment default policy
- * that populates Freshest CRL extension
- * into the certificate template.
- *
+ * This class implements an enrollment default policy that populates Freshest
+ * CRL extension into the certificate template.
+ *
* @version $Revision$, $Date$
*/
public class FreshestCRLExtDefault extends EnrollExtDefault {
@@ -61,8 +58,7 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
public static final String CONFIG_ENABLE = "freshestCRLPointEnable_";
public static final String VAL_CRITICAL = "freshestCRLCritical";
- public static final String VAL_CRL_DISTRIBUTION_POINTS =
- "freshestCRLPointsValue";
+ public static final String VAL_CRL_DISTRIBUTION_POINTS = "freshestCRLPointsValue";
private static final String POINT_TYPE = "Point Type";
private static final String POINT_NAME = "Point Name";
@@ -78,12 +74,11 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
}
public void init(IProfile profile, IConfigStore config)
- throws EProfileException {
+ throws EProfileException {
super.init(profile, config);
refreshConfigAndValueNames();
}
-
protected int getNumPoints() {
int num = DEF_NUM_POINTS;
String val = getConfig(CONFIG_NUM_POINTS);
@@ -102,34 +97,32 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
return num;
}
- public void setConfig(String name, String value)
- throws EPropertyException {
+ public void setConfig(String name, String value) throws EPropertyException {
int num = 0;
if (name.equals(CONFIG_NUM_POINTS)) {
- try {
- num = Integer.parseInt(value);
+ try {
+ num = Integer.parseInt(value);
- if (num >= MAX_NUM_POINTS || num < 0) {
- throw new EPropertyException(CMS.getUserMessage(
+ if (num >= MAX_NUM_POINTS || num < 0) {
+ throw new EPropertyException(CMS.getUserMessage(
"CMS_INVALID_PROPERTY", CONFIG_NUM_POINTS));
- }
+ }
- } catch (Exception e) {
+ } catch (Exception e) {
throw new EPropertyException(CMS.getUserMessage(
- "CMS_INVALID_PROPERTY", CONFIG_NUM_POINTS));
- }
+ "CMS_INVALID_PROPERTY", CONFIG_NUM_POINTS));
+ }
}
super.setConfig(name, value);
}
-
public Enumeration getConfigNames() {
refreshConfigAndValueNames();
return super.getConfigNames();
}
protected void refreshConfigAndValueNames() {
- //refesh our config name list
+ // refesh our config name list
super.refreshConfigAndValueNames();
addValueName(VAL_CRITICAL);
@@ -149,88 +142,76 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
}
- public IDescriptor getConfigDescriptor(Locale locale, String name) {
- if (name.equals(CONFIG_CRITICAL)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
- "false",
+ public IDescriptor getConfigDescriptor(Locale locale, String name) {
+ if (name.equals(CONFIG_CRITICAL)) {
+ return new Descriptor(IDescriptor.BOOLEAN, null, "false",
CMS.getUserMessage(locale, "CMS_PROFILE_CRITICAL"));
} else if (name.startsWith(CONFIG_POINT_TYPE)) {
- return new Descriptor(IDescriptor.STRING, null,
- null,
+ return new Descriptor(IDescriptor.STRING, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_POINT_TYPE"));
} else if (name.startsWith(CONFIG_POINT_NAME)) {
- return new Descriptor(IDescriptor.STRING, null,
- null,
+ return new Descriptor(IDescriptor.STRING, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_POINT_NAME"));
} else if (name.startsWith(CONFIG_ISSUER_TYPE)) {
- return new Descriptor(IDescriptor.STRING, null,
- null,
+ return new Descriptor(IDescriptor.STRING, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_ISSUER_TYPE"));
} else if (name.startsWith(CONFIG_ISSUER_NAME)) {
- return new Descriptor(IDescriptor.STRING, null,
- null,
+ return new Descriptor(IDescriptor.STRING, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_ISSUER_NAME"));
} else if (name.startsWith(CONFIG_ENABLE)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
- null,
+ return new Descriptor(IDescriptor.BOOLEAN, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_ENABLE"));
} else if (name.startsWith(CONFIG_NUM_POINTS)) {
- return new Descriptor(IDescriptor.INTEGER, null,
- "1",
- CMS.getUserMessage(locale, "CMS_PROFILE_NUM_DIST_POINTS"));
+ return new Descriptor(IDescriptor.INTEGER, null, "1",
+ CMS.getUserMessage(locale, "CMS_PROFILE_NUM_DIST_POINTS"));
} else {
return null;
}
}
public IDescriptor getValueDescriptor(Locale locale, String name) {
- if (name.equals(VAL_CRITICAL)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
- "false",
+ if (name.equals(VAL_CRITICAL)) {
+ return new Descriptor(IDescriptor.BOOLEAN, null, "false",
CMS.getUserMessage(locale, "CMS_PROFILE_CRITICAL"));
} else if (name.equals(VAL_CRL_DISTRIBUTION_POINTS)) {
- return new Descriptor(IDescriptor.STRING_LIST, null,
- null,
- CMS.getUserMessage(locale, "CMS_PROFILE_CRL_DISTRIBUTION_POINTS"));
+ return new Descriptor(IDescriptor.STRING_LIST, null, null,
+ CMS.getUserMessage(locale,
+ "CMS_PROFILE_CRL_DISTRIBUTION_POINTS"));
} else {
return null;
}
}
- public void setValue(String name, Locale locale,
- X509CertInfo info, String value)
- throws EPropertyException {
+ public void setValue(String name, Locale locale, X509CertInfo info,
+ String value) throws EPropertyException {
try {
FreshestCRLExtension ext = null;
- if (name == null) {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ if (name == null) {
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
- ext = (FreshestCRLExtension)
- getExtension(FreshestCRLExtension.OID,
- info);
+ ext = (FreshestCRLExtension) getExtension(FreshestCRLExtension.OID,
+ info);
- if(ext == null) {
- populate(locale,info);
+ if (ext == null) {
+ populate(locale, info);
}
-
+
if (name.equals(VAL_CRITICAL)) {
- ext = (FreshestCRLExtension)
- getExtension(FreshestCRLExtension.OID,
- info);
+ ext = (FreshestCRLExtension) getExtension(
+ FreshestCRLExtension.OID, info);
boolean val = Boolean.valueOf(value).booleanValue();
- ext.setCritical(val);
- } else if (name.equals(VAL_CRL_DISTRIBUTION_POINTS)) {
- ext = (FreshestCRLExtension)
- getExtension(FreshestCRLExtension.OID,
- info);
+ ext.setCritical(val);
+ } else if (name.equals(VAL_CRL_DISTRIBUTION_POINTS)) {
+ ext = (FreshestCRLExtension) getExtension(
+ FreshestCRLExtension.OID, info);
Vector v = parseRecords(value);
int size = v.size();
-
+
boolean critical = ext.isCritical();
int i = 0;
@@ -266,7 +247,7 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
if (issuerType != null)
addIssuer(locale, cdp, issuerType, issuerValue);
- // this is the first distribution point
+ // this is the first distribution point
if (i == 0) {
ext = new FreshestCRLExtension(cdp);
ext.setCritical(critical);
@@ -276,100 +257,91 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
}
}
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
- replaceExtension(PKIXExtensions.FreshestCRL_Id.toString(),
- ext, info);
+ replaceExtension(PKIXExtensions.FreshestCRL_Id.toString(), ext,
+ info);
} catch (EProfileException e) {
- CMS.debug("FreshestCRLExtDefault: setValue " +
- e.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ CMS.debug("FreshestCRLExtDefault: setValue " + e.toString());
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
- private void addCRLPoint(Locale locale, CRLDistributionPoint cdp, String type,
- String value) throws EPropertyException {
+ private void addCRLPoint(Locale locale, CRLDistributionPoint cdp,
+ String type, String value) throws EPropertyException {
try {
if (value == null || value.length() == 0)
return;
-
+
if (isGeneralNameType(type)) {
GeneralNames gen = new GeneralNames();
- gen.addElement(parseGeneralName(type,value));
+ gen.addElement(parseGeneralName(type, value));
cdp.setFullName(gen);
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", type));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", type));
}
} catch (IOException e) {
- CMS.debug("FreshestCRLExtDefault: addCRLPoint " +
- e.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", type));
+ CMS.debug("FreshestCRLExtDefault: addCRLPoint " + e.toString());
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", type));
} catch (GeneralNamesException e) {
- CMS.debug("FreshestCRLExtDefault: addCRLPoint " +
- e.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", type));
+ CMS.debug("FreshestCRLExtDefault: addCRLPoint " + e.toString());
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", type));
}
}
- private void addIssuer(Locale locale, CRLDistributionPoint cdp, String type,
- String value) throws EPropertyException {
+ private void addIssuer(Locale locale, CRLDistributionPoint cdp,
+ String type, String value) throws EPropertyException {
if (value == null || value.length() == 0)
return;
try {
if (isGeneralNameType(type)) {
GeneralNames gen = new GeneralNames();
- gen.addElement(parseGeneralName(type,value));
+ gen.addElement(parseGeneralName(type, value));
cdp.setCRLIssuer(gen);
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", type));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", type));
}
} catch (IOException e) {
- CMS.debug("FreshestCRLExtDefault: addIssuer " +
- e.toString());
+ CMS.debug("FreshestCRLExtDefault: addIssuer " + e.toString());
} catch (GeneralNamesException e) {
- CMS.debug("FreshestCRLExtDefault: addIssuer " +
- e.toString());
+ CMS.debug("FreshestCRLExtDefault: addIssuer " + e.toString());
}
}
- public String getValue(String name, Locale locale,
- X509CertInfo info)
- throws EPropertyException {
+ public String getValue(String name, Locale locale, X509CertInfo info)
+ throws EPropertyException {
FreshestCRLExtension ext = null;
if (name == null) {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
- ext = (FreshestCRLExtension)
- getExtension(FreshestCRLExtension.OID,
- info);
- if(ext == null)
- {
+ ext = (FreshestCRLExtension) getExtension(FreshestCRLExtension.OID,
+ info);
+ if (ext == null) {
try {
- populate(locale,info);
+ populate(locale, info);
} catch (EProfileException e) {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
if (name.equals(VAL_CRITICAL)) {
- ext = (FreshestCRLExtension)
- getExtension(FreshestCRLExtension.OID,
- info);
+ ext = (FreshestCRLExtension) getExtension(FreshestCRLExtension.OID,
+ info);
if (ext == null) {
return null;
@@ -379,10 +351,9 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
} else {
return "false";
}
- } else if (name.equals(VAL_CRL_DISTRIBUTION_POINTS)) {
- ext = (FreshestCRLExtension)
- getExtension(FreshestCRLExtension.OID,
- info);
+ } else if (name.equals(VAL_CRL_DISTRIBUTION_POINTS)) {
+ ext = (FreshestCRLExtension) getExtension(FreshestCRLExtension.OID,
+ info);
if (ext == null)
return "";
@@ -395,7 +366,7 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
NameValuePairs pairs = null;
if (i < ext.getNumPoints()) {
- CRLDistributionPoint p = ext.getPointAt(i);
+ CRLDistributionPoint p = ext.getPointAt(i);
GeneralNames gns = p.getFullName();
pairs = buildGeneralNames(gns, p);
@@ -404,11 +375,11 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
}
recs.addElement(pairs);
}
-
+
return buildRecords(recs);
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
@@ -423,8 +394,8 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
return pairs;
}
- protected NameValuePairs buildGeneralNames(GeneralNames gns, CRLDistributionPoint p)
- throws EPropertyException {
+ protected NameValuePairs buildGeneralNames(GeneralNames gns,
+ CRLDistributionPoint p) throws EPropertyException {
NameValuePairs pairs = new NameValuePairs();
@@ -495,17 +466,15 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
sb.append(getConfig(CONFIG_ENABLE + i));
sb.append("}");
}
- return CMS.getUserMessage(locale,
- "CMS_PROFILE_DEF_FRESHEST_CRL_EXT",
- getConfig(CONFIG_CRITICAL),
- sb.toString());
+ return CMS.getUserMessage(locale, "CMS_PROFILE_DEF_FRESHEST_CRL_EXT",
+ getConfig(CONFIG_CRITICAL), sb.toString());
}
/**
* Populates the request with this policy default.
*/
public void populate(IRequest request, X509CertInfo info)
- throws EProfileException {
+ throws EProfileException {
FreshestCRLExtension ext = createExtension(request);
if (ext == null)
@@ -519,30 +488,31 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
try {
boolean critical = getConfigBoolean(CONFIG_CRITICAL);
- ext.setCritical(critical);
+ ext.setCritical(critical);
num = getNumPoints();
for (int i = 0; i < num; i++) {
CRLDistributionPoint cdp = new CRLDistributionPoint();
- String enable = getConfig(CONFIG_ENABLE + i);
- String pointType = getConfig(CONFIG_POINT_TYPE + i);
+ String enable = getConfig(CONFIG_ENABLE + i);
+ String pointType = getConfig(CONFIG_POINT_TYPE + i);
String pointName = getConfig(CONFIG_POINT_NAME + i);
String issuerType = getConfig(CONFIG_ISSUER_TYPE + i);
String issuerName = getConfig(CONFIG_ISSUER_NAME + i);
if (enable != null && enable.equals("true")) {
if (pointType != null)
- addCRLPoint(getLocale(request), cdp, pointType, pointName);
+ addCRLPoint(getLocale(request), cdp, pointType,
+ pointName);
if (issuerType != null)
- addIssuer(getLocale(request), cdp, issuerType, issuerName);
+ addIssuer(getLocale(request), cdp, issuerType,
+ issuerName);
- ext.addPoint(cdp);
+ ext.addPoint(cdp);
}
}
} catch (Exception e) {
- CMS.debug("FreshestCRLExtDefault: createExtension " +
- e.toString());
+ CMS.debug("FreshestCRLExtDefault: createExtension " + e.toString());
}
return ext;
@@ -552,7 +522,7 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
* Populates the request with this policy default.
*/
private void populate(Locale locale, X509CertInfo info)
- throws EProfileException {
+ throws EProfileException {
FreshestCRLExtension ext = createExtension(locale);
if (ext == null)
@@ -588,8 +558,7 @@ public class FreshestCRLExtDefault extends EnrollExtDefault {
}
}
} catch (Exception e) {
- CMS.debug("FreshestCRLExtDefault: createExtension " +
- e.toString());
+ CMS.debug("FreshestCRLExtDefault: createExtension " + e.toString());
}
return ext;