summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java81
1 files changed, 40 insertions, 41 deletions
diff --git a/pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java b/pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java
index f3b68594..f5b00970 100644
--- a/pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java
+++ b/pki/base/common/src/com/netscape/cms/profile/def/CertificateVersionDefault.java
@@ -34,10 +34,9 @@ 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 CertificateVersionDefault extends EnrollExtDefault {
@@ -54,11 +53,11 @@ public class CertificateVersionDefault 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_VERSION)) {
return new Descriptor(IDescriptor.INTEGER, null,
"3",
@@ -69,14 +68,14 @@ public class CertificateVersionDefault extends EnrollExtDefault {
}
public void setConfig(String name, String value)
- throws EPropertyException {
+ throws EPropertyException {
if (name.equals(CONFIG_VERSION)) {
- try {
- Integer.parseInt(value);
- } catch (Exception e) {
+ try {
+ Integer.parseInt(value);
+ } catch (Exception e) {
throw new EPropertyException(CMS.getUserMessage(
"CMS_INVALID_PROPERTY", CONFIG_VERSION));
- }
+ }
}
super.setConfig(name, value);
}
@@ -92,32 +91,32 @@ public class CertificateVersionDefault extends EnrollExtDefault {
}
public void setValue(String name, Locale locale,
- X509CertInfo info, String value)
- throws EPropertyException {
+ X509CertInfo info, String value)
+ throws EPropertyException {
try {
if (name == null) {
- throw new EPropertyException(CMS.getUserMessage(
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
- if (name.equals(VAL_VERSION)) {
+ if (name.equals(VAL_VERSION)) {
if (value == null || value.equals(""))
- throw new EPropertyException(name+" cannot be empty");
+ throw new EPropertyException(name + " cannot be empty");
else {
- int version = Integer.valueOf(value).intValue()-1;
-
+ int version = Integer.valueOf(value).intValue() - 1;
+
if (version == CertificateVersion.V1)
info.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V1));
+ new CertificateVersion(CertificateVersion.V1));
else if (version == CertificateVersion.V2)
info.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V2));
+ new CertificateVersion(CertificateVersion.V2));
else if (version == CertificateVersion.V3)
info.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V3));
+ new CertificateVersion(CertificateVersion.V3));
}
} else {
- throw new EPropertyException(CMS.getUserMessage(
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
} catch (IOException e) {
@@ -128,30 +127,30 @@ public class CertificateVersionDefault extends EnrollExtDefault {
}
public String getValue(String name, Locale locale,
- X509CertInfo info)
- throws EPropertyException {
+ X509CertInfo info)
+ throws EPropertyException {
if (name == null) {
- throw new EPropertyException(CMS.getUserMessage(
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
- if (name.equals(VAL_VERSION)) {
+ if (name.equals(VAL_VERSION)) {
CertificateVersion v = null;
- try {
- v = (CertificateVersion)info.get(
- X509CertInfo.VERSION);
+ try {
+ v = (CertificateVersion) info.get(
+ X509CertInfo.VERSION);
} catch (Exception e) {
}
if (v == null)
- throw new EPropertyException(CMS.getUserMessage(
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
int version = v.compare(0);
-
- return ""+(version+1);
+
+ return "" + (version + 1);
} else {
- throw new EPropertyException(CMS.getUserMessage(
+ throw new EPropertyException(CMS.getUserMessage(
locale, "CMS_INVALID_PROPERTY", name));
}
}
@@ -168,26 +167,26 @@ public class CertificateVersionDefault extends EnrollExtDefault {
* Populates the request with this policy default.
*/
public void populate(IRequest request, X509CertInfo info)
- throws EProfileException {
+ throws EProfileException {
String v = getConfig(CONFIG_VERSION);
- int version = Integer.valueOf(v).intValue()-1;
-
+ int version = Integer.valueOf(v).intValue() - 1;
+
try {
if (version == CertificateVersion.V1)
info.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V1));
+ new CertificateVersion(CertificateVersion.V1));
else if (version == CertificateVersion.V2)
info.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V2));
+ new CertificateVersion(CertificateVersion.V2));
else if (version == CertificateVersion.V3)
info.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V3));
+ new CertificateVersion(CertificateVersion.V3));
else {
throw new EProfileException(CMS.getUserMessage(
- getLocale(request), "CMS_INVALID_PROPERTY", CONFIG_VERSION));
+ getLocale(request), "CMS_INVALID_PROPERTY", CONFIG_VERSION));
}
} catch (IOException e) {
} catch (CertificateException e) {
- }
+ }
}
}