summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java112
1 files changed, 47 insertions, 65 deletions
diff --git a/pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java b/pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java
index 01e92d6a7..39f8e8c4b 100644
--- a/pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java
+++ b/pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.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 a Netscape comment extension
- * into the certificate template.
- *
+ * This class implements an enrollment default policy that populates a Netscape
+ * comment extension into the certificate template.
+ *
* @version $Revision$, $Date$
*/
public class NSCCommentExtDefault extends EnrollExtDefault {
@@ -60,18 +57,16 @@ public class NSCCommentExtDefault 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,
- "false",
+ return new Descriptor(IDescriptor.BOOLEAN, null, "false",
CMS.getUserMessage(locale, "CMS_PROFILE_CRITICAL"));
} else if (name.equals(CONFIG_COMMENT)) {
- return new Descriptor(IDescriptor.STRING, null,
- "Comment Here...",
+ return new Descriptor(IDescriptor.STRING, null, "Comment Here...",
CMS.getUserMessage(locale, "CMS_PROFILE_COMMENT"));
} else {
return null;
@@ -80,66 +75,60 @@ public class NSCCommentExtDefault extends EnrollExtDefault {
public IDescriptor getValueDescriptor(Locale locale, String name) {
if (name.equals(VAL_CRITICAL)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
- "false",
+ return new Descriptor(IDescriptor.BOOLEAN, null, "false",
CMS.getUserMessage(locale, "CMS_PROFILE_CRITICAL"));
} else if (name.equals(VAL_COMMENT)) {
- return new Descriptor(IDescriptor.STRING_LIST, null,
- null,
+ return new Descriptor(IDescriptor.STRING_LIST, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_COMMENT"));
} 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 {
NSCCommentExtension 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));
}
ObjectIdentifier oid = NSCCommentExtension.OID;
- ext = (NSCCommentExtension)
- getExtension(oid.toString(), info);
+ ext = (NSCCommentExtension) getExtension(oid.toString(), info);
- if(ext == null) {
- populate(null,info);
+ if (ext == null) {
+ populate(null, info);
}
if (name.equals(VAL_CRITICAL)) {
- ext = (NSCCommentExtension)
- getExtension(oid.toString(), info);
+ ext = (NSCCommentExtension) getExtension(oid.toString(), info);
boolean val = Boolean.valueOf(value).booleanValue();
- if (ext == null) {
+ if (ext == null) {
return;
}
- ext.setCritical(val);
- } else if (name.equals(VAL_COMMENT)) {
+ ext.setCritical(val);
+ } else if (name.equals(VAL_COMMENT)) {
- ext = (NSCCommentExtension)
- getExtension(oid.toString(), info);
+ ext = (NSCCommentExtension) getExtension(oid.toString(), info);
- if (ext == null) {
+ if (ext == null) {
return;
}
boolean critical = ext.isCritical();
if (value == null || value.equals(""))
ext = new NSCCommentExtension(critical, "");
- // throw new EPropertyException(name+" cannot be empty");
+ // throw new EPropertyException(name+" cannot be empty");
else
ext = new NSCCommentExtension(critical, value);
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
replaceExtension(ext.getExtensionId().toString(), ext, info);
@@ -150,37 +139,33 @@ public class NSCCommentExtDefault extends EnrollExtDefault {
}
}
- public String getValue(String name, Locale locale,
- X509CertInfo info)
- throws EPropertyException {
+ public String getValue(String name, Locale locale, X509CertInfo info)
+ throws EPropertyException {
NSCCommentExtension 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));
}
ObjectIdentifier oid = NSCCommentExtension.OID;
- ext = (NSCCommentExtension)
- getExtension(oid.toString(), info);
+ ext = (NSCCommentExtension) getExtension(oid.toString(), info);
- if(ext == null)
- {
+ if (ext == null) {
try {
- populate(null,info);
+ populate(null, 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 = (NSCCommentExtension)
- getExtension(oid.toString(), info);
+ ext = (NSCCommentExtension) getExtension(oid.toString(), info);
if (ext == null) {
return null;
@@ -190,10 +175,9 @@ public class NSCCommentExtDefault extends EnrollExtDefault {
} else {
return "false";
}
- } else if (name.equals(VAL_COMMENT)) {
+ } else if (name.equals(VAL_COMMENT)) {
- ext = (NSCCommentExtension)
- getExtension(oid.toString(), info);
+ ext = (NSCCommentExtension) getExtension(oid.toString(), info);
if (ext == null)
return "";
@@ -202,35 +186,34 @@ public class NSCCommentExtDefault extends EnrollExtDefault {
if (comment == null)
comment = "";
-
+
return comment;
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
public String getText(Locale locale) {
- String params[] = {
- getConfig(CONFIG_CRITICAL),
- getConfig(CONFIG_COMMENT)
- };
+ String params[] = { getConfig(CONFIG_CRITICAL),
+ getConfig(CONFIG_COMMENT) };
- return CMS.getUserMessage(locale, "CMS_PROFILE_DEF_NS_COMMENT_EXT", params);
+ return CMS.getUserMessage(locale, "CMS_PROFILE_DEF_NS_COMMENT_EXT",
+ params);
}
/**
* Populates the request with this policy default.
*/
public void populate(IRequest request, X509CertInfo info)
- throws EProfileException {
+ throws EProfileException {
NSCCommentExtension ext = createExtension();
addExtension(ext.getExtensionId().toString(), ext, info);
}
public NSCCommentExtension createExtension() {
- NSCCommentExtension ext = null;
+ NSCCommentExtension ext = null;
try {
boolean critical = getConfigBoolean(CONFIG_CRITICAL);
@@ -241,8 +224,7 @@ public class NSCCommentExtDefault extends EnrollExtDefault {
else
ext = new NSCCommentExtension(critical, comment);
} catch (Exception e) {
- CMS.debug("NSCCommentExtension: createExtension " +
- e.toString());
+ CMS.debug("NSCCommentExtension: createExtension " + e.toString());
}
return ext;
}