Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18114/com/sun/xacml/combine
Modified Files:
CombiningAlgorithm.java DenyOverridesPolicyAlg.java
DenyOverridesRuleAlg.java FirstApplicablePolicyAlg.java
FirstApplicableRuleAlg.java OnlyOneApplicablePolicyAlg.java
PermitOverridesPolicyAlg.java PermitOverridesRuleAlg.java
PolicyCombiningAlgorithm.java RuleCombiningAlgorithm.java
Added Files:
CombinerElement.java CombinerParameter.java
PolicyCombinerElement.java RuleCombinerElement.java
Log Message:
introduced support for combining algorithm parameters, a new XACML 2.0 feature
Index: CombiningAlgorithm.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/CombiningAlgorithm.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CombiningAlgorithm.java 17 Mar 2004 18:03:38 -0000 1.3
--- CombiningAlgorithm.java 7 Jan 2005 23:50:47 -0000 1.4
***************
*** 3,7 ****
* @(#)CombiningAlgorithm.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)CombiningAlgorithm.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 43,46 ****
--- 43,48 ----
import java.net.URI;
+ import java.util.ArrayList;
+ import java.util.Collections;
import java.util.List;
***************
*** 69,81 ****
/**
! * Combines the inputs based on the context to produce some unified
! * result. This is the one function of a combining algorithm.
*
* @param context the representation of the request
! * @param inputs the things to combine (policies or rules)
*
* @return a single unified result based on the combining logic
*/
! public abstract Result combine(EvaluationCtx context, List inputs);
/**
--- 71,88 ----
/**
! * Combines the results of the inputs based on the context to produce
! * some unified result. This is the one function of a combining algorithm.
*
* @param context the representation of the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s provided for general
! * use (for all pre-2.0 policies this must be empty)
! * @param inputs a <code>List</code> of <code>CombinerElements</code>s to
! * evaluate and combine
*
* @return a single unified result based on the combining logic
*/
! public abstract Result combine(EvaluationCtx context, List parameters,
! List inputs);
/**
Index: OnlyOneApplicablePolicyAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/OnlyOneApplicablePolicyAlg.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** OnlyOneApplicablePolicyAlg.java 23 Mar 2004 23:38:55 -0000 1.4
--- OnlyOneApplicablePolicyAlg.java 7 Jan 2005 23:50:47 -0000 1.5
***************
*** 3,7 ****
* @(#)OnlyOneApplicablePolicyAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)OnlyOneApplicablePolicyAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 99,113 ****
*
* @param context the context from the request
! * @param policies the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List policies) {
boolean atLeastOne = false;
AbstractPolicy selectedPolicy = null;
! Iterator it = policies.iterator();
while (it.hasNext()) {
! AbstractPolicy policy = (AbstractPolicy)(it.next());
// see if the policy matches the context
--- 99,117 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param policyElements the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List policyElements) {
boolean atLeastOne = false;
AbstractPolicy selectedPolicy = null;
! Iterator it = policyElements.iterator();
while (it.hasNext()) {
! AbstractPolicy policy =
! ((PolicyCombinerElement)(it.next())).getPolicy();
// see if the policy matches the context
Index: DenyOverridesPolicyAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/DenyOverridesPolicyAlg.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DenyOverridesPolicyAlg.java 23 Mar 2004 23:38:52 -0000 1.5
--- DenyOverridesPolicyAlg.java 7 Jan 2005 23:50:47 -0000 1.6
***************
*** 3,7 ****
* @(#)DenyOverridesPolicyAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)DenyOverridesPolicyAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 111,125 ****
*
* @param context the context from the request
! * @param policies the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List policies) {
boolean atLeastOnePermit = false;
Set permitObligations = new HashSet();
! Iterator it = policies.iterator();
while (it.hasNext()) {
! AbstractPolicy policy = (AbstractPolicy)(it.next());
// make sure that the policy matches the context
--- 111,129 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param policyElements the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List policyElements) {
boolean atLeastOnePermit = false;
Set permitObligations = new HashSet();
! Iterator it = policyElements.iterator();
while (it.hasNext()) {
! AbstractPolicy policy =
! ((PolicyCombinerElement)(it.next())).getPolicy();
// make sure that the policy matches the context
--- NEW FILE: RuleCombinerElement.java ---
/*
* @(#)RuleCombinerElement.java
*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
* AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use in
* the design, construction, operation or maintenance of any nuclear facility.
*/
package com.sun.xacml.combine;
import com.sun.xacml.Indenter;
import com.sun.xacml.Rule;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.List;
/**
* Specific version of <code>CombinerElement</code> used for rule combining.
*
* @since 2.0
* @author Seth Proctor
*/
public class RuleCombinerElement extends CombinerElement
{
/**
* Constructor that only takes a <code>Rule</code. No parameters are
* associated with this <code>Rule</code> when combining.
*
* @param rule a <code>Rule</code> to use in combining
*/
public RuleCombinerElement(Rule rule) {
super(rule);
}
/**
* Constructor that takes both the <code>Rule</code> to combine and its
* associated combiner parameters.
*
* @param rule a <code>Rule</code> to use in combining
* @param parameters a (possibly empty) non-null <code>List</code> of
* <code>CombinerParameter<code>s provided for general
* use (for all pre-2.0 policies this must be empty)
*/
public RuleCombinerElement(Rule rule, List parameters) {
super(rule, parameters);
}
/**
* Returns the <code>Rule</code> in this element.
*
* @return the element's <code>Rule</code>
*/
public Rule getRule() {
return (Rule)(getElement());
}
/**
* Encodes this element's <code>Rule</code> and parameters into their
* XML representation and writes this encoding to the given
* <code>OutputStream</code> with indentation.
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
public void encode(OutputStream output, Indenter indenter) {
Iterator it = getParameters().iterator();
if (it.hasNext()) {
PrintStream out = new PrintStream(output);
String indent = indenter.makeString();
out.println(indent + "<RuleCombinerParameters RuleIdRef=\"" +
getRule().getId() + "\">");
indenter.in();
while (it.hasNext()) {
CombinerParameter param = (CombinerParameter)(it.next());
param.encode(output, indenter);
}
out.println(indent + "</RuleCombinerParameters>");
indenter.out();
}
getRule().encode(output, indenter);
}
}
--- NEW FILE: CombinerParameter.java ---
/*
* @(#)CombinerParameter.java
*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
* AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use in
* the design, construction, operation or maintenance of any nuclear facility.
*/
package com.sun.xacml.combine;
import com.sun.xacml.Indenter;
import com.sun.xacml.ParsingException;
import com.sun.xacml.UnknownIdentifierException;
import com.sun.xacml.attr.AttributeFactory;
import com.sun.xacml.attr.AttributeValue;
import java.io.OutputStream;
import java.io.PrintStream;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* Represents a single named parameter to a combining algorithm. Parameters
* are only used by XACML 2.0 and later policies.
*
* @since 2.0
* @author Seth Proctor
*/
public class CombinerParameter
{
// the name of this parameter
private String name;
// the value of this parameter
private AttributeValue value;
/**
* Creates a new CombinerParameter.
*
* @param name the parameter's name
* @param value the parameter's value
*/
public CombinerParameter(String name, AttributeValue value) {
this.name = name;
this.value = value;
}
/**
* Returns a new instance of the <code>CombinerParameter</code> class
* based on a DOM node. The node must be the root of an XML
* CombinerParameterType.
*
* @param root the DOM root of a CombinerParameterType XML type
*
* @throws ParsingException if the CombinerParameterType is invalid
*/
public static CombinerParameter getInstance(Node root)
throws ParsingException
{
// get the name, which is a required attribute
String name = root.getAttributes().getNamedItem("ParameterName").
getNodeValue();
// get the attribute value, the only child of this element
AttributeFactory attrFactory = AttributeFactory.getInstance();
AttributeValue value = null;
try {
value = attrFactory.createValue(root.getFirstChild());
} catch (UnknownIdentifierException uie) {
throw new ParsingException("Unknown AttributeId", uie);
}
return new CombinerParameter(name, value);
}
/**
* Returns the name of this parameter.
*
* @return the name of this parameter
*/
public String getName() {
return name;
}
/**
* Returns the value provided by this parameter.
*
* @return the value provided by this parameter
*/
public AttributeValue getValue() {
return value;
}
/**
* Encodes this parameter into its XML representation and writes this
* encoding to the given <code>OutputStream</code> with indentation.
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
public void encode(OutputStream output, Indenter indenter) {
PrintStream out = new PrintStream(output);
String indent = indenter.makeString();
out.println(indent + "<CombinerParameter ParameterName=\"" +
getName() + "\">");
indenter.in();
getValue().encode(output, indenter);
out.println(indent + "</CombinerParameter>");
indenter.out();
}
}
Index: FirstApplicablePolicyAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/FirstApplicablePolicyAlg.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FirstApplicablePolicyAlg.java 23 Mar 2004 23:38:55 -0000 1.4
--- FirstApplicablePolicyAlg.java 7 Jan 2005 23:50:47 -0000 1.5
***************
*** 3,7 ****
* @(#)FirstApplicablePolicyAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)FirstApplicablePolicyAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 98,110 ****
*
* @param context the context from the request
! * @param policies the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List policies) {
! Iterator it = policies.iterator();
while (it.hasNext()) {
! AbstractPolicy policy = (AbstractPolicy)(it.next());
// make sure that the policy matches the context
--- 98,114 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param policyElements the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List policyElements) {
! Iterator it = policyElements.iterator();
while (it.hasNext()) {
! AbstractPolicy policy =
! ((PolicyCombinerElement)(it.next())).getPolicy();
// make sure that the policy matches the context
--- NEW FILE: CombinerElement.java ---
/*
* @(#)CombinerElement.java
*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
* AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use in
* the design, construction, operation or maintenance of any nuclear facility.
*/
package com.sun.xacml.combine;
import com.sun.xacml.Indenter;
import com.sun.xacml.PolicyTreeElement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.io.OutputStream;
/**
* Represents one input (a Rule, Policy, PolicySet, or reference) to a
* combining algorithm and combiner parameters associated with that input.
*
* @since 2.0
* @author Seth Proctor
*/
public abstract class CombinerElement
{
// the element to be combined
private PolicyTreeElement element;
// the parameters used with this element
private List parameters;
/**
* Constructor that only takes an element. No parameters are associated
* with this element when combining.
*
* @param element a <code>PolicyTreeElement</code> to use in combining
*/
public CombinerElement(PolicyTreeElement element) {
this(element, null);
}
/**
* Constructor that takes both the element to combine and its associated
* combiner parameters.
*
* @param element a <code>PolicyTreeElement</code> to use in combining
* @param parameters a (possibly empty) non-null <code>List</code> of
* <code>CombinerParameter<code>s provided for general
* use (for all pre-2.0 policies this must be empty)
*/
public CombinerElement(PolicyTreeElement element, List parameters) {
this.element = element;
if (parameters == null)
this.parameters = Collections.unmodifiableList(new ArrayList());
else
this.parameters = Collections.
unmodifiableList(new ArrayList(parameters));
}
/**
* Returns the <code>PolicyTreeElement</code> in this element.
*
* @return the <code>PolicyTreeElement</code>
*/
public PolicyTreeElement getElement() {
return element;
}
/**
* Returns the <code>CombinerParameter</code>s associated with this
* element.
*
* @return a <code>List</code> of <code>CombinerParameter</code>s
*/
public List getParameters() {
return parameters;
}
/**
* Encodes the element and parameters in this <code>CombinerElement</code>
* into their XML representation and writes this encoding to the given
* <code>OutputStream</code> with indentation.
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
public abstract void encode(OutputStream output, Indenter indenter);
}
Index: FirstApplicableRuleAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/FirstApplicableRuleAlg.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** FirstApplicableRuleAlg.java 23 Mar 2004 23:38:55 -0000 1.4
--- FirstApplicableRuleAlg.java 7 Jan 2005 23:50:47 -0000 1.5
***************
*** 3,7 ****
* @(#)FirstApplicableRuleAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)FirstApplicableRuleAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 97,109 ****
*
* @param context the context from the request
! * @param rules the rules to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List rules) {
! Iterator it = rules.iterator();
while (it.hasNext()) {
! Rule rule = (Rule)(it.next());
Result result = rule.evaluate(context);
int value = result.getDecision();
--- 97,112 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param ruleElements the rules to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List ruleElements) {
! Iterator it = ruleElements.iterator();
while (it.hasNext()) {
! Rule rule = ((RuleCombinerElement)(it.next())).getRule();
Result result = rule.evaluate(context);
int value = result.getDecision();
Index: PermitOverridesRuleAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PermitOverridesRuleAlg.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PermitOverridesRuleAlg.java 23 Mar 2004 23:38:55 -0000 1.5
--- PermitOverridesRuleAlg.java 7 Jan 2005 23:50:47 -0000 1.6
***************
*** 3,7 ****
* @(#)PermitOverridesRuleAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)PermitOverridesRuleAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 108,124 ****
*
* @param context the context from the request
! * @param rules the rules to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List rules) {
boolean atLeastOneError = false;
boolean potentialPermit = false;
boolean atLeastOneDeny = false;
Result firstIndeterminateResult = null;
! Iterator it = rules.iterator();
while (it.hasNext()) {
! Rule rule = (Rule)(it.next());
Result result = rule.evaluate(context);
int value = result.getDecision();
--- 108,127 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param ruleElements the rules to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List ruleElements) {
boolean atLeastOneError = false;
boolean potentialPermit = false;
boolean atLeastOneDeny = false;
Result firstIndeterminateResult = null;
! Iterator it = ruleElements.iterator();
while (it.hasNext()) {
! Rule rule = ((RuleCombinerElement)(it.next())).getRule();
Result result = rule.evaluate(context);
int value = result.getDecision();
Index: DenyOverridesRuleAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/DenyOverridesRuleAlg.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DenyOverridesRuleAlg.java 23 Mar 2004 23:38:55 -0000 1.5
--- DenyOverridesRuleAlg.java 7 Jan 2005 23:50:47 -0000 1.6
***************
*** 3,7 ****
* @(#)DenyOverridesRuleAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)DenyOverridesRuleAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 108,124 ****
*
* @param context the context from the request
! * @param rules the rules to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List rules) {
boolean atLeastOneError = false;
boolean potentialDeny = false;
boolean atLeastOnePermit = false;
Result firstIndeterminateResult = null;
! Iterator it = rules.iterator();
while (it.hasNext()) {
! Rule rule = (Rule)(it.next());
Result result = rule.evaluate(context);
int value = result.getDecision();
--- 108,127 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param ruleElements the rules to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List ruleElements) {
boolean atLeastOneError = false;
boolean potentialDeny = false;
boolean atLeastOnePermit = false;
Result firstIndeterminateResult = null;
! Iterator it = ruleElements.iterator();
while (it.hasNext()) {
! Rule rule = ((RuleCombinerElement)(it.next())).getRule();
Result result = rule.evaluate(context);
int value = result.getDecision();
Index: PermitOverridesPolicyAlg.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PermitOverridesPolicyAlg.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PermitOverridesPolicyAlg.java 23 Mar 2004 23:38:55 -0000 1.5
--- PermitOverridesPolicyAlg.java 7 Jan 2005 23:50:47 -0000 1.6
***************
*** 3,7 ****
* @(#)PermitOverridesPolicyAlg.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)PermitOverridesPolicyAlg.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 111,127 ****
*
* @param context the context from the request
! * @param policies the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List policies) {
boolean atLeastOneError = false;
boolean atLeastOneDeny = false;
Set denyObligations = new HashSet();
Status firstIndeterminateStatus = null;
! Iterator it = policies.iterator();
while (it.hasNext()) {
! AbstractPolicy policy = (AbstractPolicy)(it.next());
// make sure that the policy matches the context
--- 111,131 ----
*
* @param context the context from the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param policyElements the policies to combine
*
* @return the result of running the combining algorithm
*/
! public Result combine(EvaluationCtx context, List parameters,
! List policyElements) {
boolean atLeastOneError = false;
boolean atLeastOneDeny = false;
Set denyObligations = new HashSet();
Status firstIndeterminateStatus = null;
! Iterator it = policyElements.iterator();
while (it.hasNext()) {
! AbstractPolicy policy =
! ((PolicyCombinerElement)(it.next())).getPolicy();
// make sure that the policy matches the context
Index: RuleCombiningAlgorithm.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/RuleCombiningAlgorithm.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RuleCombiningAlgorithm.java 17 Mar 2004 18:03:38 -0000 1.4
--- RuleCombiningAlgorithm.java 7 Jan 2005 23:50:48 -0000 1.5
***************
*** 3,7 ****
* @(#)RuleCombiningAlgorithm.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)RuleCombiningAlgorithm.java
*
! * Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 70,78 ****
*
* @param context the representation of the request
! * @param rules the rules to combine
*
* @return a single unified result based on the combining logic
*/
! public abstract Result combine(EvaluationCtx context, List rules);
}
--- 70,81 ----
*
* @param context the representation of the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param ruleElements a <code>List</code> of <code>CombinerElement<code>s
*
* @return a single unified result based on the combining logic
*/
! public abstract Result combine(EvaluationCtx context, List parameters,
! List ruleElements);
}
--- NEW FILE: PolicyCombinerElement.java ---
/*
* @(#)PolicyCombinerElement.java
*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
* AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
* AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
* REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
* INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
* OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed or intended for use in
* the design, construction, operation or maintenance of any nuclear facility.
*/
package com.sun.xacml.combine;
import com.sun.xacml.AbstractPolicy;
import com.sun.xacml.Indenter;
import com.sun.xacml.Policy;
import com.sun.xacml.PolicyReference;
import com.sun.xacml.PolicySet;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.List;
/**
* Specific version of <code>CombinerElement</code> used for policy combining.
*
* @since 2.0
* @author Seth Proctor
*/
public class PolicyCombinerElement extends CombinerElement
{
/**
* Constructor that only takes an <code>AbstractPolicy</code. No parameters
* are associated with this <code>AbstractPolicy</code> when combining.
*
* @param policy an <code>AbstractPolicy</code> to use in combining
*/
public PolicyCombinerElement(AbstractPolicy policy) {
super(policy);
}
/**
* Constructor that takes both the <code>AbstractPolicy</code> to combine
* and its associated combiner parameters.
*
* @param policy an <code>AbstractPolicy</code> to use in combining
* @param parameters a (possibly empty) non-null <code>List</code> of
* <code>CombinerParameter<code>s provided for general
* use (for all pre-2.0 policies this must be empty)
*/
public PolicyCombinerElement(AbstractPolicy policy, List parameters) {
super(policy, parameters);
}
/**
* Returns the <code>AbstractPolicy</code> in this element.
*
* @return the element's <code>AbstractPolicy</code>
*/
public AbstractPolicy getPolicy() {
return (AbstractPolicy)(getElement());
}
/**
* Encodes this element's <code>AbstractPolicy</code> and parameters into
* their XML representation and writes this encoding to the given
* <code>OutputStream</code> with indentation.
*
* @param output a stream into which the XML-encoded data is written
* @param indenter an object that creates indentation strings
*/
public void encode(OutputStream output, Indenter indenter) {
if (! getParameters().isEmpty()) {
AbstractPolicy policy = getPolicy();
// FIXME: This is ugly and happens in several places...maybe this
// should get folded into the AbstractPolicy API?
if (policy instanceof Policy) {
encodeParamaters(output, indenter, "Policy",
policy.getId().toString());
} else if (policy instanceof PolicySet) {
encodeParamaters(output, indenter, "PolicySet",
policy.getId().toString());
} else {
PolicyReference ref = (PolicyReference)policy;
if (ref.getReferenceType() == PolicyReference.POLICY_REFERENCE)
encodeParamaters(output, indenter, "Policy",
ref.getReference().toString());
else
encodeParamaters(output, indenter, "PolicySet",
ref.getReference().toString());
}
}
getPolicy().encode(output, indenter);
}
/**
* Private helper that encodes the parameters based on the type
*/
private void encodeParamaters(OutputStream output, Indenter indenter,
String prefix, String id) {
PrintStream out = new PrintStream(output);
String indent = indenter.makeString();
Iterator it = getParameters().iterator();
out.println(indent + "<" + prefix + "CombinerParameters " +
prefix + "IdRef=\"" + id + "\">");
indenter.in();
while (it.hasNext()) {
CombinerParameter param = (CombinerParameter)(it.next());
param.encode(output, indenter);
}
out.println(indent + "</" + prefix + "CombinerParameters>");
indenter.out();
}
}
Index: PolicyCombiningAlgorithm.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/PolicyCombiningAlgorithm.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PolicyCombiningAlgorithm.java 17 Mar 2004 18:03:38 -0000 1.3
--- PolicyCombiningAlgorithm.java 7 Jan 2005 23:50:48 -0000 1.4
***************
*** 82,90 ****
*
* @param context the representation of the request
! * @param policies the policies to combine
*
* @return a single unified result based on the combining logic
*/
! public abstract Result combine(EvaluationCtx context, List policies);
}
--- 82,94 ----
*
* @param context the representation of the request
! * @param parameters a (possibly empty) non-null <code>List</code> of
! * <code>CombinerParameter<code>s
! * @param policyElements a <code>List</code> of
! * <code>CombinerElement<code>s
*
* @return a single unified result based on the combining logic
*/
! public abstract Result combine(EvaluationCtx context, List parameters,
! List policyElements);
}
|