diff options
author | Endi Sukma Dewata <edewata@redhat.com> | 2012-04-05 15:08:18 -0500 |
---|---|---|
committer | Endi Sukma Dewata <edewata@redhat.com> | 2012-04-09 10:22:03 -0500 |
commit | 3f24e55923fc986af4c6a08b2b8d45704a905627 (patch) | |
tree | 716415853b5676b801f6707634305b59b9af8603 /base/common/src/com/netscape/cmscore/policy | |
parent | 7c7b9d023cd466c1771068badc020dab36beb553 (diff) | |
download | pki-3f24e55923fc986af4c6a08b2b8d45704a905627.tar.gz pki-3f24e55923fc986af4c6a08b2b8d45704a905627.tar.xz pki-3f24e55923fc986af4c6a08b2b8d45704a905627.zip |
Removed unnecessary type casts.
Unnecessary type casts have been removed using Eclipse Quick Fix.
Ticket #134
Diffstat (limited to 'base/common/src/com/netscape/cmscore/policy')
5 files changed, 49 insertions, 64 deletions
diff --git a/base/common/src/com/netscape/cmscore/policy/GeneralNameUtil.java b/base/common/src/com/netscape/cmscore/policy/GeneralNameUtil.java index a3f64915d..8d8c05bc6 100644 --- a/base/common/src/com/netscape/cmscore/policy/GeneralNameUtil.java +++ b/base/common/src/com/netscape/cmscore/policy/GeneralNameUtil.java @@ -311,7 +311,7 @@ public class GeneralNameUtil implements IGeneralNameUtil { } public GeneralNameConfig[] getGenNameConfig() { - return (GeneralNameConfig[]) mGenNameConfigs.clone(); + return mGenNameConfigs.clone(); } public int getNumGeneralNames() { diff --git a/base/common/src/com/netscape/cmscore/policy/GenericPolicyProcessor.java b/base/common/src/com/netscape/cmscore/policy/GenericPolicyProcessor.java index 823c416dc..baf86da31 100644 --- a/base/common/src/com/netscape/cmscore/policy/GenericPolicyProcessor.java +++ b/base/common/src/com/netscape/cmscore/policy/GenericPolicyProcessor.java @@ -210,7 +210,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { Enumeration<String> mImpls = c.getSubStoreNames(); while (mImpls.hasMoreElements()) { - String id = (String) mImpls.nextElement(); + String id = mImpls.nextElement(); // The implementation id should be unique if (mImplTable.containsKey(id)) @@ -270,7 +270,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { IConfigStore ruleStore = config.getSubStore(PROP_RULE); for (int i = 0; i < numPolicies; i++) { - String instanceName = (String) mPolicyOrder.elementAt(i); + String instanceName = mPolicyOrder.elementAt(i); // The instance id should be unique if (mInstanceTable.containsKey(instanceName)) @@ -302,8 +302,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { } // Make an instance of the specified policy. - RegisteredPolicy regPolicy = - (RegisteredPolicy) mImplTable.get(implName); + RegisteredPolicy regPolicy = mImplTable.get(implName); if (regPolicy == null) { String[] params = { implName, instanceName }; @@ -318,7 +317,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { rule = (IPolicyRule) Class.forName(classpath).newInstance(); if (rule instanceof IPolicyRule) - ((IPolicyRule) rule).setInstanceName(instanceName); + rule.setInstanceName(instanceName); rule.init(this, c); } catch (Throwable e) { mAuthority.log(ILogger.LL_FAILURE, @@ -378,7 +377,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { */ public PolicyResult apply(IRequest req) { IPolicySet rules = null; - String op = (String) req.getRequestType(); + String op = req.getRequestType(); CMS.debug("GenericPolicyProcessor: apply begins"); if (op == null) { @@ -465,8 +464,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { try { while (enum1.hasMoreElements()) { - RegisteredPolicy regPolicy = - (RegisteredPolicy) enum1.nextElement(); + RegisteredPolicy regPolicy = enum1.nextElement(); // Make an Instance of it IPolicyRule ruleImpl = (IPolicyRule) @@ -488,11 +486,8 @@ public class GenericPolicyProcessor implements IPolicyProcessor { try { while (enum1.hasMoreElements()) { - RegisteredPolicy regPolicy = - (RegisteredPolicy) enum1.nextElement(); - + RegisteredPolicy regPolicy = enum1.nextElement(); impls.addElement(regPolicy.getId()); - } ret = impls.elements(); } catch (Exception e) { @@ -502,8 +497,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { } public IPolicyRule getPolicyImpl(String id) { - RegisteredPolicy regImpl = (RegisteredPolicy) - mImplTable.get(id); + RegisteredPolicy regImpl = mImplTable.get(id); if (regImpl == null) return null; @@ -535,8 +529,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { public void deletePolicyImpl(String id) throws EBaseException { // First check if the id is valid; - RegisteredPolicy regPolicy = - (RegisteredPolicy) mImplTable.get(id); + RegisteredPolicy regPolicy = mImplTable.get(id); if (regPolicy == null) throw new EPolicyException( @@ -547,7 +540,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { Enumeration<PolicyInstance> e = mInstanceTable.elements(); for (; e.hasMoreElements();) { - PolicyInstance inst = (PolicyInstance) e.nextElement(); + PolicyInstance inst = e.nextElement(); if (inst.isInstanceOf(id)) { instanceExist = true; @@ -636,8 +629,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { try { while (enum1.hasMoreElements()) { - PolicyInstance instance = - (PolicyInstance) mInstanceTable.get((String) enum1.nextElement()); + PolicyInstance instance = mInstanceTable.get(enum1.nextElement()); rules.addElement(instance.getRule()); @@ -668,15 +660,13 @@ public class GenericPolicyProcessor implements IPolicyProcessor { } public IPolicyRule getPolicyInstance(String id) { - PolicyInstance policyInstance = (PolicyInstance) - mInstanceTable.get(id); + PolicyInstance policyInstance = mInstanceTable.get(id); return (policyInstance == null) ? null : policyInstance.getRule(); } public Vector<String> getPolicyInstanceConfig(String id) { - PolicyInstance policyInstance = (PolicyInstance) - mInstanceTable.get(id); + PolicyInstance policyInstance = mInstanceTable.get(id); if (policyInstance == null) return null; @@ -702,8 +692,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { CMS.getUserMessage("CMS_POLICY_CANT_DELETE_PERSISTENT_POLICY", id)); // First check if the instance is present. - PolicyInstance instance = - (PolicyInstance) mInstanceTable.get(id); + PolicyInstance instance = mInstanceTable.get(id); if (instance == null) throw new EPolicyException( @@ -762,7 +751,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { throw new EPolicyException( CMS.getUserMessage("CMS_POLICY_DUPLICATE_INST_ID", id)); // There should be an implmentation for this rule. - String implName = (String) ht.get(IPolicyRule.PROP_IMPLNAME); + String implName = ht.get(IPolicyRule.PROP_IMPLNAME); // See if there is an implementation with this name. IPolicyRule rule = getPolicyImpl(implName); @@ -793,7 +782,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { rule.init(this, newStore); // Add the rule to the table. - String enabledStr = (String) ht.get(IPolicyRule.PROP_ENABLE); + String enabledStr = ht.get(IPolicyRule.PROP_ENABLE); boolean active = false; if (enabledStr == null || enabledStr.trim().length() == 0 || @@ -801,7 +790,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { active = true; // Set the predicate if any present on the rule. - String predicate = ((String) ht.get(IPolicyRule.PROP_PREDICATE)).trim(); + String predicate = ht.get(IPolicyRule.PROP_PREDICATE).trim(); IExpression exp = null; if (predicate.trim().length() > 0) @@ -837,8 +826,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { public void modifyPolicyInstance(String id, Hashtable<String, String> ht) throws EBaseException { // The instance id should be there already - PolicyInstance policyInstance = (PolicyInstance) - mInstanceTable.get(id); + PolicyInstance policyInstance = mInstanceTable.get(id); if (policyInstance == null) throw new EPolicyException( @@ -846,7 +834,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { IPolicyRule rule = policyInstance.getRule(); // The impl id shouldn't change - String implId = (String) ht.get(IPolicyRule.PROP_IMPLNAME); + String implId = ht.get(IPolicyRule.PROP_IMPLNAME); if (!implId.equals(policyInstance.getImplId())) throw new EPolicyException( @@ -868,7 +856,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { IConfigStore newStore = new PropConfigStore(id); // See if the rule is disabled. - String enabledStr = (String) ht.get(IPolicyRule.PROP_ENABLE); + String enabledStr = ht.get(IPolicyRule.PROP_ENABLE); boolean active = false; if (enabledStr == null || enabledStr.trim().length() == 0 || @@ -876,7 +864,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { active = true; // Set the predicate expression. - String predicate = ((String) ht.get(IPolicyRule.PROP_PREDICATE)).trim(); + String predicate = ht.get(IPolicyRule.PROP_PREDICATE).trim(); IExpression exp = null; if (predicate.trim().length() > 0) @@ -890,8 +878,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { CMS.getUserMessage("CMS_POLICY_PERSISTENT_RULE_INACTIVE", id)); } - IExpression defPred = (IExpression) - mUndeletablePolicies.get(id); + IExpression defPred = mUndeletablePolicies.get(id); if (defPred == SimpleExpression.NULL_EXPRESSION) defPred = null; @@ -922,16 +909,16 @@ public class GenericPolicyProcessor implements IPolicyProcessor { // put old config store parameters first. for (Enumeration<String> oldkeys = oldStore.keys(); oldkeys.hasMoreElements();) { - String k = (String) oldkeys.nextElement(); - String v = (String) oldStore.getString(k); + String k = oldkeys.nextElement(); + String v = oldStore.getString(k); newStore.put(k, v); } // put modified params. for (Enumeration<String> newkeys = ht.keys(); newkeys.hasMoreElements();) { - String k = (String) newkeys.nextElement(); - String v = (String) ht.get(k); + String k = newkeys.nextElement(); + String v = ht.get(k); Debug.trace("newstore key " + k + "=" + v); if (v != null) { @@ -969,13 +956,13 @@ public class GenericPolicyProcessor implements IPolicyProcessor { // Store the changes in the file. try { for (Enumeration<String> e = newStore.keys(); e.hasMoreElements();) { - String key = (String) e.nextElement(); + String key = e.nextElement(); if (key != null) { Debug.trace( "oldstore.put(" + key + "," + - (String) newStore.getString(key) + ")"); - oldStore.put(key, (String) newStore.getString(key)); + newStore.getString(key) + ")"); + oldStore.put(key, newStore.getString(key)); } } mGlobalStore.commit(true); @@ -1078,9 +1065,8 @@ public class GenericPolicyProcessor implements IPolicyProcessor { // add rules specified in the new order. for (Enumeration<String> enum1 = policyOrder.elements(); enum1.hasMoreElements();) { - String instanceName = (String) enum1.nextElement(); - PolicyInstance pInstance = (PolicyInstance) - mInstanceTable.get(instanceName); + String instanceName = enum1.nextElement(); + PolicyInstance pInstance = mInstanceTable.get(instanceName); if (!pInstance.isActive()) continue; @@ -1141,7 +1127,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { StringBuffer sb = new StringBuffer(); for (Enumeration<String> e = rules.elements(); e.hasMoreElements();) { - sb.append((String) e.nextElement()); + sb.append(e.nextElement()); sb.append(","); } if (sb.length() > 0) @@ -1379,7 +1365,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { // predicate is set. mUndeletablePolicies = new Hashtable<String, IExpression>(); for (Enumeration<String> e = rules.elements(); e.hasMoreElements();) { - String urn = (String) e.nextElement(); + String urn = e.nextElement(); // See if there is predicate in the file String pred = mConfig.getString(PROP_UNDELETABLE_POLICIES + @@ -1426,10 +1412,10 @@ public class GenericPolicyProcessor implements IPolicyProcessor { // the policy is present, is not disabled and its predicate // is not tampered with. for (Enumeration<String> e = mUndeletablePolicies.keys(); e.hasMoreElements();) { - String urn = (String) e.nextElement(); + String urn = e.nextElement(); // See if the rule is in the instance table. - PolicyInstance inst = (PolicyInstance) mInstanceTable.get(urn); + PolicyInstance inst = mInstanceTable.get(urn); if (inst == null) throw new EPolicyException( @@ -1441,8 +1427,7 @@ public class GenericPolicyProcessor implements IPolicyProcessor { CMS.getUserMessage("CMS_POLICY_PERSISTENT_RULE_INACTIVE", urn)); // See if the predicated is misconfigured. - IExpression defPred = (IExpression) - mUndeletablePolicies.get(urn); + IExpression defPred = mUndeletablePolicies.get(urn); // We used SimpleExpression.NULL_EXPRESSION to indicate a null. if (defPred == SimpleExpression.NULL_EXPRESSION) diff --git a/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java b/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java index b40a50699..f6c01b041 100644 --- a/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java +++ b/base/common/src/com/netscape/cmscore/policy/PolicyPredicateParser.java @@ -128,11 +128,11 @@ public class PolicyPredicateParser { if (size == 0) return null; OrExpression orExp = new - OrExpression((IExpression) expSet.elementAt(0), null); + OrExpression(expSet.elementAt(0), null); for (int i = 1; i < size; i++) orExp = new OrExpression(orExp, - (IExpression) expSet.elementAt(i)); + expSet.elementAt(i)); return orExp; } @@ -174,12 +174,12 @@ public class PolicyPredicateParser { } int size = expVector.size(); - SimpleExpression exp1 = (SimpleExpression) expVector.elementAt(0); - SimpleExpression exp2 = (SimpleExpression) expVector.elementAt(1); + SimpleExpression exp1 = expVector.elementAt(0); + SimpleExpression exp2 = expVector.elementAt(1); AndExpression andExp = new AndExpression(exp1, exp2); for (int i = 2; i < size; i++) { - andExp = new AndExpression(andExp, (SimpleExpression) expVector.elementAt(i)); + andExp = new AndExpression(andExp, expVector.elementAt(i)); } return andExp; } diff --git a/base/common/src/com/netscape/cmscore/policy/PolicySet.java b/base/common/src/com/netscape/cmscore/policy/PolicySet.java index d824d2629..8e8d60046 100644 --- a/base/common/src/com/netscape/cmscore/policy/PolicySet.java +++ b/base/common/src/com/netscape/cmscore/policy/PolicySet.java @@ -131,7 +131,7 @@ public class PolicySet implements IPolicySet { if (index < 0) return null; - return (IPolicyRule) mRules.elementAt(index); + return mRules.elementAt(index); } /** @@ -167,8 +167,8 @@ public class PolicySet implements IPolicySet { int size = mRules.size(); for (int index = 0; index < size; index++) { - String name = (String) mRuleNames.elementAt(index); - IPolicyRule rule = (IPolicyRule) mRules.elementAt(index); + String name = mRuleNames.elementAt(index); + IPolicyRule rule = mRules.elementAt(index); IExpression exp = rule.getPredicate(); try { @@ -238,7 +238,7 @@ public class PolicySet implements IPolicySet { // treat as rejected to prevent request from going into // a weird state. request queue doesn't handle this case. rejected = true; - ((IPolicyRule) rule).setError( + rule.setError( req, CMS.getUserMessage("CMS_POLICY_UNEXPECTED_POLICY_ERROR", rule.getName(), ex.toString()), null); } @@ -265,7 +265,7 @@ public class PolicySet implements IPolicySet { int size = mRules.size(); for (int index = 0; index < size; index++) { - String ruleName = (String) mRuleNames.elementAt(index); + String ruleName = mRuleNames.elementAt(index); System.out.println("Rule Name: " + ruleName); System.out.println("Implementation: " + diff --git a/base/common/src/com/netscape/cmscore/policy/SimpleExpression.java b/base/common/src/com/netscape/cmscore/policy/SimpleExpression.java index cf6e44bb0..97b75fa4f 100644 --- a/base/common/src/com/netscape/cmscore/policy/SimpleExpression.java +++ b/base/common/src/com/netscape/cmscore/policy/SimpleExpression.java @@ -131,7 +131,7 @@ public class SimpleExpression implements IExpression { private boolean matchVector(Vector<?> value) throws EPolicyException { boolean result = false; - Enumeration<?> e = (Enumeration<?>) value.elements(); + Enumeration<?> e = value.elements(); for (; e.hasMoreElements();) { result = matchValue(e.nextElement()); @@ -146,7 +146,7 @@ public class SimpleExpression implements IExpression { boolean result = false; for (int i = 0; i < value.length; i++) { - result = matchValue((Object) value[i]); + result = matchValue(value[i]); if (result) break; } |