summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java123
1 files changed, 58 insertions, 65 deletions
diff --git a/pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java b/pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java
index 8c5d8094..2665fa2c 100644
--- a/pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java
+++ b/pki/base/common/src/com/netscape/cms/profile/def/BasicConstraintsExtDefault.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.profile.def;
-
import java.io.IOException;
import java.util.Locale;
@@ -34,12 +33,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 Basic Constraint extension
- * into the certificate template.
- *
+ * This class implements an enrollment default policy that populates Basic
+ * Constraint extension into the certificate template.
+ *
* @version $Revision$, $Date$
*/
public class BasicConstraintsExtDefault extends EnrollExtDefault {
@@ -64,21 +61,21 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
}
public void init(IProfile profile, IConfigStore config)
- throws EProfileException {
+ throws EProfileException {
super.init(profile, config);
}
- public IDescriptor getConfigDescriptor(Locale locale, String name) {
+ public IDescriptor getConfigDescriptor(Locale locale, String name) {
if (name.equals(CONFIG_CRITICAL)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
+ return new Descriptor(IDescriptor.BOOLEAN, null,
"false",
CMS.getUserMessage(locale, "CMS_PROFILE_CRITICAL"));
} else if (name.equals(CONFIG_IS_CA)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
+ return new Descriptor(IDescriptor.BOOLEAN, null,
"true",
CMS.getUserMessage(locale, "CMS_PROFILE_IS_CA"));
} else if (name.equals(CONFIG_PATH_LEN)) {
- return new Descriptor(IDescriptor.INTEGER, null,
+ return new Descriptor(IDescriptor.INTEGER, null,
"-1",
CMS.getUserMessage(locale, "CMS_PROFILE_PATH_LEN"));
}
@@ -87,15 +84,15 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
public IDescriptor getValueDescriptor(Locale locale, String name) {
if (name.equals(VAL_CRITICAL)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
+ return new Descriptor(IDescriptor.BOOLEAN, null,
"false",
CMS.getUserMessage(locale, "CMS_PROFILE_CRITICAL"));
} else if (name.equals(VAL_IS_CA)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
+ return new Descriptor(IDescriptor.BOOLEAN, null,
"true",
CMS.getUserMessage(locale, "CMS_PROFILE_IS_CA"));
} else if (name.equals(VAL_PATH_LEN)) {
- return new Descriptor(IDescriptor.INTEGER, null,
+ return new Descriptor(IDescriptor.INTEGER, null,
"-1",
CMS.getUserMessage(locale, "CMS_PROFILE_PATH_LEN"));
} else {
@@ -104,39 +101,37 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
}
public void setValue(String name, Locale locale,
- X509CertInfo info, String value)
- throws EPropertyException {
+ X509CertInfo info, String value)
+ throws EPropertyException {
try {
BasicConstraintsExtension ext = null;
- if (name == null) {
- throw new EPropertyException(CMS.getUserMessage(
+ if (name == null) {
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
ext = (BasicConstraintsExtension)
getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
- if(ext == null)
- {
- populate(null,info);
+ if (ext == null) {
+ populate(null, info);
}
if (name.equals(VAL_CRITICAL)) {
ext = (BasicConstraintsExtension)
getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
- boolean val = Boolean.valueOf(value).booleanValue();
-
+ boolean val = Boolean.valueOf(value).booleanValue();
- if(ext == null) {
+ if (ext == null) {
return;
}
ext.setCritical(val);
} else if (name.equals(VAL_IS_CA)) {
ext = (BasicConstraintsExtension)
getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
- if(ext == null) {
+ if (ext == null) {
return;
}
Boolean isCA = Boolean.valueOf(value);
@@ -146,7 +141,7 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
ext = (BasicConstraintsExtension)
getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
- if(ext == null) {
+ if (ext == null) {
return;
}
Integer pathLen = Integer.valueOf(value);
@@ -156,8 +151,8 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
throw new EPropertyException("Invalid name " + name);
}
replaceExtension(PKIXExtensions.BasicConstraints_Id.toString(),
- ext, info);
- } catch (IOException e) {
+ ext, info);
+ } catch (IOException e) {
CMS.debug("BasicConstraintsExtDefault: setValue " + e.toString());
throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
@@ -169,35 +164,34 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
}
public String getValue(String name, Locale locale,
- X509CertInfo info)
- throws EPropertyException {
+ X509CertInfo info)
+ throws EPropertyException {
try {
- if (name == null) {
- throw new EPropertyException(CMS.getUserMessage(
+ if (name == null) {
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
BasicConstraintsExtension ext = (BasicConstraintsExtension)
getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
- if(ext == null)
- {
+ if (ext == null) {
CMS.debug("BasicConstraintsExtDefault: getValue ext is null, populating a new one ");
-
- try {
- populate(null,info);
+
+ try {
+ populate(null, info);
} catch (EProfileException e) {
CMS.debug("BasicConstraintsExtDefault: getValue " + e.toString());
- 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 = (BasicConstraintsExtension)
- getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
+ ext = (BasicConstraintsExtension)
+ getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
if (ext == null) {
return null;
@@ -208,8 +202,8 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
return "false";
}
} else if (name.equals(VAL_IS_CA)) {
- ext = (BasicConstraintsExtension)
- getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
+ ext = (BasicConstraintsExtension)
+ getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
if (ext == null) {
return null;
@@ -218,41 +212,41 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
return isCA.toString();
} else if (name.equals(VAL_PATH_LEN)) {
- ext = (BasicConstraintsExtension)
- getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
+ ext = (BasicConstraintsExtension)
+ getExtension(PKIXExtensions.BasicConstraints_Id.toString(), info);
if (ext == null) {
return null;
}
Integer pathLen = (Integer)
- ext.get(BasicConstraintsExtension.PATH_LEN);
-
+ ext.get(BasicConstraintsExtension.PATH_LEN);
String pLen = null;
pLen = pathLen.toString();
- if(pLen.equals("-2"))
- {
- //This is done for bug 621700. Profile constraints actually checks for -1
- //The low level security class for some reason sets this to -2
- //This will allow the request to be approved successfuly by the agent.
+ if (pLen.equals("-2")) {
+ // This is done for bug 621700. Profile constraints actually
+ // checks for -1
+ // The low level security class for some reason sets this to
+ // -2
+ // This will allow the request to be approved successfuly by
+ // the agent.
- pLen = "-1";
+ pLen = "-1";
}
-
+
CMS.debug("BasicConstriantsExtDefault getValue(pLen) " + pLen);
-
+
return pLen;
-
- } else {
- throw new EPropertyException(CMS.getUserMessage(
+ } else {
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
} catch (IOException e) {
CMS.debug("BasicConstraintsExtDefault: getValue " + e.toString());
- throw new EPropertyException(CMS.getUserMessage(
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
}
@@ -271,11 +265,11 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
* Populates the request with this policy default.
*/
public void populate(IRequest request, X509CertInfo info)
- throws EProfileException {
+ throws EProfileException {
BasicConstraintsExtension ext = createExtension();
addExtension(PKIXExtensions.BasicConstraints_Id.toString(), ext,
- info);
+ info);
}
public BasicConstraintsExtension createExtension() {
@@ -287,8 +281,7 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
int pathLen = -2;
-
- if(!pathLenStr.equals("") ) {
+ if (!pathLenStr.equals("")) {
pathLen = Integer.valueOf(pathLenStr).intValue();
}
@@ -296,8 +289,8 @@ public class BasicConstraintsExtDefault extends EnrollExtDefault {
try {
ext = new BasicConstraintsExtension(isCA, critical, pathLen);
} catch (Exception e) {
- CMS.debug("BasicConstraintsExtDefault: createExtension " +
- e.toString());
+ CMS.debug("BasicConstraintsExtDefault: createExtension " +
+ e.toString());
return null;
}
ext.setCritical(critical);