diff options
author | Ade Lee <alee@redhat.com> | 2012-01-11 12:57:53 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2012-01-11 13:49:04 -0500 |
commit | 10cfe7756e967ac91c66d33b392aeab9cf3780fb (patch) | |
tree | d5ac9b58442265d2ce5ef60e31f041ddacba1b4f /pki/base/common/src/com/netscape/cms/policy/APolicyRule.java | |
parent | edcb24f65cc3700e75d0a1d14dc2483f210b0ee4 (diff) | |
download | pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.gz pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.tar.xz pki-10cfe7756e967ac91c66d33b392aeab9cf3780fb.zip |
Formatting (no line wrap in comments or code)
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/policy/APolicyRule.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/policy/APolicyRule.java | 107 |
1 files changed, 54 insertions, 53 deletions
diff --git a/pki/base/common/src/com/netscape/cms/policy/APolicyRule.java b/pki/base/common/src/com/netscape/cms/policy/APolicyRule.java index d9a527d68..1c43d92d4 100644 --- a/pki/base/common/src/com/netscape/cms/policy/APolicyRule.java +++ b/pki/base/common/src/com/netscape/cms/policy/APolicyRule.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.policy; - import java.io.IOException; import java.security.InvalidKeyException; import java.security.MessageDigest; @@ -42,16 +41,16 @@ import com.netscape.certsrv.request.AgentApprovals; import com.netscape.certsrv.request.IRequest; import com.netscape.certsrv.request.PolicyResult; - /** * The abstract policy rule that concrete implementations will * extend. * <P> + * * <PRE> * NOTE: The Policy Framework has been replaced by the Profile Framework. * </PRE> * <P> - * + * * @deprecated * @version $Revision$, $Date$ */ @@ -68,15 +67,16 @@ public abstract class APolicyRule implements IPolicyRule { /** * Initializes the policy rule. * <P> - * - * @param config The config store reference + * + * @param config The config store reference */ public abstract void init(ISubsystem owner, IConfigStore config) - throws EBaseException; + throws EBaseException; /** * Gets the description for this policy rule. * <P> + * * @return The Description for this rule. */ public String getDescription() { @@ -86,8 +86,8 @@ public abstract class APolicyRule implements IPolicyRule { /** * Sets a predicate expression for rule matching. * <P> - * - * @param exp The predicate expression for the rule. + * + * @param exp The predicate expression for the rule. */ public void setPredicate(IExpression exp) { mFilterExp = exp; @@ -96,7 +96,7 @@ public abstract class APolicyRule implements IPolicyRule { /** * Returns the predicate expression for the rule. * <P> - * + * * @return The predicate expression for the rule. */ public IExpression getPredicate() { @@ -106,7 +106,7 @@ public abstract class APolicyRule implements IPolicyRule { /** * Returns the name of the policy rule. * <P> - * + * * @return The name of the policy class. */ public String getName() { @@ -114,45 +114,45 @@ public abstract class APolicyRule implements IPolicyRule { } /** - * Sets the instance name for a policy rule. + * Sets the instance name for a policy rule. * <P> - * - * @param instanceName The name of the rule instance. + * + * @param instanceName The name of the rule instance. */ - public void setInstanceName(String instanceName) { + public void setInstanceName(String instanceName) { mInstanceName = instanceName; } /** * Returns the name of the policy rule instance. * <P> - * + * * @return The name of the policy rule instance if set, else - * the name of the rule class. + * the name of the rule class. */ - public String getInstanceName() { + public String getInstanceName() { return mInstanceName != null ? mInstanceName : NAME; } /** * Applies the policy on the given Request. * <P> - * - * @param req The request on which to apply policy. + * + * @param req The request on which to apply policy. * @return The policy result object. */ public abstract PolicyResult apply(IRequest req); /** * Return configured parameters for a policy rule instance. - * + * * @return nvPairs A Vector of name/value pairs. */ public abstract Vector getInstanceParams(); /** * Return default parameters for a policy implementation. - * + * * @return nvPairs A Vector of name/value pairs. */ public abstract Vector getDefaultParams(); @@ -161,8 +161,8 @@ public abstract class APolicyRule implements IPolicyRule { setPolicyException(req, format, params); } - public void setError(IRequest req, String format, String arg1, - String arg2) { + public void setError(IRequest req, String format, String arg1, + String arg2) { Object[] np = new Object[2]; np[0] = arg1; @@ -189,7 +189,7 @@ public abstract class APolicyRule implements IPolicyRule { /** * determines whether a DEFERRED policy result should be returned - * by checking the contents of the AgentApprovals attribute. This + * by checking the contents of the AgentApprovals attribute. This * call should be used by policy modules instead of returning * PolicyResult.DEFERRED directly. * <p> @@ -223,12 +223,12 @@ public abstract class APolicyRule implements IPolicyRule { } } - public void setPolicyException(IRequest req, String format, - Object[] params) { - if (format == null) + public void setPolicyException(IRequest req, String format, + Object[] params) { + if (format == null) return; - EPolicyException ex; + EPolicyException ex; if (params == null) ex = new EPolicyException(format); @@ -247,12 +247,12 @@ public abstract class APolicyRule implements IPolicyRule { * log a message for this policy rule. */ protected void log(int level, String msg) { - mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER, level, - "APolicyRule " + NAME + ": " + msg); + mLogger.log(ILogger.EV_SYSTEM, ILogger.S_OTHER, level, + "APolicyRule " + NAME + ": " + msg); } - public static KeyIdentifier createKeyIdentifier(X509Key key) - throws NoSuchAlgorithmException, InvalidKeyException { + public static KeyIdentifier createKeyIdentifier(X509Key key) + throws NoSuchAlgorithmException, InvalidKeyException { MessageDigest md = MessageDigest.getInstance("SHA-1"); md.update(key.getEncoded()); @@ -260,19 +260,20 @@ public abstract class APolicyRule implements IPolicyRule { } /** - * Form a byte array of octet string key identifier from the sha-1 hash of + * Form a byte array of octet string key identifier from the sha-1 hash of * the Subject Public Key INFO. (including algorithm ID, etc.) * <p> + * * @param certInfo cert info of the certificate. * @return A Key identifier with the sha-1 hash of subject public key. */ protected KeyIdentifier formSpkiSHA1KeyId(X509CertInfo certInfo) - throws EBaseException { + throws EBaseException { KeyIdentifier keyId = null; try { CertificateX509Key certKey = - (CertificateX509Key) certInfo.get(X509CertInfo.KEY); + (CertificateX509Key) certInfo.get(X509CertInfo.KEY); if (certKey == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("POLICY_MISSING_KEY_1", "")); @@ -286,23 +287,23 @@ public abstract class APolicyRule implements IPolicyRule { } keyId = createKeyIdentifier(key); } catch (IOException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } catch (CertificateException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } catch (NoSuchAlgorithmException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } catch (InvalidKeyException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } @@ -310,19 +311,20 @@ public abstract class APolicyRule implements IPolicyRule { } /** - * Form a byte array of octet string key identifier from the sha-1 hash of + * Form a byte array of octet string key identifier from the sha-1 hash of * the Subject Public Key BIT STRING. * <p> + * * @param certInfo cert info of the certificate. * @return A Key identifier with the sha-1 hash of subject public key. */ protected KeyIdentifier formSHA1KeyId(X509CertInfo certInfo) - throws EBaseException { + throws EBaseException { KeyIdentifier keyId = null; try { CertificateX509Key certKey = - (CertificateX509Key) certInfo.get(X509CertInfo.KEY); + (CertificateX509Key) certInfo.get(X509CertInfo.KEY); if (certKey == null) { log(ILogger.LL_FAILURE, CMS.getLogMessage("POLICY_MISSING_KEY_1", "")); @@ -341,22 +343,21 @@ public abstract class APolicyRule implements IPolicyRule { md.update(rawKey); keyId = new KeyIdentifier(md.digest()); } catch (IOException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } catch (CertificateException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } catch (NoSuchAlgorithmException e) { - log(ILogger.LL_FAILURE, - CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); + log(ILogger.LL_FAILURE, + CMS.getLogMessage("POLICY_ERROR_SUBJECT_KEY_ID_1", NAME)); throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_SUBJECT_KEY_ID_ERROR", NAME)); } return keyId; } } - |