summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.java
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.java204
1 files changed, 99 insertions, 105 deletions
diff --git a/pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.java b/pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.java
index 8a3f2afc..115d3f62 100644
--- a/pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.java
+++ b/pki/base/common/src/com/netscape/cms/profile/def/SubjectInfoAccessExtDefault.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;
@@ -40,11 +39,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 Subject Info Access extension.
- *
+ * This class implements an enrollment default policy that populates Subject
+ * Info Access extension.
+ *
* @version $Revision$, $Date$
*/
public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
@@ -87,29 +85,28 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
return num;
}
-
+
public void init(IProfile profile, IConfigStore config)
- throws EProfileException {
+ throws EProfileException {
super.init(profile, config);
refreshConfigAndValueNames();
}
- 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_ADS)) {
- try {
- num = Integer.parseInt(value);
+ try {
+ num = Integer.parseInt(value);
- if (num >= MAX_NUM_AD || num < 0) {
- throw new EPropertyException(CMS.getUserMessage(
+ if (num >= MAX_NUM_AD || num < 0) {
+ throw new EPropertyException(CMS.getUserMessage(
"CMS_INVALID_PROPERTY", CONFIG_NUM_ADS));
- }
+ }
- } catch (Exception e) {
+ } catch (Exception e) {
throw new EPropertyException(CMS.getUserMessage(
- "CMS_INVALID_PROPERTY", CONFIG_NUM_ADS));
- }
+ "CMS_INVALID_PROPERTY", CONFIG_NUM_ADS));
+ }
}
super.setConfig(name, value);
}
@@ -137,30 +134,27 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
}
}
- 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.startsWith(CONFIG_AD_METHOD)) {
- return new Descriptor(IDescriptor.STRING, null,
- null,
+ return new Descriptor(IDescriptor.STRING, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_AD_METHOD"));
} else if (name.startsWith(CONFIG_AD_LOCATIONTYPE)) {
- return new Descriptor(IDescriptor.CHOICE, "RFC822Name,DNSName,DirectoryName,EDIPartyName,URIName,IPAddress,OIDName",
- "URIName",
- CMS.getUserMessage(locale, "CMS_PROFILE_AD_LOCATIONTYPE"));
+ return new Descriptor(
+ IDescriptor.CHOICE,
+ "RFC822Name,DNSName,DirectoryName,EDIPartyName,URIName,IPAddress,OIDName",
+ "URIName", CMS.getUserMessage(locale,
+ "CMS_PROFILE_AD_LOCATIONTYPE"));
} else if (name.startsWith(CONFIG_AD_LOCATION)) {
- return new Descriptor(IDescriptor.STRING, null,
- null,
+ return new Descriptor(IDescriptor.STRING, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_AD_LOCATION"));
} else if (name.startsWith(CONFIG_AD_ENABLE)) {
- return new Descriptor(IDescriptor.BOOLEAN, null,
- "false",
+ return new Descriptor(IDescriptor.BOOLEAN, null, "false",
CMS.getUserMessage(locale, "CMS_PROFILE_AD_ENABLE"));
- } else if (name.startsWith(CONFIG_NUM_ADS)) {
- return new Descriptor(IDescriptor.INTEGER, null,
- "1",
+ } else if (name.startsWith(CONFIG_NUM_ADS)) {
+ return new Descriptor(IDescriptor.INTEGER, null, "1",
CMS.getUserMessage(locale, "CMS_PROFILE_NUM_ADS"));
}
return null;
@@ -168,58 +162,52 @@ public class SubjectInfoAccessExtDefault 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_GENERAL_NAMES)) {
- return new Descriptor(IDescriptor.STRING_LIST, null,
- null,
+ return new Descriptor(IDescriptor.STRING_LIST, null, null,
CMS.getUserMessage(locale, "CMS_PROFILE_GENERAL_NAMES"));
} 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 {
SubjectInfoAccessExtension 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));
}
-
SubjectInfoAccessExtension a = new SubjectInfoAccessExtension(false);
ObjectIdentifier oid = a.getExtensionId();
- ext = (SubjectInfoAccessExtension)
- getExtension(oid.toString(), info);
+ ext = (SubjectInfoAccessExtension) getExtension(oid.toString(),
+ info);
- if(ext == null) {
- populate(null,info);
+ if (ext == null) {
+ populate(null, info);
}
-
+
if (name.equals(VAL_CRITICAL)) {
- ext = (SubjectInfoAccessExtension)
- getExtension(oid.toString(), info);
+ ext = (SubjectInfoAccessExtension) 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_GENERAL_NAMES)) {
+ ext.setCritical(val);
+ } else if (name.equals(VAL_GENERAL_NAMES)) {
- ext = (SubjectInfoAccessExtension)
- getExtension(oid.toString(), info);
+ ext = (SubjectInfoAccessExtension) getExtension(oid.toString(),
+ info);
- if(ext == null)
- {
+ if (ext == null) {
return;
}
boolean critical = ext.isCritical();
@@ -255,73 +243,78 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
GeneralName gn = null;
if (locationType != null || location != null) {
- GeneralNameInterface interface1 = parseGeneralName(locationType + ":" + location);
+ GeneralNameInterface interface1 = parseGeneralName(locationType
+ + ":" + location);
if (interface1 == null)
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", locationType));
+ throw new EPropertyException(
+ CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY",
+ locationType));
gn = new GeneralName(interface1);
}
-
+
if (method != null) {
try {
- ext.addAccessDescription(new ObjectIdentifier(method), gn);
+ ext.addAccessDescription(new ObjectIdentifier(
+ method), gn);
} catch (NumberFormatException ee) {
- CMS.debug("SubjectInfoAccessExtDefault: "+ee.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_PROFILE_DEF_SIA_OID", method));
+ CMS.debug("SubjectInfoAccessExtDefault: "
+ + ee.toString());
+ throw new EPropertyException(
+ CMS.getUserMessage(locale,
+ "CMS_PROFILE_DEF_SIA_OID",
+ method));
}
}
}
}
} 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);
} catch (IOException e) {
CMS.debug("SubjectInfoAccessExtDefault: " + e.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
} catch (EProfileException e) {
CMS.debug("SubjectInfoAccessExtDefault: " + e.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
- public String getValue(String name, Locale locale,
- X509CertInfo info)
- throws EPropertyException {
+ public String getValue(String name, Locale locale, X509CertInfo info)
+ throws EPropertyException {
SubjectInfoAccessExtension 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));
}
SubjectInfoAccessExtension a = new SubjectInfoAccessExtension(false);
- ObjectIdentifier oid = a.getExtensionId();
+ ObjectIdentifier oid = a.getExtensionId();
- ext = (SubjectInfoAccessExtension)
- getExtension(oid.toString(), info);
+ ext = (SubjectInfoAccessExtension) getExtension(oid.toString(), info);
- if(ext == null)
- {
+ if (ext == null) {
try {
- populate(null,info);
+ populate(null, info);
} catch (EProfileException e) {
- CMS.debug("SubjectInfoAccessExtDefault: getValue " + e.toString());
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ CMS.debug("SubjectInfoAccessExtDefault: getValue "
+ + e.toString());
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
if (name.equals(VAL_CRITICAL)) {
- ext = (SubjectInfoAccessExtension)
- getExtension(oid.toString(), info);
+ ext = (SubjectInfoAccessExtension) getExtension(oid.toString(),
+ info);
if (ext == null) {
return null;
@@ -331,20 +324,20 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
} else {
return "false";
}
- } else if (name.equals(VAL_GENERAL_NAMES)) {
+ } else if (name.equals(VAL_GENERAL_NAMES)) {
- ext = (SubjectInfoAccessExtension)
- getExtension(oid.toString(), info);
+ ext = (SubjectInfoAccessExtension) getExtension(oid.toString(),
+ info);
if (ext == null)
return "";
int num = getNumAds();
-
+
CMS.debug("SubjectInfoAccess num=" + num);
Vector recs = new Vector();
- for (int i = 0; i < num; i++) {
+ for (int i = 0; i < num; i++) {
NameValuePairs np = new NameValuePairs();
AccessDescription des = null;
@@ -358,7 +351,7 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
np.add(AD_ENABLE, "false");
} else {
ObjectIdentifier methodOid = des.getMethod();
- GeneralName gn = des.getLocation();
+ GeneralName gn = des.getLocation();
np.add(AD_METHOD, methodOid.toString());
np.add(AD_LOCATION_TYPE, getGeneralNameType(gn));
@@ -370,8 +363,8 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
return buildRecords(recs);
} else {
- throw new EPropertyException(CMS.getUserMessage(
- locale, "CMS_INVALID_PROPERTY", name));
+ throw new EPropertyException(CMS.getUserMessage(locale,
+ "CMS_INVALID_PROPERTY", name));
}
}
@@ -397,7 +390,7 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
ads.append(getConfig(CONFIG_AD_ENABLE + i));
ads.append("}");
}
- return CMS.getUserMessage(locale, "CMS_PROFILE_DEF_SIA_TEXT",
+ return CMS.getUserMessage(locale, "CMS_PROFILE_DEF_SIA_TEXT",
getConfig(CONFIG_CRITICAL), ads.toString());
}
@@ -405,14 +398,14 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
* Populates the request with this policy default.
*/
public void populate(IRequest request, X509CertInfo info)
- throws EProfileException {
+ throws EProfileException {
SubjectInfoAccessExtension ext = createExtension();
addExtension(ext.getExtensionId().toString(), ext, info);
}
public SubjectInfoAccessExtension createExtension() {
- SubjectInfoAccessExtension ext = null;
+ SubjectInfoAccessExtension ext = null;
int num = getNumAds();
try {
@@ -434,21 +427,22 @@ public class SubjectInfoAccessExtDefault extends EnrollExtDefault {
String hostname = CMS.getEENonSSLHost();
String port = CMS.getEENonSSLPort();
if (hostname != null && port != null)
- location = "http://"+hostname+":"+port+"/ocsp";
+ location = "http://" + hostname + ":" + port
+ + "/ocsp";
}
}
String s = locationType + ":" + location;
GeneralNameInterface gn = parseGeneralName(s);
if (gn != null) {
- ext.addAccessDescription(new ObjectIdentifier(method),
- new GeneralName(gn));
+ ext.addAccessDescription(new ObjectIdentifier(method),
+ new GeneralName(gn));
}
}
}
} catch (Exception e) {
- CMS.debug("SubjectInfoAccessExtDefault: createExtension " +
- e.toString());
+ CMS.debug("SubjectInfoAccessExtDefault: createExtension "
+ + e.toString());
}
return ext;