diff options
author | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
commit | 171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch) | |
tree | 1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/common/src/com/netscape/cms/profile/def/NSCCommentExtDefault.java | |
parent | adad2fcee8a29fdb82376fbce07dedb11fccc182 (diff) | |
download | pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip |
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
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.java | 112 |
1 files changed, 65 insertions, 47 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 39f8e8c4b..01e92d6a7 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,6 +17,7 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.profile.def; + import java.io.IOException; import java.util.Locale; @@ -33,10 +34,12 @@ 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 { @@ -57,16 +60,18 @@ 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; @@ -75,60 +80,66 @@ 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); @@ -139,33 +150,37 @@ 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; @@ -175,9 +190,10 @@ 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 ""; @@ -186,34 +202,35 @@ 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); @@ -224,7 +241,8 @@ 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; } |