Commit 306f03e2 authored by cdanger's avatar cdanger

Fixed code-style issues

parent de896e21
......@@ -81,6 +81,8 @@ public final class BaseDecisionResult implements DecisionResult
// initialized non-null
private final List<JAXBElement<IdReferenceType>> applicablePolicyIdList;
private transient volatile int hashCode = 0;
private BaseDecisionResult(DecisionType decision, DecisionType extendedIndeterminate, Status status, PepActions pepActions, List<JAXBElement<IdReferenceType>> policyIdentifierList)
{
if (decision == null)
......@@ -175,8 +177,6 @@ public final class BaseDecisionResult implements DecisionResult
this(algResult.getDecision(), algResult.getExtendedIndeterminate(), algResult.getStatus(), pepActions, applicablePolicyIdList);
}
private transient volatile int hashCode = 0;
/** {@inheritDoc} */
@Override
public int hashCode()
......
......@@ -87,6 +87,8 @@ public final class BasePepActions implements PepActions
private final List<Obligation> obligationList;
private final List<Advice> adviceList;
private transient volatile int hashCode = 0;
/**
* Instantiates PEP action set from obligations/advice
*
......@@ -123,8 +125,6 @@ public final class BasePepActions implements PepActions
return Collections.unmodifiableList(adviceList);
}
private transient volatile int hashCode = 0;
/** {@inheritDoc} */
@Override
public int hashCode()
......
......@@ -72,6 +72,50 @@ import org.slf4j.LoggerFactory;
*/
public class PDPImpl implements CloseablePDP
{
private static final IllegalArgumentException ILLEGAL_ARGUMENT_EXCEPTION = new IllegalArgumentException("No input Individual Decision Request");
// the logger we'll use for all messages
private static final Logger LOGGER = LoggerFactory.getLogger(PDPImpl.class);
/**
* Indeterminate response iff CombinedDecision element not supported because the request parser does not support any scheme from MultipleDecisionProfile section 2.
*/
private static final Response UNSUPPORTED_COMBINED_DECISION_RESPONSE = new Response(Collections.<Result> singletonList(new Result(DecisionType.INDETERMINATE, new StatusHelper(
StatusHelper.STATUS_SYNTAX_ERROR, "Unsupported feature: CombinedDecision='true'"), null, null, null, null)));
private static final AttributeGUID ENVIRONMENT_CURRENT_TIME_ATTRIBUTE_GUID = new AttributeGUID(XACMLCategory.XACML_3_0_ENVIRONMENT_CATEGORY_ENVIRONMENT.value(), null,
XACMLAttributeId.XACML_1_0_ENVIRONMENT_CURRENT_TIME.value());
private static final AttributeGUID ENVIRONMENT_CURRENT_DATE_ATTRIBUTE_GUID = new AttributeGUID(XACMLCategory.XACML_3_0_ENVIRONMENT_CATEGORY_ENVIRONMENT.value(), null,
XACMLAttributeId.XACML_1_0_ENVIRONMENT_CURRENT_DATE.value());
private static final AttributeGUID ENVIRONMENT_CURRENT_DATETIME_ATTRIBUTE_GUID = new AttributeGUID(XACMLCategory.XACML_3_0_ENVIRONMENT_CATEGORY_ENVIRONMENT.value(), null,
XACMLAttributeId.XACML_1_0_ENVIRONMENT_CURRENT_DATETIME.value());
private static final DecisionResultFilter DEFAULT_RESULT_FILTER = new DecisionResultFilter()
{
private static final String ID = "urn:ow2:authzforce:feature:pdp:result-filter:default";
@Override
public String getId()
{
return ID;
}
@Override
public List<Result> filter(List<Result> results)
{
return results;
}
@Override
public boolean supportsMultipleDecisionCombining()
{
return false;
}
};
private static class NonCachingIndividualDecisionRequestEvaluator extends IndividualDecisionRequestEvaluator
{
private NonCachingIndividualDecisionRequestEvaluator(RootPolicyEvaluator rootPolicyEvaluator)
......@@ -171,50 +215,6 @@ public class PDPImpl implements CloseablePDP
}
}
private static final IllegalArgumentException ILLEGAL_ARGUMENT_EXCEPTION = new IllegalArgumentException("No input Individual Decision Request");
// the logger we'll use for all messages
private static final Logger LOGGER = LoggerFactory.getLogger(PDPImpl.class);
/**
* Indeterminate response iff CombinedDecision element not supported because the request parser does not support any scheme from MultipleDecisionProfile section 2.
*/
private static final Response UNSUPPORTED_COMBINED_DECISION_RESPONSE = new Response(Collections.<Result> singletonList(new Result(DecisionType.INDETERMINATE, new StatusHelper(
StatusHelper.STATUS_SYNTAX_ERROR, "Unsupported feature: CombinedDecision='true'"), null, null, null, null)));
private static final AttributeGUID ENVIRONMENT_CURRENT_TIME_ATTRIBUTE_GUID = new AttributeGUID(XACMLCategory.XACML_3_0_ENVIRONMENT_CATEGORY_ENVIRONMENT.value(), null,
XACMLAttributeId.XACML_1_0_ENVIRONMENT_CURRENT_TIME.value());
private static final AttributeGUID ENVIRONMENT_CURRENT_DATE_ATTRIBUTE_GUID = new AttributeGUID(XACMLCategory.XACML_3_0_ENVIRONMENT_CATEGORY_ENVIRONMENT.value(), null,
XACMLAttributeId.XACML_1_0_ENVIRONMENT_CURRENT_DATE.value());
private static final AttributeGUID ENVIRONMENT_CURRENT_DATETIME_ATTRIBUTE_GUID = new AttributeGUID(XACMLCategory.XACML_3_0_ENVIRONMENT_CATEGORY_ENVIRONMENT.value(), null,
XACMLAttributeId.XACML_1_0_ENVIRONMENT_CURRENT_DATETIME.value());
private static final DecisionResultFilter DEFAULT_RESULT_FILTER = new DecisionResultFilter()
{
private static final String ID = "urn:ow2:authzforce:feature:pdp:result-filter:default";
@Override
public String getId()
{
return ID;
}
@Override
public List<Result> filter(List<Result> results)
{
return results;
}
@Override
public boolean supportsMultipleDecisionCombining()
{
return false;
}
};
private final RootPolicyEvaluator rootPolicyEvaluator;
private final DecisionCache decisionCache;
private final RequestFilter reqFilter;
......
......@@ -95,14 +95,14 @@ public final class DenyUnlessPermitAlg extends BaseCombiningAlg<Decidable>
return new Evaluator(combinedElements);
}
/**
* Supported algorithms
*/
public static final CombiningAlgSet SET = new CombiningAlgSet(new DenyUnlessPermitAlg(SUPPORTED_IDENTIFIERS[0]), new DenyUnlessPermitAlg(SUPPORTED_IDENTIFIERS[1]));
private DenyUnlessPermitAlg(String algId)
{
super(algId, Decidable.class);
}
/**
* Supported algorithms
*/
public static final CombiningAlgSet SET = new CombiningAlgSet(new DenyUnlessPermitAlg(SUPPORTED_IDENTIFIERS[0]), new DenyUnlessPermitAlg(SUPPORTED_IDENTIFIERS[1]));
}
......@@ -38,6 +38,12 @@ import org.ow2.authzforce.core.pdp.impl.BaseDecisionResult;
*/
public final class FirstApplicableAlg extends BaseCombiningAlg<Decidable>
{
/**
* The standard URIs used to identify this algorithm
*/
private static final String[] SUPPORTED_IDENTIFIERS = { "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:first-applicable",
"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" };
private static class Evaluator implements CombiningAlg.Evaluator
{
......@@ -80,20 +86,14 @@ public final class FirstApplicableAlg extends BaseCombiningAlg<Decidable>
return new Evaluator(combinedElements);
}
/**
* The standard URIs used to identify this algorithm
*/
private static final String[] SUPPORTED_IDENTIFIERS = { "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:first-applicable",
"urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" };
private FirstApplicableAlg(String algId)
{
super(algId, Decidable.class);
}
/**
* Supported algorithms
*/
public static final CombiningAlgSet SET = new CombiningAlgSet(new FirstApplicableAlg(SUPPORTED_IDENTIFIERS[0]), new FirstApplicableAlg(SUPPORTED_IDENTIFIERS[1]));
private FirstApplicableAlg(String algId)
{
super(algId, Decidable.class);
}
}
......@@ -39,6 +39,11 @@ import org.slf4j.LoggerFactory;
*/
public class OnlyOneApplicableAlg extends BaseCombiningAlg<PolicyEvaluator>
{
/**
* The standard URI used to identify this algorithm
*/
public static final String ID = "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable";
private static class Evaluator implements CombiningAlg.Evaluator
{
private static final Logger LOGGER = LoggerFactory.getLogger(Evaluator.class);
......@@ -105,11 +110,6 @@ public class OnlyOneApplicableAlg extends BaseCombiningAlg<PolicyEvaluator>
return new Evaluator(combinedElements);
}
/**
* The standard URI used to identify this algorithm
*/
public static final String ID = "urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable";
/**
* Standard constructor.
*/
......
......@@ -174,6 +174,11 @@ public final class PermitOverridesAlg extends BaseCombiningAlg<Decidable>
return new Evaluator(combinedElements);
}
private PermitOverridesAlg(String algId)
{
super(algId, Decidable.class);
}
/**
* Supported algorithms
*/
......@@ -188,9 +193,4 @@ public final class PermitOverridesAlg extends BaseCombiningAlg<Decidable>
SET = new CombiningAlgSet(algSet);
}
private PermitOverridesAlg(String algId)
{
super(algId, Decidable.class);
}
}
......@@ -41,6 +41,13 @@ import org.ow2.authzforce.core.pdp.impl.BaseDecisionResult;
*/
public final class PermitUnlessDenyAlg extends BaseCombiningAlg<Decidable>
{
/**
* The standard URN used to identify this algorithm
*/
private static final String[] SUPPORTED_IDENTIFIERS = { "urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny",
"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny" };
private static class Evaluator implements CombiningAlg.Evaluator
{
......@@ -91,11 +98,10 @@ public final class PermitUnlessDenyAlg extends BaseCombiningAlg<Decidable>
return new Evaluator(combinedElements);
}
/**
* The standard URN used to identify this algorithm
*/
private static final String[] SUPPORTED_IDENTIFIERS = { "urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny",
"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny" };
private PermitUnlessDenyAlg(String algId)
{
super(algId, Decidable.class);
}
/**
* Supported algorithms
......@@ -112,9 +118,4 @@ public final class PermitUnlessDenyAlg extends BaseCombiningAlg<Decidable>
SET = new CombiningAlgSet(algSet);
}
private PermitUnlessDenyAlg(String algId)
{
super(algId, Decidable.class);
}
}
......@@ -38,8 +38,7 @@ import org.ow2.authzforce.core.pdp.api.value.Datatype;
* AttributeDesignator
*
* <p>
* WARNING: java.net.URI cannot be used here for XACML datatype/category/ID, because not equivalent to XML schema anyURI type. Spaces are allowed in XSD anyURI
* [1], not in java.net.URI.
* WARNING: java.net.URI cannot be used here for XACML datatype/category/ID, because not equivalent to XML schema anyURI type. Spaces are allowed in XSD anyURI [1], not in java.net.URI.
* </p>
* <p>
* [1] http://www.w3.org/TR/xmlschema-2/#anyURI That's why we use String instead.
......@@ -64,23 +63,22 @@ public class AttributeDesignator<AV extends AttributeValue> extends AttributeDes
private static final IllegalArgumentException NULL_DATATYPE_EXCEPTION = new IllegalArgumentException("Undefined attribute designator datatype");
private static final IllegalArgumentException NULL_ATTRIBUTE_ID_EXCEPTION = new IllegalArgumentException("Undefined attribute designator AttribtueId");
private static final IllegalArgumentException NULL_ATTRIBUTE_Provider_EXCEPTION = new IllegalArgumentException("Undefined attribute Provider");
private static final UnsupportedOperationException UNSUPPORTED_DATATYPE_SET_OPERATION_EXCEPTION = new UnsupportedOperationException("DataType field is read-only");
private static final UnsupportedOperationException UNSUPPORTED_ATTRIBUTE_ID_SET_OPERATION_EXCEPTION = new UnsupportedOperationException("AttributeId field is read-only");
private static final UnsupportedOperationException UNSUPPORTED_CATEGORY_SET_OPERATION_EXCEPTION = new UnsupportedOperationException("Category field is read-only");
private static final UnsupportedOperationException UNSUPPORTED_ISSUER_SET_OPERATION_EXCEPTION = new UnsupportedOperationException("Issuer field is read-only");
private final transient String missingAttributeMessage;
private final AttributeGUID attrGUID;
private final transient AttributeGUID attrGUID;
private final transient AttributeProvider attrProvider;
private final transient BagDatatype<AV> returnType;
private final transient IndeterminateEvaluationException missingAttributeForUnknownReasonException;
private final transient IndeterminateEvaluationException missingAttributeBecauseNullContextException;
private final Datatype<AV> attributeType;
private final transient Datatype<AV> attributeType;
private static final UnsupportedOperationException UNSUPPORTED_DATATYPE_SET_OPERATION_EXCEPTION = new UnsupportedOperationException(
"DataType field is read-only");
private static final UnsupportedOperationException UNSUPPORTED_ATTRIBUTE_ID_SET_OPERATION_EXCEPTION = new UnsupportedOperationException(
"AttributeId field is read-only");
private static final UnsupportedOperationException UNSUPPORTED_CATEGORY_SET_OPERATION_EXCEPTION = new UnsupportedOperationException(
"Category field is read-only");
private static final UnsupportedOperationException UNSUPPORTED_ISSUER_SET_OPERATION_EXCEPTION = new UnsupportedOperationException(
"Issuer field is read-only");
// lazy initialization
private transient volatile String toString = null;
private transient volatile int hashCode = 0;
/*
* (non-Javadoc)
......@@ -197,11 +195,9 @@ public class AttributeDesignator<AV extends AttributeValue> extends AttributeDes
// error messages/exceptions
this.missingAttributeMessage = this + " not found in context";
this.missingAttributeForUnknownReasonException = new IndeterminateEvaluationException(StatusHelper.STATUS_MISSING_ATTRIBUTE, missingAttributeMessage
+ " for unknown reason");
this.missingAttributeBecauseNullContextException = new IndeterminateEvaluationException(
"Missing Attributes/Attribute for evaluation of AttributeDesignator '" + this.attrGUID + "' because request context undefined",
StatusHelper.STATUS_MISSING_ATTRIBUTE);
this.missingAttributeForUnknownReasonException = new IndeterminateEvaluationException(StatusHelper.STATUS_MISSING_ATTRIBUTE, missingAttributeMessage + " for unknown reason");
this.missingAttributeBecauseNullContextException = new IndeterminateEvaluationException("Missing Attributes/Attribute for evaluation of AttributeDesignator '" + this.attrGUID
+ "' because request context undefined", StatusHelper.STATUS_MISSING_ATTRIBUTE);
}
/**
......@@ -247,10 +243,6 @@ public class AttributeDesignator<AV extends AttributeValue> extends AttributeDes
return JaxbXACMLUtils.XACML_3_0_OBJECT_FACTORY.createAttributeDesignator(this);
}
// lazy initialization
private transient volatile String toString = null;
private transient volatile int hashCode = 0;
/*
* (non-Javadoc)
*
......@@ -262,8 +254,7 @@ public class AttributeDesignator<AV extends AttributeValue> extends AttributeDes
{
if (toString == null)
{
toString = "AttributeDesignator [category=" + category + ", attributeId=" + attributeId + ", dataType=" + dataType + ", issuer=" + issuer
+ ", mustBePresent=" + mustBePresent + "]";
toString = "AttributeDesignator [category=" + category + ", attributeId=" + attributeId + ", dataType=" + dataType + ", issuer=" + issuer + ", mustBePresent=" + mustBePresent + "]";
}
return toString;
......
......@@ -46,6 +46,11 @@ import org.ow2.authzforce.core.pdp.api.value.StandardDatatypes;
*/
public final class LogicalOrFunction extends SingleParameterTypedFirstOrderFunction<BooleanValue, BooleanValue>
{
/**
* XACML standard identifier for the "or" logical function
*/
public static final String NAME_OR = XACML_NS_1_0 + "or";
private static final class Call extends FirstOrderFunctionCall<BooleanValue>
{
private static final String INDETERMINATE_ARG_MESSAGE_PREFIX = "Function " + NAME_OR + ": Indeterminate arg #";
......@@ -133,11 +138,6 @@ public final class LogicalOrFunction extends SingleParameterTypedFirstOrderFunct
}
}
/**
* XACML standard identifier for the "or" logical function
*/
public static final String NAME_OR = XACML_NS_1_0 + "or";
private LogicalOrFunction()
{
super(NAME_OR, StandardDatatypes.BOOLEAN_FACTORY.getDatatype(), true, Arrays.asList(StandardDatatypes.BOOLEAN_FACTORY.getDatatype()));
......
......@@ -1107,6 +1107,7 @@ public final class PolicyEvaluators
private static final class DynamicPolicyRefEvaluator extends PolicyRefEvaluator
{
private static final Logger LOGGER = LoggerFactory.getLogger(DynamicPolicyRefEvaluator.class);
private static final class RefResolvedResult
{
......@@ -1132,8 +1133,6 @@ public final class PolicyEvaluators
}
}
private static final Logger LOGGER = LoggerFactory.getLogger(DynamicPolicyRefEvaluator.class);
// this policyProvider to use in finding the referenced policy
private final RefPolicyProvider refPolicyProvider;
......
......@@ -28,9 +28,7 @@ import org.ow2.authzforce.core.pdp.api.policy.PolicyVersion;
import org.ow2.authzforce.core.pdp.api.policy.TopLevelPolicyElementType;
/**
* View of all statically resolved policies applicable by the PDP or specific
* PolicySet evaluator (root policy as well as policies referenced directly or
* indirectly from the root one)
* View of all statically resolved policies applicable by the PDP or specific PolicySet evaluator (root policy as well as policies referenced directly or indirectly from the root one)
*
*
* @version $Id: $
......@@ -39,6 +37,7 @@ public final class StaticApplicablePolicyView implements Iterable<Entry<String,
{
private static final IllegalArgumentException ILLEGAL_ARGUMENTS_EXCEPTION = new IllegalArgumentException("Null root policy ID/version/extra metadata");
private static final UnsupportedOperationException UNSUPPORTED_REMOVE_OPERATION_EXCEPTION = new UnsupportedOperationException();
private final Entry<String, PolicyVersion> rootPolicyEntry;
private final TopLevelPolicyElementType rootPolicyType;
private final ExtraPolicyMetadata extraRootPolicyMetadata;
......@@ -46,15 +45,15 @@ public final class StaticApplicablePolicyView implements Iterable<Entry<String,
private final class PolicySetIteratorImpl implements Iterator<Entry<String, PolicyVersion>>
{
private Iterator<Entry<String, PolicyVersion>> refPolicySetIterator;
private final Iterator<Entry<String, PolicyVersion>> refPolicySetIterator;
private boolean isFirst = true;
private PolicySetIteratorImpl()
{
refPolicySetIterator = extraRootPolicyMetadata.getRefPolicySets().entrySet().iterator();
}
private boolean isFirst = true;
@Override
public boolean hasNext()
{
......@@ -84,8 +83,7 @@ public final class StaticApplicablePolicyView implements Iterable<Entry<String,
}
/**
* Creates view of applicable policies from the root policy metadata and map
* of referenced policies. All fields made immutable by this constructor.
* Creates view of applicable policies from the root policy metadata and map of referenced policies. All fields made immutable by this constructor.
*
* @param rootPolicyType
* root policy type
......@@ -137,10 +135,8 @@ public final class StaticApplicablePolicyView implements Iterable<Entry<String,
}
/**
* If {@link #rootPolicyType()} returns
* {@link TopLevelPolicyElementType#POLICY}, it is the only item in the
* iteration (since there is no child Policy(Set)). Else this iterates over
* policies referenced directly or indirectly from the root policySet.
* If {@link #rootPolicyType()} returns {@link TopLevelPolicyElementType#POLICY}, it is the only item in the iteration (since there is no child Policy(Set)). Else this iterates over policies
* referenced directly or indirectly from the root policySet.
*
* @return iterator over applicable Policies
*/
......@@ -150,11 +146,8 @@ public final class StaticApplicablePolicyView implements Iterable<Entry<String,
}
/**
* If {@link #rootPolicyType()} returns
* {@link TopLevelPolicyElementType#POLICY}, there is no item in this
* iteration, else the root policy(set) entry is always the first item in
* the iteration, then the policies referenced directly or indirectly from
* the root policySet.
* If {@link #rootPolicyType()} returns {@link TopLevelPolicyElementType#POLICY}, there is no item in this iteration, else the root policy(set) entry is always the first item in the iteration,
* then the policies referenced directly or indirectly from the root policySet.
*
* @return iterator over applicable PolicySets
*/
......@@ -184,7 +177,8 @@ public final class StaticApplicablePolicyView implements Iterable<Entry<String,
*/
public PolicyVersion getPolicySet(String policyId)
{
return rootPolicyType == TopLevelPolicyElementType.POLICY_SET && rootPolicyEntry.getKey().equals(policyId) ? rootPolicyEntry.getValue() : extraRootPolicyMetadata.getRefPolicySets().get(policyId);
return rootPolicyType == TopLevelPolicyElementType.POLICY_SET && rootPolicyEntry.getKey().equals(policyId) ? rootPolicyEntry.getValue() : extraRootPolicyMetadata.getRefPolicySets().get(
policyId);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment