summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2012-01-09 23:32:31 -0500
committerAde Lee <alee@redhat.com>2012-01-09 23:32:31 -0500
commit466533710c179f62865e08b3031748072a0247a3 (patch)
tree4c04c20d50239be26ba8319076de90226526a542 /pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java
parentc9e3c48de53fce6908f625f40ac2b2f75d66b5a1 (diff)
downloadpki-466533710c179f62865e08b3031748072a0247a3.tar.gz
pki-466533710c179f62865e08b3031748072a0247a3.tar.xz
pki-466533710c179f62865e08b3031748072a0247a3.zip
Formatting (no wrap)
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java')
-rw-r--r--pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java80
1 files changed, 39 insertions, 41 deletions
diff --git a/pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java b/pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java
index 8b3ab40c..60c0dfbc 100644
--- a/pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java
+++ b/pki/base/common/src/com/netscape/cms/policy/extensions/PrivateKeyUsagePeriodExt.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.policy.extensions;
-
import java.io.IOException;
import java.security.cert.CertificateException;
import java.text.SimpleDateFormat;
@@ -42,20 +41,20 @@ import com.netscape.certsrv.request.IRequest;
import com.netscape.certsrv.request.PolicyResult;
import com.netscape.cms.policy.APolicyRule;
-
/**
* PrivateKeyUsagePeriod Identifier Extension policy.
* <P>
+ *
* <PRE>
* NOTE: The Policy Framework has been replaced by the Profile Framework.
* </PRE>
* <P>
- *
+ *
* @deprecated
* @version $Revision$, $Date$
*/
public class PrivateKeyUsagePeriodExt extends APolicyRule
- implements IEnrollmentPolicy, IExtendedPluginInfo {
+ implements IEnrollmentPolicy, IExtendedPluginInfo {
private final static String PROP_NOT_BEFORE = "notBefore";
private final static String PROP_NOT_AFTER = "notAfter";
@@ -94,16 +93,16 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
public String[] getExtendedPluginInfo(Locale locale) {
String[] params = {
PROP_IS_CRITICAL + ";boolean;RFC 2459 recommendation: The profile " +
- "recommends against the use of this extension. CAs " +
- "conforming to the profile MUST NOT generate certs with " +
- "critical private key usage period extensions.",
+ "recommends against the use of this extension. CAs " +
+ "conforming to the profile MUST NOT generate certs with " +
+ "critical private key usage period extensions.",
PROP_NOT_BEFORE + ";string; Date before which the Private Key is invalid.",
PROP_NOT_AFTER + ";string; Date after which the Private Key is invalid.",
IExtendedPluginInfo.HELP_TOKEN +
- ";configuration-policyrules-privatekeyusageperiod",
+ ";configuration-policyrules-privatekeyusageperiod",
IExtendedPluginInfo.HELP_TEXT +
- ";Adds (deprecated) Private Key Usage Period Extension. " +
- "Defined in RFC 2459 (4.2.1.4)"
+ ";Adds (deprecated) Private Key Usage Period Extension. " +
+ "Defined in RFC 2459 (4.2.1.4)"
};
return params;
@@ -119,17 +118,17 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
/**
* Initializes this policy rule.
- * ra.Policy.rule.<ruleName>.implName=PrivateKeyUsageExtension
- * ra.Policy.rule.<ruleName>.enable=true
- * ra.Policy.rule.<ruleName>.notBefore=30
- * ra.Policy.rule.<ruleName>.notAfter=180
- * ra.Policy.rule.<ruleName>.critical=false
- * ra.Policy.rule.<ruleName>.predicate=ou==Sales
- *
- * @param config The config store reference
+ * ra.Policy.rule.<ruleName>.implName=PrivateKeyUsageExtension
+ * ra.Policy.rule.<ruleName>.enable=true
+ * ra.Policy.rule.<ruleName>.notBefore=30
+ * ra.Policy.rule.<ruleName>.notAfter=180
+ * ra.Policy.rule.<ruleName>.critical=false
+ * ra.Policy.rule.<ruleName>.predicate=ou==Sales
+ *
+ * @param config The config store reference
*/
public void init(ISubsystem owner, IConfigStore config)
- throws EBaseException {
+ throws EBaseException {
try {
// Get params.
@@ -145,7 +144,7 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
notAfter = formatter.format(formatter.parse(mNotAfter.trim()));
} catch (Exception e) {
// e.printStackTrace();
- Object[] params = {getInstanceName(), e};
+ Object[] params = { getInstanceName(), e };
throw new EPolicyException(
CMS.getUserMessage("CMS_POLICY_INVALID_POLICY_CONFIG"), params);
@@ -154,20 +153,20 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
}
/**
- * Adds a private key usage extension if none exists.
- *
- * @param req The request on which to apply policy.
+ * Adds a private key usage extension if none exists.
+ *
+ * @param req The request on which to apply policy.
* @return The policy result object.
*/
public PolicyResult apply(IRequest req) {
PolicyResult res = PolicyResult.ACCEPTED;
// get cert info.
- X509CertInfo[] ci =
- req.getExtDataInCertInfoArray(IRequest.CERT_INFO);
-
+ X509CertInfo[] ci =
+ req.getExtDataInCertInfoArray(IRequest.CERT_INFO);
+
if (ci == null || ci[0] == null) {
- setError(req, CMS.getUserMessage("CMS_POLICY_NO_CERT_INFO"), NAME);
+ setError(req, CMS.getUserMessage("CMS_POLICY_NO_CERT_INFO"), NAME);
return PolicyResult.REJECTED; // unrecoverable error.
}
@@ -201,7 +200,7 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
// remove any previously computed version of the extension
try {
extensions.delete(PrivateKeyUsageExtension.class.getSimpleName());
-
+
} catch (IOException e) {
}
@@ -209,16 +208,16 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
try {
ext = new PrivateKeyUsageExtension(
- formatter.parse(mNotBefore),
+ formatter.parse(mNotBefore),
formatter.parse(mNotAfter));
certInfo.set(X509CertInfo.VERSION,
- new CertificateVersion(CertificateVersion.V3));
+ new CertificateVersion(CertificateVersion.V3));
extensions.set(PrivateKeyUsageExtension.class.getSimpleName(), ext);
} catch (Exception e) {
- if (e instanceof RuntimeException)
+ if (e instanceof RuntimeException)
throw (RuntimeException) e;
- log(ILogger.LL_FAILURE,
- CMS.getLogMessage("POLICY_ERROR_CREATE_PRIVATE_KEY_EXT", e.toString()));
+ log(ILogger.LL_FAILURE,
+ CMS.getLogMessage("POLICY_ERROR_CREATE_PRIVATE_KEY_EXT", e.toString()));
setError(req, CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR"), NAME);
return PolicyResult.REJECTED;
}
@@ -227,11 +226,11 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
/**
* Return configured parameters for a policy rule instance.
- *
+ *
* @return Empty Vector since this policy has no configuration parameters.
- * for this policy instance.
+ * for this policy instance.
*/
- public Vector<String> getInstanceParams() {
+ public Vector<String> getInstanceParams() {
Vector<String> params = new Vector<String>();
params.addElement(PROP_IS_CRITICAL + "=" + mCritical);
@@ -242,11 +241,11 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
/**
* Return default parameters for a policy implementation.
- *
- * @return Empty Vector since this policy implementation has no
- * configuration parameters.
+ *
+ * @return Empty Vector since this policy implementation has no
+ * configuration parameters.
*/
- public Vector<String> getDefaultParams() {
+ public Vector<String> getDefaultParams() {
Vector<String> defParams = new Vector<String>();
defParams.addElement(PROP_IS_CRITICAL + "=" + DEFAULT_CRITICALITY);
@@ -255,4 +254,3 @@ public class PrivateKeyUsagePeriodExt extends APolicyRule
return defParams;
}
}
-