Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15175/com/sun/xacml/cond
Modified Files:
AbsFunction.java AddFunction.java BagFunction.java
ComparisonFunction.java DateMathFunction.java
DivideFunction.java EqualFunction.java FloorFunction.java
HigherOrderFunction.java LogicalFunction.java
MatchFunction.java ModFunction.java MultiplyFunction.java
NOfFunction.java NotFunction.java NumericConvertFunction.java
RoundFunction.java SetFunction.java
StringNormalizeFunction.java SubtractFunction.java
Added Files:
BasicFunctionFactoryProxy.java ConditionBagFunction.java
ConditionSetFunction.java GeneralBagFunction.java
GeneralSetFunction.java MapFunctionProxy.java
Log Message:
preliminary re-factoring to make condition code publically consumable and
usable by the run-time configuration system
Index: LogicalFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/LogicalFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** LogicalFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- LogicalFunction.java 15 Mar 2004 21:52:41 -0000 1.2
***************
*** 1,7 ****
/*
! * @(#)LogicalFunction.java 1.5 01/30/03
*
! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 1,7 ----
/*
! * @(#)LogicalFunction.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 40,54 ****
import com.sun.xacml.attr.AttributeValue;
- import com.sun.xacml.attr.BagAttribute;
import com.sun.xacml.attr.BooleanAttribute;
import java.util.Iterator;
import java.util.List;
! import java.util.Map;
/**
! * A class that implements several of the logical functions: or and
! * and. It takes any number of boolean arguments. It evaluates
* them one at a time, starting with the first argument. As soon as
* the result of the function can be determined, evaluation stops and
--- 40,54 ----
import com.sun.xacml.attr.AttributeValue;
import com.sun.xacml.attr.BooleanAttribute;
+ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
! import java.util.Set;
/**
! * A class that implements the logical functions "or" and "and".
! * These functions take any number of boolean arguments and evaluate
* them one at a time, starting with the first argument. As soon as
* the result of the function can be determined, evaluation stops and
***************
*** 57,101 ****
*
* @author Steve Hanna
*/
! class LogicalFunction extends FunctionBase
{
! // To add to the list of XACML functions implemented by this class,
! // add static final fields here for the function name and ID.
! // Then change the code in addFunctions to indicate that this function
! // is supported and change the code in eval to implement it.
!
! // Names of XACML functions implemented by this class
!
public static final String NAME_OR = FUNCTION_NS + "or";
- public static final String NAME_AND = FUNCTION_NS + "and";
! // ID numbers for XACML functions implemented by the class
! // NOTE: These identifiers MUST be unique within this class.
private static final int ID_OR = 0;
private static final int ID_AND = 1;
/**
! * Add all the functions supported by this class to the list
! * of functions handled by this class.
*/
! public static void addFunctions(Map functionMap) {
! functionMap.put(NAME_OR,
! new LogicalFunction(NAME_OR, ID_OR));
! functionMap.put(NAME_AND,
! new LogicalFunction(NAME_AND, ID_AND));
}
/**
! * Creates a new <code>LogicalFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object (like function:or)
! * @param functionId an identifier number for this function
*/
! protected LogicalFunction(String functionName, int functionId) {
! super(functionName, functionId, BooleanAttribute.identifier, false,
! -1, BooleanAttribute.identifier, false);
}
--- 57,103 ----
*
* @author Steve Hanna
+ * @author Seth Proctor
*/
! public class LogicalFunction extends FunctionBase
{
! /**
! * Standard identifier for the or function.
! */
public static final String NAME_OR = FUNCTION_NS + "or";
! /**
! * Standard identifier for the and function.
! */
! public static final String NAME_AND = FUNCTION_NS + "and";
+ // internal identifiers for each of the supported functions
private static final int ID_OR = 0;
private static final int ID_AND = 1;
/**
! * Creates a new <code>LogicalFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object, including the full namespace
! *
! * @throws IllegalArgumentException if the functionName is unknown
*/
! public LogicalFunction(String functionName) {
! super(functionName, getId(functionName), BooleanAttribute.identifier,
! false, -1, BooleanAttribute.identifier, false);
}
/**
! * Private helper that looks up the private id based on the function name.
*/
! private static int getId(String functionName) {
! if (functionName.equals(NAME_OR))
! return ID_OR;
! else if (functionName.equals(NAME_AND))
! return ID_AND;
! else
! throw new IllegalArgumentException("unknown logical function: " +
! functionName);
}
--- NEW FILE: ConditionSetFunction.java ---
/*
* @(#)ConditionSetFunction.java
*
* Copyright 2004 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.cond;
import com.sun.xacml.EvaluationCtx;
import com.sun.xacml.attr.AttributeValue;
import com.sun.xacml.attr.BagAttribute;
import com.sun.xacml.attr.BooleanAttribute;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* Specific <code>SetFunction</code> class that supports all of the
* condition set functions: type-at-least-one-member-of, type-subset, and
* type-set-equals.
*
* @author Seth Proctor
*/
public class ConditionSetFunction extends SetFunction
{
// private identifiers for the supported functions
private static final int ID_BASE_AT_LEAST_ONE_MEMBER_OF = 0;
private static final int ID_BASE_SUBSET = 1;
private static final int ID_BASE_SET_EQUALS = 2;
// mapping of function name to its associated id and parameter type
private static HashMap idMap;
private static HashMap typeMap;
/**
* Static initializer that sets up the paramater info for all the
* supported functions.
*/
static {
idMap = new HashMap();
typeMap = new HashMap();
idMap.put(NAME_BASE_AT_LEAST_ONE_MEMBER_OF,
new Integer(ID_BASE_AT_LEAST_ONE_MEMBER_OF));
idMap.put(NAME_BASE_SUBSET, new Integer(ID_BASE_SUBSET));
idMap.put(NAME_BASE_SET_EQUALS, new Integer(ID_BASE_SET_EQUALS));
for (int i = 0; i < baseTypes.length; i++) {
String baseName = FUNCTION_NS + simpleTypes[i];
String baseType = baseTypes[i];
idMap.put(baseName + NAME_BASE_AT_LEAST_ONE_MEMBER_OF,
new Integer(ID_BASE_AT_LEAST_ONE_MEMBER_OF));
idMap.put(baseName + NAME_BASE_SUBSET,
new Integer(ID_BASE_SUBSET));
idMap.put(baseName + NAME_BASE_SET_EQUALS,
new Integer(ID_BASE_SET_EQUALS));
typeMap.put(baseName + NAME_BASE_AT_LEAST_ONE_MEMBER_OF, baseType);
typeMap.put(baseName + NAME_BASE_SUBSET, baseType);
typeMap.put(baseName + NAME_BASE_SET_EQUALS, baseType);
}
};
/**
* Constructor that is used to create one of the condition standard
* set functions. The name supplied must be one of the standard XACML
* functions supported by this class, including the full namespace,
* otherwise an exception is thrown. Look in <code>SetFunction</code>
* for details about the supported names.
*
* @param functionName the name of the function to create
*
* @throws IllegalArgumentException if the function is unknown
*/
public ConditionSetFunction(String functionName) {
super(functionName, getId(functionName), getArgumentType(functionName),
BooleanAttribute.identifier, false);
}
/**
* Constructor that is used to create instances of condition set
* functions for new (non-standard) datatypes. This is equivalent to
* using the <code>getInstance</code> methods in <code>SetFunction</code>
* and is generally only used by the run-time configuration code.
*
* @param functionName the name of the new function
* @param datatype the full identifier for the supported datatype
* @param functionType which kind of Set function, based on the
* <code>NAME_BASE_*</code> fields
*/
public ConditionSetFunction(String functionName, String datatype,
String functionType) {
super(functionName, getId(functionName), datatype,
BooleanAttribute.identifier, false);
}
/**
* Private helper that returns the internal identifier used for the
* given standard function.
*/
private static int getId(String functionName) {
Integer id = (Integer)(idMap.get(functionName));
if (id == null)
throw new IllegalArgumentException("unknown set function " +
functionName);
return id.intValue();
}
/**
* Private helper that returns the argument type for the given standard
* function. Note that this doesn't check on the return value since the
* method always is called after getId, so we assume that the function
* is present.
*/
private static String getArgumentType(String functionName) {
return (String)(typeMap.get(functionName));
}
/**
* Evaluates the function, using the specified parameters.
*
* @param inputs a <code>List</code> of <code>Evaluatable</code>
* objects representing the arguments passed to the function
* @param context an <code>EvaluationCtx</code> so that the
* <code>Evaluatable</code> objects can be evaluated
* @return an <code>EvaluationResult</code> representing the
* function's result
*/
public EvaluationResult evaluate(List inputs, EvaluationCtx context) {
// Evaluate the arguments
AttributeValue [] argValues = new AttributeValue[inputs.size()];
EvaluationResult evalResult = evalArgs(inputs, context, argValues);
if (evalResult != null)
return evalResult;
// setup the two bags we'll be using
BagAttribute [] bags = new BagAttribute[2];
bags[0] = (BagAttribute)(argValues[0]);
bags[1] = (BagAttribute)(argValues[1]);
AttributeValue result = null;
switch(getFunctionId()) {
// *-at-least-one-member-of takes two bags of the same type and
// returns a boolean
case ID_BASE_AT_LEAST_ONE_MEMBER_OF:
// true if at least one element in the first argument is in the
// second argument (using the *-is-in semantics)
result = BooleanAttribute.getFalseInstance();
Iterator it = bags[0].iterator();
while (it.hasNext()) {
if (bags[1].contains((AttributeValue)(it.next()))) {
result = BooleanAttribute.getTrueInstance();
break;
}
}
break;
// *-set-equals takes two bags of the same type and returns
// a boolean
case ID_BASE_SUBSET:
// returns true if the first argument is a subset of the second
// argument (ie, all the elements in the first bag appear in
// the second bag) ... ignore all duplicate values in both
// input bags
boolean subset = bags[1].containsAll(bags[0]);
result = BooleanAttribute.getInstance(subset);
break;
// *-set-equals takes two bags of the same type and returns
// a boolean
case ID_BASE_SET_EQUALS:
// returns true if the two inputs contain the same elements
// discounting any duplicates in either input ... this is the same
// as applying the and function on the subset function with
// the two inputs, and then the two inputs reversed (ie, are the
// two inputs subsets of each other)
boolean equals = (bags[1].containsAll(bags[0]) &&
bags[0].containsAll(bags[1]));
result = BooleanAttribute.getInstance(equals);
break;
}
return new EvaluationResult(result);
}
}
Index: NumericConvertFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/NumericConvertFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** NumericConvertFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- NumericConvertFunction.java 15 Mar 2004 21:52:41 -0000 1.2
***************
*** 1,7 ****
/*
! * @(#)NumericConvertFunction.java 1.3 01/30/03
*
! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 1,7 ----
/*
! * @(#)NumericConvertFunction.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 43,48 ****
import com.sun.xacml.attr.IntegerAttribute;
import java.util.List;
! import java.util.Map;
--- 43,49 ----
import com.sun.xacml.attr.IntegerAttribute;
+ import java.util.HashSet;
import java.util.List;
! import java.util.Set;
***************
*** 53,112 ****
* and returns the result. If the argument is indeterminate, an
* indeterminate result is returned.
- * <p>
- * Each instance of this class is told when constructed which function
- * it will be implementing (double-to-integer, etc.). This allows the
- * instance to optimize itself for that purpose.
*
* @author Steve Hanna
*/
! class NumericConvertFunction extends FunctionBase
{
! // To add to the list of XACML functions implemented by this class,
! // add static final fields here for the function name and ID.
! // Then change the code in addFunctions to indicate that this function
! // is supported and change the code in eval to implement it.
!
! // Names of XACML functions implemented by this class
!
public static final String NAME_DOUBLE_TO_INTEGER =
FUNCTION_NS + "double-to-integer";
public static final String NAME_INTEGER_TO_DOUBLE =
FUNCTION_NS + "integer-to-double";
! // ID numbers for XACML functions implemented by the class
! // NOTE: These identifiers MUST be unique within this class.
!
private static final int ID_DOUBLE_TO_INTEGER = 0;
private static final int ID_INTEGER_TO_DOUBLE = 1;
/**
! * Add all the functions supported by this class to the list
! * of functions handled by this class.
*/
! public static void addFunctions(Map functionMap) {
! functionMap.put(NAME_DOUBLE_TO_INTEGER, new NumericConvertFunction(
! NAME_DOUBLE_TO_INTEGER, ID_DOUBLE_TO_INTEGER,
! DoubleAttribute.identifier, IntegerAttribute.identifier));
! functionMap.put(NAME_INTEGER_TO_DOUBLE, new NumericConvertFunction(
! NAME_INTEGER_TO_DOUBLE, ID_INTEGER_TO_DOUBLE,
! IntegerAttribute.identifier, DoubleAttribute.identifier));
}
/**
! * Creates a new <code>NumericConvertFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object (like function:string-equal)
! * @param functionId an identifier number for this function
! * @param argumentType the standard XACML name for the type of
! * the arguments (like string)
! * @param returnType the standard XACML name for the type of
! * the return value (like string)
*/
! protected NumericConvertFunction(String functionName, int functionId,
! String argumentType, String returnType) {
! super(functionName, functionId, argumentType, false, 1,
! returnType, false);
}
--- 54,131 ----
* and returns the result. If the argument is indeterminate, an
* indeterminate result is returned.
*
* @author Steve Hanna
+ * @author Seth Proctor
*/
! public class NumericConvertFunction extends FunctionBase
{
! /**
! * Standard identifier for the double-to-integer function.
! */
public static final String NAME_DOUBLE_TO_INTEGER =
FUNCTION_NS + "double-to-integer";
+
+ /**
+ * Standard identifier for the integer-to-double function.
+ */
public static final String NAME_INTEGER_TO_DOUBLE =
FUNCTION_NS + "integer-to-double";
! // private identifiers for the supported functions
private static final int ID_DOUBLE_TO_INTEGER = 0;
private static final int ID_INTEGER_TO_DOUBLE = 1;
/**
! * Creates a new <code>NumericConvertFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object, including the full namespace
! *
! * @throws IllegalArgumentException if the function is unknwon
*/
! public NumericConvertFunction(String functionName) {
! super(functionName, getId(functionName), getArgumentType(functionName),
! false, 1, getReturnType(functionName), false);
}
/**
! * Private helper that returns the internal identifier used for the
! * given standard function.
*/
! private static int getId(String functionName) {
! if (functionName.equals(NAME_DOUBLE_TO_INTEGER))
! return ID_DOUBLE_TO_INTEGER;
! else if (functionName.equals(NAME_INTEGER_TO_DOUBLE))
! return ID_INTEGER_TO_DOUBLE;
! else
! throw new IllegalArgumentException("unknown convert function " +
! functionName);
! }
!
! /**
! * Private helper that returns the type used for the given standard
! * function. Note that this doesn't check on the return value since the
! * method always is called after getId, so we assume that the function
! * is present.
! */
! private static String getArgumentType(String functionName) {
! if (functionName.equals(NAME_DOUBLE_TO_INTEGER))
! return DoubleAttribute.identifier;
! else
! return IntegerAttribute.identifier;
! }
!
! /**
! * Private helper that returns the return type for the given standard
! * function. Note that this doesn't check on the return value since the
! * method always is called after getId, so we assume that the function
! * is present.
! */
! private static String getReturnType(String functionName) {
! if (functionName.equals(NAME_DOUBLE_TO_INTEGER))
! return IntegerAttribute.identifier;
! else
! return DoubleAttribute.identifier;
}
--- NEW FILE: GeneralSetFunction.java ---
/*
* @(#)GeneralSetFunction.java
*
* Copyright 2004 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.cond;
import com.sun.xacml.EvaluationCtx;
import com.sun.xacml.attr.AttributeValue;
import com.sun.xacml.attr.BagAttribute;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* Specific <code>SetFunction</code> class that supports all of the
* general-purpose set functions: type-intersection and type-union.
*
* @author Seth Proctor
*/
public class GeneralSetFunction extends SetFunction
{
// private identifiers for the supported functions
private static final int ID_BASE_INTERSECTION = 0;
private static final int ID_BASE_UNION = 1;
// mapping of function name to its associated id and parameter type
private static HashMap idMap;
private static HashMap typeMap;
/**
* Static initializer that sets up the paramater info for all the
* supported functions.
*/
static {
idMap = new HashMap();
typeMap = new HashMap();
idMap.put(NAME_BASE_INTERSECTION, new Integer(ID_BASE_INTERSECTION));
idMap.put(NAME_BASE_UNION, new Integer(ID_BASE_UNION));
for (int i = 0; i < baseTypes.length; i++) {
String baseName = FUNCTION_NS + simpleTypes[i];
String baseType = baseTypes[i];
idMap.put(baseName + NAME_BASE_INTERSECTION,
new Integer(ID_BASE_INTERSECTION));
idMap.put(baseName + NAME_BASE_UNION,
new Integer(ID_BASE_UNION));
typeMap.put(baseName + NAME_BASE_INTERSECTION, baseType);
typeMap.put(baseName + NAME_BASE_UNION, baseType);
}
};
/**
* Constructor that is used to create one of the general-purpose standard
* set functions. The name supplied must be one of the standard XACML
* functions supported by this class, including the full namespace,
* otherwise an exception is thrown. Look in <code>SetFunction</code>
* for details about the supported names.
*
* @param functionName the name of the function to create
*
* @throws IllegalArgumentException if the function is unknown
*/
public GeneralSetFunction(String functionName) {
super(functionName, getId(functionName), getArgumentType(functionName),
getArgumentType(functionName), true);
}
/**
* Constructor that is used to create instances of general-purpose set
* functions for new (non-standard) datatypes. This is equivalent to
* using the <code>getInstance</code> methods in <code>SetFunction</code>
* and is generally only used by the run-time configuration code.
*
* @param functionName the name of the new function
* @param datatype the full identifier for the supported datatype
* @param functionType which kind of Set function, based on the
* <code>NAME_BASE_*</code> fields
*/
public GeneralSetFunction(String functionName, String datatype,
String functionType) {
super(functionName, getId(functionType), datatype, datatype, true);
}
/**
* Private helper that returns the internal identifier used for the
* given standard function.
*/
private static int getId(String functionName) {
Integer id = (Integer)(idMap.get(functionName));
if (id == null)
throw new IllegalArgumentException("unknown set function " +
functionName);
return id.intValue();
}
/**
* Private helper that returns the argument type for the given standard
* function. Note that this doesn't check on the return value since the
* method always is called after getId, so we assume that the function
* is present.
*/
private static String getArgumentType(String functionName) {
return (String)(typeMap.get(functionName));
}
/**
* Evaluates the function, using the specified parameters.
*
* @param inputs a <code>List</code> of <code>Evaluatable</code>
* objects representing the arguments passed to the function
* @param context an <code>EvaluationCtx</code> so that the
* <code>Evaluatable</code> objects can be evaluated
* @return an <code>EvaluationResult</code> representing the
* function's result
*/
public EvaluationResult evaluate(List inputs, EvaluationCtx context) {
// Evaluate the arguments
AttributeValue [] argValues = new AttributeValue[inputs.size()];
EvaluationResult evalResult = evalArgs(inputs, context, argValues);
if (evalResult != null)
return evalResult;
// setup the two bags we'll be using
BagAttribute [] bags = new BagAttribute[2];
bags[0] = (BagAttribute)(argValues[0]);
bags[1] = (BagAttribute)(argValues[1]);
AttributeValue result = null;
Set set = new HashSet();
switch(getFunctionId()) {
// *-intersection takes two bags of the same type and returns
// a bag of that type
case ID_BASE_INTERSECTION:
// create a bag with the common elements of both inputs, removing
// all duplicate values
Iterator it = bags[0].iterator();
// find all the things in bags[0] that are also in bags[1]
while (it.hasNext()) {
AttributeValue value = (AttributeValue)(it.next());
if (bags[1].contains(value)) {
// sets won't allow duplicates, so this addition is ok
set.add(value);
}
}
result = new BagAttribute(bags[0].getType(), set);
break;
// *-union takes two bags of the same type and returns a bag of
// that type
case ID_BASE_UNION:
// create a bag with all the elements from both inputs, removing
// all duplicate values
Iterator it0 = bags[0].iterator();
while (it0.hasNext()) {
// first off, add all elements from the first bag...the set
// will ignore all duplicates
set.add(it0.next());
}
Iterator it1 = bags[1].iterator();
while (it1.hasNext()) {
// now add all the elements from the second bag...again, all
// duplicates will be ignored by the set
set.add(it1.next());
}
result = new BagAttribute(bags[0].getType(), set);
break;
}
return new EvaluationResult(result);
}
}
Index: AddFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/AddFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** AddFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- AddFunction.java 15 Mar 2004 21:52:41 -0000 1.2
***************
*** 1,7 ****
/*
! * @(#)AddFunction.java 1.9 01/30/03
*
! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 1,7 ----
/*
! * @(#)AddFunction.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 43,48 ****
import com.sun.xacml.attr.IntegerAttribute;
import java.util.List;
! import java.util.Map;
--- 43,49 ----
import com.sun.xacml.attr.IntegerAttribute;
+ import java.util.HashSet;
import java.util.List;
! import java.util.Set;
***************
*** 52,107 ****
* If any of the operands is indeterminate, an indeterminate result is
* returned.
- * <p>
- * Each instance of this class is told when constructed which function
- * it will be implementing (integer-add, etc.). This allows the instance
- * to optimize itself for that purpose.
*
* @author Steve Hanna
*/
! class AddFunction extends FunctionBase
{
! // To add to the list of XACML functions implemented by this class,
! // add static final fields here for the function name and ID.
! // Then change the code in addFunctions to indicate that this function
! // is supported and change the code in eval to implement it.
!
! // Names of XACML functions implemented by this class
!
public static final String NAME_INTEGER_ADD =
FUNCTION_NS + "integer-add";
public static final String NAME_DOUBLE_ADD =
FUNCTION_NS + "double-add";
! // ID numbers for XACML functions implemented by the class
! // NOTE: These identifiers MUST be unique within this class.
!
private static final int ID_INTEGER_ADD = 0;
private static final int ID_DOUBLE_ADD = 1;
/**
! * Add all the functions supported by this class to the list
! * of functions handled by this class.
*/
! public static void addFunctions(Map functionMap) {
! functionMap.put(NAME_INTEGER_ADD, new AddFunction(
! NAME_INTEGER_ADD, ID_INTEGER_ADD, IntegerAttribute.identifier));
! functionMap.put(NAME_DOUBLE_ADD, new AddFunction(
! NAME_DOUBLE_ADD, ID_DOUBLE_ADD, DoubleAttribute.identifier));
}
/**
! * Creates a new <code>AddFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object (eg integer-add)
! * @param functionId an Identifier number for this function
! * @param argumentType the standard XACML name for the type of
! * the arguments (like integer)
*/
! protected AddFunction(String functionName, int functionId,
! String argumentType) {
! super(functionName, functionId, argumentType, false, -1, 2,
! argumentType, false);
}
--- 53,117 ----
* If any of the operands is indeterminate, an indeterminate result is
* returned.
*
* @author Steve Hanna
+ * @author Seth Proctor
*/
! public class AddFunction extends FunctionBase
{
! /**
! * Standard identifier for the integer-add function.
! */
public static final String NAME_INTEGER_ADD =
FUNCTION_NS + "integer-add";
+
+ /**
+ * Standard identifier for the double-add function.
+ */
public static final String NAME_DOUBLE_ADD =
FUNCTION_NS + "double-add";
! // inernal identifiers for each of the supported functions
private static final int ID_INTEGER_ADD = 0;
private static final int ID_DOUBLE_ADD = 1;
/**
! * Creates a new <code>AddFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object, including the full namespace
! *
! * @throws IllegalArgumentException if the function is unknown
*/
! public AddFunction(String functionName) {
! super(functionName, getId(functionName), getArgumentType(functionName),
! false, -1, 2, getArgumentType(functionName), false);
}
/**
! * Private helper that returns the internal identifier used for the
! * given standard function.
*/
! private static int getId(String functionName) {
! if (functionName.equals(NAME_INTEGER_ADD))
! return ID_INTEGER_ADD;
! else if (functionName.equals(NAME_DOUBLE_ADD))
! return ID_DOUBLE_ADD;
! else
! throw new IllegalArgumentException("unknown add function " +
! functionName);
! }
!
! /**
! * Private helper that returns the type used for the given standard
! * function. Note that this doesn't check on the return value since the
! * method always is called after getId, so we assume that the function
! * is present.
! */
! private static String getArgumentType(String functionName) {
! if (functionName.equals(NAME_INTEGER_ADD))
! return IntegerAttribute.identifier;
! else
! return DoubleAttribute.identifier;
}
***************
*** 123,127 ****
if (result != null)
return result;
!
// Now that we have real values, perform the add operation
switch (getFunctionId()) {
--- 133,137 ----
if (result != null)
return result;
!
// Now that we have real values, perform the add operation
switch (getFunctionId()) {
***************
*** 132,136 ****
sum += arg;
}
!
result = new EvaluationResult(new IntegerAttribute(sum));
break;
--- 142,146 ----
sum += arg;
}
!
result = new EvaluationResult(new IntegerAttribute(sum));
break;
***************
*** 143,147 ****
sum = sum + arg;
}
!
// Make it round half even, not round nearest
double lower = Math.floor(sum);
--- 153,157 ----
sum = sum + arg;
}
!
// Make it round half even, not round nearest
double lower = Math.floor(sum);
***************
*** 153,157 ****
sum = higher;
}
!
result = new EvaluationResult(new DoubleAttribute(sum));
break;
--- 163,167 ----
sum = higher;
}
!
result = new EvaluationResult(new DoubleAttribute(sum));
break;
***************
*** 161,163 ****
--- 171,174 ----
return result;
}
+
}
Index: RoundFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/RoundFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** RoundFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- RoundFunction.java 15 Mar 2004 21:52:41 -0000 1.2
***************
*** 1,7 ****
/*
! * @(#)RoundFunction.java 1.7 01/30/03
*
! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 1,7 ----
/*
! * @(#)RoundFunction.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 43,48 ****
import com.sun.xacml.attr.IntegerAttribute;
import java.util.List;
! import java.util.Map;
--- 43,49 ----
import com.sun.xacml.attr.IntegerAttribute;
+ import java.util.HashSet;
import java.util.List;
! import java.util.Set;
***************
*** 53,82 ****
*
* @author Steve Hanna
*/
! class RoundFunction extends FunctionBase
{
- // To add to the list of XACML functions implemented by this class,
- // add static final fields here for the function name and ID.
- // Then change the code in addFunctions to indicate that this function
- // is supported and change the code in eval to implement it.
-
- // Names of XACML functions implemented by this class
-
- public static final String NAME_ROUND = FUNCTION_NS + "round";
-
- // ID numbers for XACML functions implemented by the class
- // NOTE: These identifiers MUST be unique within this class.
-
- private static final int ID_ROUND = 0;
-
/**
! * Add all the functions supported by this class to the list
! * of functions handled by this class.
*/
! public static void addFunctions(Map functionMap) {
! functionMap.put(NAME_ROUND,
! new RoundFunction(NAME_ROUND, ID_ROUND));
! }
/**
--- 54,66 ----
*
* @author Steve Hanna
+ * @author Seth Proctor
*/
! public class RoundFunction extends FunctionBase
{
/**
! * Standard identifier for the round function.
*/
! public static final String NAME_ROUND = FUNCTION_NS + "round";
/**
***************
*** 84,93 ****
*
* @param functionName the standard XACML name of the function to be
! * handled by this object (like function:string-equal)
! * @param functionId an identifier number for this function
*/
! protected RoundFunction(String functionName, int functionId) {
! super(functionName, functionId, DoubleAttribute.identifier, false,
! 1, DoubleAttribute.identifier, false);
}
--- 68,82 ----
*
* @param functionName the standard XACML name of the function to be
! * handled by this object, including the full namespace
! *
! * @throws IllegalArgumentException if the function is unknown
*/
! public RoundFunction(String functionName) {
! super(NAME_ROUND, 0, DoubleAttribute.identifier, false, 1,
! DoubleAttribute.identifier, false);
!
! if (! functionName.equals(NAME_ROUND))
! throw new IllegalArgumentException("unknown round function: "
! + functionName);
}
***************
*** 111,136 ****
// Now that we have real values, perform the round operation
! // in the manner appropriate for the type of the arguments.
! switch (getFunctionId()) {
! case ID_ROUND: {
! double arg = ((DoubleAttribute) argValues[0]).getValue();
! double roundValue = Math.round(arg);
!
! // Make it round half even, not round nearest
! double lower = Math.floor(arg);
! double higher = lower + 1;
! if ((arg - lower) == (higher - arg)) {
! if ((lower % 2) == 0)
! roundValue = lower;
! else
! roundValue = higher;
! }
! result = new EvaluationResult(new DoubleAttribute(roundValue));
! break;
! }
}
!
! return result;
}
}
--- 100,118 ----
// Now that we have real values, perform the round operation
! double arg = ((DoubleAttribute) argValues[0]).getValue();
! double roundValue = Math.round(arg);
!
! // Make it round half even, not round nearest
! double lower = Math.floor(arg);
! double higher = lower + 1;
! if ((arg - lower) == (higher - arg)) {
! if ((lower % 2) == 0)
! roundValue = lower;
! else
! roundValue = higher;
}
!
! return new EvaluationResult(new DoubleAttribute(roundValue));
}
}
Index: DateMathFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/DateMathFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** DateMathFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- DateMathFunction.java 15 Mar 2004 21:52:41 -0000 1.2
***************
*** 1,7 ****
/*
! * @(#)DateMathFunction.java 1.7 01/30/03
*
! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 1,7 ----
/*
! * @(#)DateMathFunction.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 48,54 ****
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.List;
! import java.util.Map;
--- 48,56 ----
import java.util.Date;
import java.util.GregorianCalendar;
+ import java.util.HashMap;
+ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
! import java.util.Set;
***************
*** 64,95 ****
*
* @author Steve Hanna
*/
! class DateMathFunction extends FunctionBase
{
! // To add to the list of XACML functions implemented by this class,
! // add static final fields here for the function name and ID.
! // Then add an array of argument types below.
! // Then change the code in addFunctions to indicate that this function
! // is supported and change the code in eval to implement it.
!
! // Names of XACML functions implemented by this class
!
public static final String NAME_DATETIME_ADD_DAYTIMEDURATION =
FUNCTION_NS + "dateTime-add-dayTimeDuration";
public static final String NAME_DATETIME_SUBTRACT_DAYTIMEDURATION =
FUNCTION_NS + "dateTime-subtract-dayTimeDuration";
public static final String NAME_DATETIME_ADD_YEARMONTHDURATION =
FUNCTION_NS + "dateTime-add-yearMonthDuration";
public static final String NAME_DATETIME_SUBTRACT_YEARMONTHDURATION =
FUNCTION_NS + "dateTime-subtract-yearMonthDuration";
public static final String NAME_DATE_ADD_YEARMONTHDURATION =
FUNCTION_NS + "date-add-yearMonthDuration";
public static final String NAME_DATE_SUBTRACT_YEARMONTHDURATION =
FUNCTION_NS + "date-subtract-yearMonthDuration";
! // ID numbers for XACML functions implemented by the class
! // NOTE: These identifiers MUST be unique within this class.
!
private static final int ID_DATETIME_ADD_DAYTIMEDURATION = 0;
private static final int ID_DATETIME_SUBTRACT_DAYTIMEDURATION = 1;
--- 66,112 ----
*
* @author Steve Hanna
+ * @author Seth Proctor
*/
! public class DateMathFunction extends FunctionBase
{
! /**
! * Standard identifier for the dateTime-add-dayTimeDuration function.
! */
public static final String NAME_DATETIME_ADD_DAYTIMEDURATION =
FUNCTION_NS + "dateTime-add-dayTimeDuration";
+
+ /**
+ * Standard identifier for the dateTime-subtract-dayTimeDuration function.
+ */
public static final String NAME_DATETIME_SUBTRACT_DAYTIMEDURATION =
FUNCTION_NS + "dateTime-subtract-dayTimeDuration";
+
+ /**
+ * Standard identifier for the dateTime-add-yearMonthDuration function.
+ */
public static final String NAME_DATETIME_ADD_YEARMONTHDURATION =
FUNCTION_NS + "dateTime-add-yearMonthDuration";
+
+ /**
+ * Standard identifier for the dateTime-subtract-yearMonthDuration
+ * function.
+ */
public static final String NAME_DATETIME_SUBTRACT_YEARMONTHDURATION =
FUNCTION_NS + "dateTime-subtract-yearMonthDuration";
+
+ /**
+ * Standard identifier for the date-add-yearMonthDuration function.
+ */
public static final String NAME_DATE_ADD_YEARMONTHDURATION =
FUNCTION_NS + "date-add-yearMonthDuration";
+
+ /**
+ * Standard identifier for the date-subtract-yearMonthDuration function.
+ */
public static final String NAME_DATE_SUBTRACT_YEARMONTHDURATION =
FUNCTION_NS + "date-subtract-yearMonthDuration";
! // private identifiers for the supported functions
private static final int ID_DATETIME_ADD_DAYTIMEDURATION = 0;
private static final int ID_DATETIME_SUBTRACT_DAYTIMEDURATION = 1;
***************
*** 99,105 ****
private static final int ID_DATE_SUBTRACT_YEARMONTHDURATION = 5;
! /**
! * Argument types for dateTime-*-dayTimeDuration
! */
private static final String dateTimeDayTimeDurationArgTypes [] =
{ DateTimeAttribute.identifier,
--- 116,120 ----
private static final int ID_DATE_SUBTRACT_YEARMONTHDURATION = 5;
! // Argument types
private static final String dateTimeDayTimeDurationArgTypes [] =
{ DateTimeAttribute.identifier,
***************
*** 112,179 ****
YearMonthDurationAttribute.identifier };
/**
! * nothing here uses a bag
*/
! private static final boolean bagParams [] = { false, false };
/**
! * Argument types for this object
*/
! private String [] argTypes = null;
/**
! * Add all the functions supported by this class to the list
! * of functions handled by this class.
*/
! public static void addFunctions(Map functionMap) {
! // Put null for argumentType, since the types of the arguments
! // are different.
! functionMap.put(NAME_DATETIME_ADD_DAYTIMEDURATION,
! new DateMathFunction(NAME_DATETIME_ADD_DAYTIMEDURATION,
! ID_DATETIME_ADD_DAYTIMEDURATION,
! dateTimeDayTimeDurationArgTypes,
! DateTimeAttribute.identifier));
! functionMap.put(NAME_DATETIME_SUBTRACT_DAYTIMEDURATION,
! new DateMathFunction(NAME_DATETIME_SUBTRACT_DAYTIMEDURATION,
! ID_DATETIME_SUBTRACT_DAYTIMEDURATION,
! dateTimeDayTimeDurationArgTypes,
! DateTimeAttribute.identifier));
! functionMap.put(NAME_DATETIME_ADD_YEARMONTHDURATION,
! new DateMathFunction(NAME_DATETIME_ADD_YEARMONTHDURATION,
! ID_DATETIME_ADD_YEARMONTHDURATION,
! dateTimeYearMonthDurationArgTypes,
! DateTimeAttribute.identifier));
! functionMap.put(NAME_DATETIME_SUBTRACT_YEARMONTHDURATION,
! new DateMathFunction(NAME_DATETIME_SUBTRACT_YEARMONTHDURATION,
! ID_DATETIME_SUBTRACT_YEARMONTHDURATION,
! dateTimeYearMonthDurationArgTypes,
! DateTimeAttribute.identifier));
! functionMap.put(NAME_DATE_ADD_YEARMONTHDURATION,
! new DateMathFunction(NAME_DATE_ADD_YEARMONTHDURATION,
! ID_DATE_ADD_YEARMONTHDURATION,
! dateYearMonthDurationArgTypes,
! DateAttribute.identifier));
! functionMap.put(NAME_DATE_SUBTRACT_YEARMONTHDURATION,
! new DateMathFunction(NAME_DATE_SUBTRACT_YEARMONTHDURATION,
! ID_DATE_SUBTRACT_YEARMONTHDURATION,
! dateYearMonthDurationArgTypes,
! DateAttribute.identifier));
}
/**
! * Creates a new <code>DateMathFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object (like function:or)
! * @param functionId an identifier number for this function
! * @param argumentTypes the standard XACML names for the types of
! * the arguments (like string)
! * @param returnType the standard XACML name for the type of
! * the return value (like string)
*/
! protected DateMathFunction(String functionName, int functionId,
! String [] argumentTypes, String returnType) {
! super(functionName, functionId, argumentTypes, bagParams,
! returnType, false);
}
--- 127,225 ----
YearMonthDurationAttribute.identifier };
+ // nothing here uses a bag
+ private static final boolean bagParams [] = { false, false };
+
+ // Argument types for this object
+ private String [] argTypes = null;
+
+ // mapping from name to provide identifiers and argument types
+ private static HashMap idMap;
+ private static HashMap typeMap;
+
/**
! * Static initializer to setup the id and type maps
*/
! static {
! idMap = new HashMap();
!
! idMap.put(NAME_DATETIME_ADD_DAYTIMEDURATION,
! new Integer(ID_DATETIME_ADD_DAYTIMEDURATION));
! idMap.put(NAME_DATETIME_SUBTRACT_DAYTIMEDURATION,
! new Integer(ID_DATETIME_SUBTRACT_DAYTIMEDURATION));
! idMap.put(NAME_DATETIME_ADD_YEARMONTHDURATION,
! new Integer(ID_DATETIME_ADD_YEARMONTHDURATION));
! idMap.put(NAME_DATETIME_SUBTRACT_YEARMONTHDURATION,
! new Integer(ID_DATETIME_SUBTRACT_YEARMONTHDURATION));
! idMap.put(NAME_DATE_ADD_YEARMONTHDURATION,
! new Integer(ID_DATE_ADD_YEARMONTHDURATION));
! idMap.put(NAME_DATE_SUBTRACT_YEARMONTHDURATION,
! new Integer(ID_DATE_SUBTRACT_YEARMONTHDURATION));
!
! typeMap = new HashMap();
!
! typeMap.put(NAME_DATETIME_ADD_DAYTIMEDURATION,
! dateTimeDayTimeDurationArgTypes);
! typeMap.put(NAME_DATETIME_SUBTRACT_DAYTIMEDURATION,
! dateTimeDayTimeDurationArgTypes);
! typeMap.put(NAME_DATETIME_ADD_YEARMONTHDURATION,
! dateTimeYearMonthDurationArgTypes);
! typeMap.put(NAME_DATETIME_SUBTRACT_YEARMONTHDURATION,
! dateTimeYearMonthDurationArgTypes);
! typeMap.put(NAME_DATE_ADD_YEARMONTHDURATION,
! dateYearMonthDurationArgTypes);
! typeMap.put(NAME_DATE_SUBTRACT_YEARMONTHDURATION,
! dateYearMonthDurationArgTypes);
! };
/**
! * Creates a new <code>DateMathFunction</code> object.
! *
! * @param functionName the standard XACML name of the function to be
! * handled by this object, including the full namespace
! *
! * @throws IllegalArgumentException if the function is unknown
*/
! public DateMathFunction(String functionName) {
! super(functionName, getId(functionName),
! getArgumentTypes(functionName), bagParams,
! getReturnType(functionName), false);
! }
/**
! * Private helper that returns the internal identifier used for the
! * given standard function.
*/
! private static int getId(String functionName) {
! Integer i = (Integer)(idMap.get(functionName));
!
! if (i == null)
! throw new IllegalArgumentException("unknown datemath function " +
! functionName);
!
! return i.intValue();
}
/**
! * Private helper that returns the types used for the given standard
! * function. Note that this doesn't check on the return value since the
! * method always is called after getId, so we assume that the function
! * is present.
*/
! private static String [] getArgumentTypes(String functionName) {
! return (String [])(typeMap.get(functionName));
! }
!
! /**
! * Private helper that returns the return type for the given standard
! * function. Note that this doesn't check on the return value since the
! * method always is called after getId, so we assume that the function
! * is present.
! */
! private static String getReturnType(String functionName) {
! if (functionName.equals(NAME_DATE_ADD_YEARMONTHDURATION) ||
! functionName.equals(NAME_DATE_SUBTRACT_YEARMONTHDURATION))
! return DateAttribute.identifier;
! else
! return DateTimeAttribute.identifier;
}
Index: BagFunction.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/BagFunction.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** BagFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1
--- BagFunction.java 15 Mar 2004 21:52:41 -0000 1.2
***************
*** 1,7 ****
/*
! * @(#)BagFunction.java 1.14 01/30/03
*
! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 1,7 ----
/*
! * @(#)BagFunction.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 37,46 ****
package com.sun.xacml.cond;
- import com.sun.xacml.EvaluationCtx;
- import com.sun.xacml.UnknownIdentifierException;
-
import com.sun.xacml.attr.AnyURIAttribute;
- import com.sun.xacml.attr.AttributeValue;
- import com.sun.xacml.attr.BagAttribute;
import com.sun.xacml.attr.Base64BinaryAttribute;
import com.sun.xacml.attr.BooleanAttribute;
--- 37,41 ----
***************
*** 57,104 ****
import com.sun.xacml.attr.YearMonthDurationAttribute;
- import java.net.URI;
-
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
-
/**
! * A class that implements all of the bag functions: type-one-and-only,
! * type-bag-size, type-is-in, and type-bag.
*
* @author Seth Proctor
*/
! public class BagFunction extends FunctionBase
{
! // To add to the list of functions implemented by this class,
! // add static final fields here for the function name and ID.
!
! // Names of XACML functions implemented by this class
!
public static final String NAME_BASE_ONE_AND_ONLY =
"-one-and-only";
public static final String NAME_BASE_BAG_SIZE =
"-bag-size";
public static final String NAME_BASE_IS_IN =
"-is-in";
public static final String NAME_BASE_BAG =
"-bag";
! // ID numbers for XACML functions implemented by the class
! // NOTE: These identifiers MUST be unique within this class.
!
! private static final int ID_BASE_ONE_AND_ONLY = 0;
! private static final int ID_BASE_BAG_SIZE = 1;
! private static final int ID_BASE_IS_IN = 2;
! private static final int ID_BASE_BAG = 3;
!
private static final boolean bagParams [] = { false, true };
! // String [] of base types supported by this class
! private static String baseTypes [] = {
StringAttribute.identifier,
BooleanAttribute.identifier,
--- 52,110 ----
import com.sun.xacml.attr.YearMonthDurationAttribute;
/**
! * Represents all of the Bag functions, though the actual implementations
! * are in two sub-classes specific to the condition and general bag
! * functions.
*
* @author Seth Proctor
*/
! public abstract class BagFunction extends FunctionBase
{
! /**
! * Base name for the type-one-and-only funtions. To get the standard
! * identifier for a given type, use <code>FunctionBase.FUNCTION_NS</code>
! * + the datatype's base name (e.g., <code>string</code>) +
! * </code>NAME_BASE_ONE_AND_ONLY</code>.
! */
public static final String NAME_BASE_ONE_AND_ONLY =
"-one-and-only";
+
+ /**
+ * Base name for the type-bag-size funtions. To get the standard
+ * identifier for a given type, use <code>FunctionBase.FUNCTION_NS</code>
+ * + the datatype's base name (e.g., <code>string</code>) +
+ * </code>NAME_BASE_BAG_SIZE</code>.
+ */
public static final String NAME_BASE_BAG_SIZE =
"-bag-size";
+
+ /**
+ * Base name for the type-is-in. To get the standard
+ * identifier for a given type, use <code>FunctionBase.FUNCTION_NS</code>
+ * + the datatype's base name (e.g., <code>string</code>) +
+ * </code>NAME_BASE_IS_IN</code>.
+ */
public static final String NAME_BASE_IS_IN =
"-is-in";
+
+ /**
+ * Base name for the type-bag funtions. To get the standard
+ * identifier for a given type, use <code>FunctionBase.FUNCTION_NS</code>
+ * + the datatype's base name (e.g., <code>string</code>) +
+ * </code>NAME_BASE_BAG</code>.
+ */
public static final String NAME_BASE_BAG =
"-bag";
! // bag parameter info for the functions that accept multiple args
private static final boolean bagParams [] = { false, true };
! /**
! * A complete list of all the XACML datatypes supported by the Bag
! * functions
! */
! protected static String baseTypes [] = {
StringAttribute.identifier,
BooleanAttribute.identifier,
***************
*** 117,122 ****
};
! // String [] of the "simple" type names matching the baseTypes list
! private static String simpleTypes [] = {
...
[truncated message content] |