sunxacml-commit Mailing List for Sun's XACML Implementation (Page 6)
Brought to you by:
farrukh_najmi,
sethp
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(3) |
Jun
(3) |
Jul
(6) |
Aug
(37) |
Sep
(5) |
Oct
(6) |
Nov
(1) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(11) |
Mar
(26) |
Apr
(5) |
May
(27) |
Jun
(13) |
Jul
(7) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2005 |
Jan
(12) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(8) |
2006 |
Jan
(10) |
Feb
(6) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
|
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] |
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6501/com/sun/xacml/attr/proxy Added Files: AnyURIAttributeProxy.java Base64BinaryAttributeProxy.java BooleanAttributeProxy.java DateAttributeProxy.java DateTimeAttributeProxy.java DayTimeDurationAttributeProxy.java DoubleAttributeProxy.java HexBinaryAttributeProxy.java IntegerAttributeProxy.java RFC822NameAttributeProxy.java StringAttributeProxy.java TimeAttributeProxy.java X500NameAttributeProxy.java YearMonthDurationAttributeProxy.java package.html Log Message: added to support the run-time configuration system --- NEW FILE: X500NameAttributeProxy.java --- /* * @(#)X500NameAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.X500NameAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class X500NameAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return X500NameAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return X500NameAttribute.getInstance(value); } } --- NEW FILE: StringAttributeProxy.java --- /* * @(#)StringAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.StringAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class StringAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) { return StringAttribute.getInstance(root); } public AttributeValue getInstance(String value) { return StringAttribute.getInstance(value); } } --- NEW FILE: DoubleAttributeProxy.java --- /* * @(#)DoubleAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.DoubleAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class DoubleAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return DoubleAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DoubleAttribute.getInstance(value); } } --- NEW FILE: DayTimeDurationAttributeProxy.java --- /* * @(#)DayTimeDurationAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.DayTimeDurationAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class DayTimeDurationAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return DayTimeDurationAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DayTimeDurationAttribute.getInstance(value); } } --- NEW FILE: TimeAttributeProxy.java --- /* * @(#)TimeAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.TimeAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class TimeAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return TimeAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return TimeAttribute.getInstance(value); } } --- NEW FILE: RFC822NameAttributeProxy.java --- /* * @(#)RFC822NameAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.RFC822NameAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class RFC822NameAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return RFC822NameAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return RFC822NameAttribute.getInstance(value); } } --- NEW FILE: YearMonthDurationAttributeProxy.java --- /* * @(#)YearMonthDurationAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.YearMonthDurationAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class YearMonthDurationAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return YearMonthDurationAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return YearMonthDurationAttribute.getInstance(value); } } --- NEW FILE: HexBinaryAttributeProxy.java --- /* * @(#)HexBinaryAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.HexBinaryAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class HexBinaryAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return HexBinaryAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return HexBinaryAttribute.getInstance(value); } } --- NEW FILE: BooleanAttributeProxy.java --- /* * @(#)BooleanAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.BooleanAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class BooleanAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return BooleanAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return BooleanAttribute.getInstance(value); } } --- NEW FILE: package.html --- <body> This package defines proxy classes for all of the standard datatypes. This package was introduced in version 1.2 with the new run-time configuration code, which needs concrete proxy classes to add datatype support to a factory. Before 1.2, the <code>AttributeFactory</code> used annonymous classes to cut down on the total number of files in this project. </body> --- NEW FILE: AnyURIAttributeProxy.java --- /* * @(#)AnyURIAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AnyURIAttribute; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class AnyURIAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return AnyURIAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return AnyURIAttribute.getInstance(value); } } --- NEW FILE: DateAttributeProxy.java --- /* * @(#)DateAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.DateAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class DateAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return DateAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DateAttribute.getInstance(value); } } --- NEW FILE: Base64BinaryAttributeProxy.java --- /* * @(#)Base64BinaryAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.Base64BinaryAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class Base64BinaryAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return Base64BinaryAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return Base64BinaryAttribute.getInstance(value); } } --- NEW FILE: DateTimeAttributeProxy.java --- /* * @(#)DateTimeAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.DateTimeAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class DateTimeAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return DateTimeAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DateTimeAttribute.getInstance(value); } } --- NEW FILE: IntegerAttributeProxy.java --- /* * @(#)IntegerAttributeProxy.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.attr.proxy; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.IntegerAttribute; import org.w3c.dom.Node; /** * A proxy class that is provided mainly for the run-time configuration * code to use. * * @author Seth Proctor */ public class IntegerAttributeProxy implements AttributeProxy { public AttributeValue getInstance(Node root) throws Exception { return IntegerAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return IntegerAttribute.getInstance(value); } } |
From: Seth P. <se...@us...> - 2004-03-15 22:02:50
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15474/com/sun/xacml Added Files: ConfigurationStore.java Log Message: first version of a new run-time configuration system --- NEW FILE: ConfigurationStore.java --- /* * @(#)ConfigurationStore.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; import com.sun.xacml.attr.AttributeFactory; import com.sun.xacml.attr.AttributeProxy; import com.sun.xacml.attr.BaseAttributeFactory; import com.sun.xacml.attr.StandardAttributeFactory; import com.sun.xacml.combine.BaseCombiningAlgFactory; import com.sun.xacml.combine.CombiningAlgFactory; import com.sun.xacml.combine.CombiningAlgorithm; import com.sun.xacml.combine.StandardCombiningAlgFactory; import com.sun.xacml.cond.BaseFunctionFactory; import com.sun.xacml.cond.BasicFunctionFactoryProxy; import com.sun.xacml.cond.Function; import com.sun.xacml.cond.FunctionProxy; import com.sun.xacml.cond.FunctionFactory; import com.sun.xacml.cond.FunctionFactoryProxy; import com.sun.xacml.cond.StandardFunctionFactory; import com.sun.xacml.cond.cluster.FunctionCluster; import com.sun.xacml.finder.AttributeFinder; import com.sun.xacml.finder.PolicyFinder; import com.sun.xacml.finder.ResourceFinder; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.xml.sax.SAXException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * This class supports run-time loading of configuration data. It loads the * configurations from an XML file that conforms to the configuration schema. * By design this class does not get used automatically, nor does it change * the state of the system directly. A programmer must choose to support this * mechanism in their program, and then must explicitly use loaded elements. * This way, the programmer still has full control over their security model, * but also has the convenience of re-using a common configuration * mechanism. * <p> * Note that becuase this doesn't tie directly into the rest of the code, you * are still free to design your own run-time configuration mechanisms. This * is simply provided as a convenience, and so that all programmers can start * from a common point. * <p> * NOTE: The name of this class, its interfaces, and they way it interacts * with the rest of the code is currently unstable, so expect some changes * between now and the next release. * * @author Seth Proctor */ public class ConfigurationStore { /** * Property used to specify the configuration file. */ public static final String PDP_CONFIG_PROPERTY = "com.sun.xacml.PDPConfigFile"; /** * Identifier for the default named elements. */ public static final String DEFAULT_IDENTIFIER = "default"; // pdp elements private PDPConfig defaultPDPConfig; private HashMap pdpConfigMap; // attribute factory elements private AttributeFactory defaultAttributeFactory; private HashMap attributeMap; // combining algorithm factory elements private CombiningAlgFactory defaultCombiningFactory; private HashMap combiningMap; // function factory elements private FunctionFactoryProxy defaultFunctionFactoryProxy; private HashMap functionMap; /** * Default constructor. This constructor uses the * <code>PDP_CONFIG_PROPERTY</code> property to load the configuration. * If the property isn't set, if it names a file that can't be accessed, * or if the file is invalid, then an exception is thrown. * * @throws ParsingException if anything goes wrong during the parsing * of the configuration file, the class loading, * or the factory and pdp setup */ public ConfigurationStore() throws ParsingException { String configFile = System.getProperty(PDP_CONFIG_PROPERTY); // make sure that the right property was set if (configFile == null) { throw new ParsingException("Config property " + PDP_CONFIG_PROPERTY + " needs to be set"); } setupConfig(new File(configFile)); } /** * Constructor that explicitly specifies the configuration file to load. * This is useful if your security model doesn't allow the use of * properties, if you don't want to use a property to specify a * configuration file, or if you want to use more then one configuration * file. If the file can't be accessed, or if the file is invalid, then * an exception is thrown. * * @throws ParsingException if anything goes wrong during the parsing * of the configuration file, the class loading, * or the factory and pdp setup */ public ConfigurationStore(File configFile) throws ParsingException { setupConfig(configFile); } /** * Private helper function used by both constructors to actually load the * configuration data. This is the root of several private methods used * to setup all the pdps and factories. */ private void setupConfig(File configFile) throws ParsingException { Node root = null; System.out.println("Loading PDP configuration..."); // get the root node from the configuration file root = getRootNode(configFile); // initialize all the maps pdpConfigMap = new HashMap(); attributeMap = new HashMap(); combiningMap = new HashMap(); functionMap = new HashMap(); // loop through all the root-level elements, for each one getting its // name and then loading the right kind of element NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String childName = child.getNodeName(); String elementName = null; // get the element's name, or default to DEFAULT_IDENTIFIER NamedNodeMap attrMap = child.getAttributes(); if (attrMap == null) { elementName = DEFAULT_IDENTIFIER; } else { Node attr = attrMap.getNamedItem("name"); if (attr == null) elementName = DEFAULT_IDENTIFIER; else elementName = attr.getNodeValue(); } // see if this is a pdp or a factory, and load accordingly, // putting the new element into the respective map...make sure // that we're never loading something with the same name twice if (childName.equals("pdp")) { System.out.println(" Loading PDP \"" + elementName + "\"..."); if (pdpConfigMap.containsKey(elementName)) throw new ParsingException("more that one pdp with " + "name \"" + elementName +"\""); pdpConfigMap.put(elementName, parsePDPConfig(child)); System.out.println(" done"); } else if (childName.equals("attributeFactory")) { System.out.println(" Loading AttributeFactory \"" + elementName + "\"..."); if (attributeMap.containsKey(elementName)) throw new ParsingException("more that one " + "attributeFactory with name " + elementName +"\""); attributeMap.put(elementName, parseAttributeFactory(child)); System.out.println(" done"); } else if (childName.equals("combiningAlgFactory")) { System.out.println(" Loading CombiningAlgFactory \"" + elementName + "\"..."); if (combiningMap.containsKey(elementName)) throw new ParsingException("more that one " + "combiningAlgFactory with " + "name \"" + elementName +"\""); combiningMap.put(elementName, parseCombiningAlgFactory(child)); System.out.println(" done"); } else if (childName.equals("functionFactory")) { System.out.println(" Loading FunctionFactory \"" + elementName + "\"..."); if (functionMap.containsKey(elementName)) throw new ParsingException("more that one functionFactory" + " with name \"" + elementName +"\""); functionMap.put(elementName, parseFunctionFactory(child)); System.out.println(" done"); } } // finally, extract the default elements, if they were specified... // this is done as an optimizaion on the assumption that people will // call the getDefault* methods more than once, but may be removed // if that assumption proves to be incorrect in practice defaultPDPConfig = (PDPConfig)(pdpConfigMap.get(DEFAULT_IDENTIFIER)); defaultAttributeFactory = (AttributeFactory) (attributeMap.get(DEFAULT_IDENTIFIER)); defaultCombiningFactory = (CombiningAlgFactory) (combiningMap.get(DEFAULT_IDENTIFIER)); defaultFunctionFactoryProxy = (FunctionFactoryProxy) (functionMap.get(DEFAULT_IDENTIFIER)); } /** * Private helper that parses the file and sets up the DOM tree. * FIXME: add schema validation support before 1.2 is final */ private Node getRootNode(File configFile) throws ParsingException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); dbFactory.setIgnoringComments(true); dbFactory.setNamespaceAware(false); dbFactory.setValidating(false); DocumentBuilder db = null; try { db = dbFactory.newDocumentBuilder(); } catch (ParserConfigurationException pce) { throw new ParsingException("couldn't get a document builder", pce); } Document doc = null; try { doc = db.parse(new FileInputStream(configFile)); } catch (IOException ioe) { throw new ParsingException("failed to load the file ", ioe); } catch (SAXException saxe) { throw new ParsingException("error parsing the XML tree", saxe); } catch (IllegalArgumentException iae) { throw new ParsingException("no data to parse", iae); } Element root = doc.getDocumentElement(); if (! root.getTagName().equals("config")) throw new ParsingException("unknown document type: " + root.getTagName()); return root; } /** * Private helper that handles the pdp elements. */ private PDPConfig parsePDPConfig(Node root) throws ParsingException { ArrayList attrModules = new ArrayList(); HashSet policyModules = new HashSet(); ArrayList rsrcModules = new ArrayList(); // go through all elements of the pdp, loading the specified modules NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String name = child.getNodeName(); if (name.equals("policyFinderModule")) { policyModules.add(loadClass("module", child)); } else if (name.equals("attributeFinderModule")) { attrModules.add(loadClass("module", child)); } else if (name.equals("resourceFinderModule")) { rsrcModules.add(loadClass("module", child)); } } // after loading the modules, use the collections to setup a // PDPConfig based on this pdp element AttributeFinder attrFinder = new AttributeFinder(); attrFinder.setModules(attrModules); PolicyFinder policyFinder = new PolicyFinder(); policyFinder.setModules(policyModules); ResourceFinder rsrcFinder = new ResourceFinder(); rsrcFinder.setModules(rsrcModules); return new PDPConfig(attrFinder, policyFinder, rsrcFinder); } /** * Private helper that handles the attributeFactory elements. */ private AttributeFactory parseAttributeFactory(Node root) throws ParsingException { AttributeFactory factory = null; // check if we're starting with the standard factory setup if (useStandard(root, "useStandardDatatypes")) factory = StandardAttributeFactory.getNewFactory(); else factory = new BaseAttributeFactory(); // now look for all datatypes specified for this factory, adding // them as we go NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeName().equals("datatype")) { // a datatype is a class with an identifier String identifier = child.getAttributes(). getNamedItem("identifier").getNodeValue(); AttributeProxy proxy = (AttributeProxy)(loadClass("datatype", child)); try { factory.addDatatype(identifier, proxy); } catch (IllegalArgumentException iae) { throw new ParsingException("duplicate datatype: " + identifier, iae); } } } return factory; } /** * Private helper that handles the combiningAlgFactory elements. */ private CombiningAlgFactory parseCombiningAlgFactory(Node root) throws ParsingException { CombiningAlgFactory factory = null; // check if we're starting with the standard factory setup if (useStandard(root, "useStandardAlgorithms")) factory = StandardCombiningAlgFactory.getNewFactory(); else factory = new BaseCombiningAlgFactory(); // now look for all algorithms specified for this factory, adding // them as we go NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); if (child.getNodeName().equals("algorithm")) { // an algorithm is a simple class element CombiningAlgorithm alg = (CombiningAlgorithm)(loadClass("algorithm", child)); try { factory.addAlgorithm(alg); } catch (IllegalArgumentException iae) { throw new ParsingException("duplicate combining " + "algorithm: " + alg.getIdentifier().toString(), iae); } } } return factory; } /** * Private helper that handles the functionFactory elements. This one * is a little more complex than the other two factory helper methods, * since it consists of three factories (target, condition, and general). */ private FunctionFactoryProxy parseFunctionFactory(Node root) throws ParsingException { FunctionFactoryProxy proxy = null; FunctionFactory generalFactory = null; FunctionFactory conditionFactory = null; FunctionFactory targetFactory = null; // check if we're starting with the standard factory setup, and // make sure that the proxy is pre-configured if (useStandard(root, "useStandardFunctions")) { proxy = StandardFunctionFactory.getNewFactory(); targetFactory = proxy.getTargetFactory(); conditionFactory = proxy.getConditionFactory(); generalFactory = proxy.getGeneralFactory(); } else { generalFactory = new BaseFunctionFactory(); conditionFactory = new BaseFunctionFactory(generalFactory); targetFactory = new BaseFunctionFactory(conditionFactory); proxy = new BasicFunctionFactoryProxy(targetFactory, conditionFactory, generalFactory); } // go through and load the three sections, putting the loaded // functions into the appropriate factory NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String name = child.getNodeName(); if (name.equals("target")) { System.out.println(" [TARGET Functions]"); functionParserHelper(child, targetFactory); } else if (name.equals("condition")) { System.out.println(" [CONDITION Functions]"); functionParserHelper(child, conditionFactory); } else if (name.equals("general")) { System.out.println(" [GENERAL Functions]"); functionParserHelper(child, generalFactory); } } return proxy; } /** * Private helper used by the function factory code to load a specific * target, condition, or general section. */ private void functionParserHelper(Node root, FunctionFactory factory) throws ParsingException { // go through all elements in the section NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String name = child.getNodeName(); if (name.equals("function")) { // a function section is a simple class element Function function = (Function)(loadClass("function", child)); try { factory.addFunction(function); } catch (IllegalArgumentException iae) { throw new ParsingException("duplicate function", iae); } } else if (name.equals("abstractFunction")) { // an abstract function is a class with an identifier URI identifier = null; try { identifier = new URI(child.getAttributes(). getNamedItem("identifier"). getNodeValue()); } catch (URISyntaxException urise) { throw new ParsingException("invalid function identifier", urise); } FunctionProxy proxy = (FunctionProxy)(loadClass("abstract function", child)); try { factory.addAbstractFunction(proxy, identifier); } catch (IllegalArgumentException iae) { throw new ParsingException("duplicate abstract function", iae); } } else if (name.equals("functionCluster")) { // a cluster is a class that will give us a collection of // functions that need to be added one by one into the factory FunctionCluster cluster = (FunctionCluster)(loadClass("function cluster", child)); Iterator it = cluster.getSupportedFunctions().iterator(); while (it.hasNext()) { try { factory.addFunction((Function)(it.next())); } catch (IllegalArgumentException iae) { throw new ParsingException("duplicate function", iae); } } } } } /** * Private helper that is used by all the code to load an instance of * the given class...this assumes that the class is in the classpath, * both for simplicity and for stronger security */ private Object loadClass(String prefix, Node root) throws ParsingException { // get the name of the class String className = root.getAttributes().getNamedItem("class").getNodeValue(); System.out.print(" [ " + prefix + ": " + className + " "); // use the system classloader to load the given class ClassLoader cl = ClassLoader.getSystemClassLoader(); Class c = null; try { c = cl.loadClass(className); } catch (ClassNotFoundException cnfe) { throw new ParsingException("couldn't load class " + className, cnfe); } Object instance = null; // figure out if there are any parameters to the constructor if (! root.hasChildNodes()) { // we're using a null constructor, so this is easy try { instance = c.newInstance(); } catch (InstantiationException ie) { throw new ParsingException("couldn't instantiate " + className + " with empty constructor", ie); } catch (IllegalAccessException iae) { throw new ParsingException("couldn't get access to instance " + "of " + className, iae); } } else { // parse the arguments to the constructor List args = null; try { args = getArgs(root); } catch (IllegalArgumentException iae) { throw new ParsingException("illegal class arguments", iae); } int argLength = args.size(); // next we need to see if there's a constructor that matches the // arguments provided...this has to be done by hand since // Class.getConstructor(Class []) doesn't handle sub-classes and // generic types (for instance, a constructor taking List won't // match a parameter list containing ArrayList) // get the list of all available constructors Constructor [] cons = c.getConstructors(); Constructor constructor = null; for (int i = 0; i < cons.length; i++) { // get the parameters for this constructor Class [] params = cons[i].getParameterTypes(); if (params.length == argLength) { Iterator it = args.iterator(); int j = 0; // loop through the parameters and see if each one is // assignable from the coresponding input argument while (it.hasNext()) { if (! params[j].isAssignableFrom(it.next().getClass())) break; j++; } // if we looked at all the parameters, then this // constructor matches the input if (j == argLength) constructor = cons[i]; } // if we've found a matching constructor then stop looping if (constructor != null) break; } // make sure we found a matching constructor if (constructor == null) throw new ParsingException("couldn't find a matching " + "constructor"); // finally, instantiate the class try { instance = constructor.newInstance(args.toArray()); } catch (InstantiationException ie) { throw new ParsingException("couldn't instantiate " + className, ie); } catch (IllegalAccessException iae) { throw new ParsingException("couldn't get access to instance " + "of " + className, iae); } catch (InvocationTargetException ite) { throw new ParsingException("couldn't create " + className, ite); } } System.out.println("]"); return instance; } /** * Private helper that gets the constructor arguments for a given class. * Right now this just supports String and List, but it's trivial to * add support for other types...the question is what types are needed. * FIXME: decide on what types will be supported */ private List getArgs(Node root) { List args = new ArrayList(); NodeList children = root.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); String name = child.getNodeName(); if (child.getNodeType() == Node.ELEMENT_NODE) { if (name.equals("string")) { args.add(child.getFirstChild().getNodeValue()); } else if (name.equals("list")) { args.add(getArgs(child)); } else { throw new IllegalArgumentException("unkown arg type: " + name); } } } return args; } /** * Private helper used by the three factory routines to see if the * given factory should be based on the standard setup */ private boolean useStandard(Node node, String attributeName) { NamedNodeMap map = node.getAttributes(); if (map == null) return true; Node attrNode = map.getNamedItem(attributeName); if (attrNode == null) return true; return attrNode.getNodeValue().equals("true"); } /** * Returns the default PDP configuration. If no default was specified * then this throws an exception. * * @return the default PDP configuration * * @throws UnknownIdentifierException if there is no default config */ public PDPConfig getDefaultPDPConfig() throws UnknownIdentifierException { if (defaultPDPConfig == null) throw new UnknownIdentifierException("no default available"); return defaultPDPConfig; } /** * Returns the PDP configuration with the given name. If no such * configuration exists then an exception is thrown. * * @return the matching PDP configuation * * @throws UnknownIdentifierException if the name is unknown */ public PDPConfig getPDPConfig(String name) throws UnknownIdentifierException { Object object = pdpConfigMap.get(name); if (object == null) throw new UnknownIdentifierException("unknown pdp: " + name); return (PDPConfig)object; } /** * Returns a set of identifiers representing each PDP configuration * available. * * @return a <code>Set</code> of <code>String</code>s */ public Set getSupportedPDPConfigurations() { return Collections.unmodifiableSet(pdpConfigMap.keySet()); } /** * Returns the default attribute factory. If no default was specified * then this throws an exception. * * @return the default attribute factory * * @throws UnknownIdentifierException if there is no default factory */ public AttributeFactory getDefaultAttributeFactory() throws UnknownIdentifierException { if (defaultAttributeFactory == null) throw new UnknownIdentifierException("no default available"); return defaultAttributeFactory; } /** * Returns the attribute factory with the given name. If no such * factory exists then an exception is thrown. * * @return the matching attribute factory * * @throws UnknownIdentifierException if the name is unknown */ public AttributeFactory getAttributeFactory(String name) throws UnknownIdentifierException { Object object = attributeMap.get(name); if (object == null) throw new UnknownIdentifierException("unknown factory: " + name); return (AttributeFactory)object; } /** * Returns a set of identifiers representing each attribute factory * available. * * @return a <code>Set</code> of <code>String</code>s */ public Set getSupportedAttributeFactories() { return Collections.unmodifiableSet(attributeMap.keySet()); } /** * Returns the default combiningAlg factory. If no default was specified * then this throws an exception. * * @return the default combiningAlg factory * * @throws UnknownIdentifierException if there is no default factory */ public CombiningAlgFactory getDefaultCombiningAlgFactory() throws UnknownIdentifierException { if (defaultCombiningFactory == null) throw new UnknownIdentifierException("no default available"); return defaultCombiningFactory; } /** * Returns the combiningAlg factory with the given name. If no such * factory exists then an exception is thrown. * * @return the matching combiningAlg factory * * @throws UnknownIdentifierException if the name is unknown */ public CombiningAlgFactory getCombiningAlgFactory(String name) throws UnknownIdentifierException { Object object = combiningMap.get(name); if (object == null) throw new UnknownIdentifierException("unknown factory: " + name); return (CombiningAlgFactory)object; } /** * Returns a set of identifiers representing each combiningAlg factory * available. * * @return a <code>Set</code> of <code>String</code>s */ public Set getSupportedCombiningAlgFactories() { return Collections.unmodifiableSet(combiningMap.keySet()); } /** * Returns the default function factory proxy. If no default was specified * then this throws an exception. * * @return the default function factory proxy * * @throws UnknownIdentifierException if there is no default factory */ public FunctionFactoryProxy getDefaultFunctionFactoryProxy() throws UnknownIdentifierException { if (defaultFunctionFactoryProxy == null) throw new UnknownIdentifierException("no default available"); return defaultFunctionFactoryProxy; } /** * Returns the function factory proxy with the given name. If no such * proxy exists then an exception is thrown. * * @return the matching function factory proxy * * @throws UnknownIdentifierException if the name is unknown */ public FunctionFactoryProxy getFunctionFactoryProxy(String name) throws UnknownIdentifierException { Object object = functionMap.get(name); if (object == null) throw new UnknownIdentifierException("unknown factory: " + name); return (FunctionFactoryProxy)object; } /** * Returns a set of identifiers representing each function factory proxy * available. * * @return a <code>Set</code> of <code>String</code>s */ public Set getSupportedFunctionFactories() { return Collections.unmodifiableSet(functionMap.keySet()); } } |
From: Seth P. <se...@us...> - 2004-03-15 21:45:42
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11383/com/sun/xacml/finder/impl Modified Files: FilePolicyModule.java Log Message: added new constructor for run-time configuration Index: FilePolicyModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/FilePolicyModule.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FilePolicyModule.java 14 Aug 2003 21:35:45 -0000 1.2 --- FilePolicyModule.java 15 Mar 2004 21:36:29 -0000 1.3 *************** *** 55,58 **** --- 55,59 ---- import java.util.HashSet; import java.util.Iterator; + import java.util.List; import java.util.Set; *************** *** 151,154 **** --- 152,166 ---- /** + * Constructor that specifies a set of initial policy files to use. + * + */ + public FilePolicyModule(List fileNames) { + this(); + + if (fileNames != null) + this.fileNames.addAll(fileNames); + } + + /** * Indicates whether this module supports finding policies based on * a request (target matching). Since this module does support |
From: Seth P. <se...@us...> - 2004-03-15 21:44:04
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10845/com/sun/xacml/cond Modified Files: FunctionFactory.java StandardFunctionFactory.java Added Files: BaseFunctionFactory.java Log Message: setup new, more flexible factory scheme Index: StandardFunctionFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/StandardFunctionFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StandardFunctionFactory.java 13 Feb 2004 17:54:33 -0000 1.1 --- StandardFunctionFactory.java 15 Mar 2004 21:34:51 -0000 1.2 *************** *** 37,75 **** package com.sun.xacml.cond; ! import com.sun.xacml.ParsingException; ! import com.sun.xacml.UnknownIdentifierException; ! ! import com.sun.xacml.attr.BooleanAttribute; import java.net.URI; import java.net.URISyntaxException; - import java.util.Collection; import java.util.Iterator; - import java.util.HashMap; - - import org.w3c.dom.NamedNodeMap; - import org.w3c.dom.Node; /** * This factory supports the standard set of functions specified in XACML ! * 1.0 and 1.1. It is the default factory used by the system. * * @author Seth Proctor */ ! public class StandardFunctionFactory extends FunctionFactory { ! // internal identifiers for each of the three types private static final int TARGET_FACTORY = 0; private static final int CONDITION_FACTORY = 1; private static final int GENERAL_FACTORY = 2; - // the backing maps for the Function objects - private static HashMap targetFunctionMap = null; - private static HashMap conditionFunctionMap = null; - private static HashMap generalFunctionMap = null; - // the three singleton instances private static FunctionFactory targetFactory = null; --- 37,85 ---- package com.sun.xacml.cond; ! import com.sun.xacml.cond.cluster.AbsFunctionCluster; ! import com.sun.xacml.cond.cluster.AddFunctionCluster; ! import com.sun.xacml.cond.cluster.ComparisonFunctionCluster; ! import com.sun.xacml.cond.cluster.ConditionBagFunctionCluster; ! import com.sun.xacml.cond.cluster.ConditionSetFunctionCluster; ! import com.sun.xacml.cond.cluster.DateMathFunctionCluster; ! import com.sun.xacml.cond.cluster.DivideFunctionCluster; ! import com.sun.xacml.cond.cluster.EqualFunctionCluster; ! import com.sun.xacml.cond.cluster.FloorFunctionCluster; ! import com.sun.xacml.cond.cluster.GeneralBagFunctionCluster; ! import com.sun.xacml.cond.cluster.GeneralSetFunctionCluster; ! import com.sun.xacml.cond.cluster.HigherOrderFunctionCluster; ! import com.sun.xacml.cond.cluster.LogicalFunctionCluster; ! import com.sun.xacml.cond.cluster.MatchFunctionCluster; ! import com.sun.xacml.cond.cluster.ModFunctionCluster; ! import com.sun.xacml.cond.cluster.MultiplyFunctionCluster; ! import com.sun.xacml.cond.cluster.NOfFunctionCluster; ! import com.sun.xacml.cond.cluster.NotFunctionCluster; ! import com.sun.xacml.cond.cluster.NumericConvertFunctionCluster; ! import com.sun.xacml.cond.cluster.RoundFunctionCluster; ! import com.sun.xacml.cond.cluster.StringNormalizeFunctionCluster; ! import com.sun.xacml.cond.cluster.SubtractFunctionCluster; import java.net.URI; import java.net.URISyntaxException; import java.util.Iterator; /** * This factory supports the standard set of functions specified in XACML ! * 1.0 and 1.1. It is the default factory used by the system. Like the other ! * standard factories, there is only one instance used, so changing the ! * contents of one instance will affect all other instances. * * @author Seth Proctor */ ! public class StandardFunctionFactory extends BaseFunctionFactory { ! // internal identifiers for the three kinds of factories private static final int TARGET_FACTORY = 0; private static final int CONDITION_FACTORY = 1; private static final int GENERAL_FACTORY = 2; // the three singleton instances private static FunctionFactory targetFactory = null; *************** *** 77,90 **** private static FunctionFactory generalFactory = null; - /** - * A mapping of the three types from the *_FACTORY fields to their String - * representations. This is particularly useful for error messages. - */ - private static final String [] - NAMES = { "Target", "Condition", "General" }; - - // the type of this instance - private int factoryType; - // dummy object used as a lock for the getFactory routines // FIXME: this needs a better mechanism --- 87,90 ---- *************** *** 95,174 **** * maps are initialized correctly. */ ! private StandardFunctionFactory(int type) { ! factoryType = type; ! ! // first off, we always have to fill in the target map, since this ! // is the base that all three types use ! if (targetFunctionMap == null) { ! targetFunctionMap = new HashMap(); // add EqualFunction ! EqualFunction.addFunctions(targetFunctionMap); // add LogicalFunction ! LogicalFunction.addFunctions(targetFunctionMap); // add NOfFunction ! NOfFunction.addFunctions(targetFunctionMap); // add NotFunction ! NotFunction.addFunctions(targetFunctionMap); // add ComparisonFunction ! ComparisonFunction.addFunctions(targetFunctionMap); // add MatchFunction ! MatchFunction.addFunctions(targetFunctionMap); ! } ! ! // next, initialize the condition map if that's what kind we are (or ! // if we're a GENERAL, in which case we need all the functions) and if ! // it hasn't been initialized yet ! if (((type == CONDITION_FACTORY) || (type == GENERAL_FACTORY)) ! && (conditionFunctionMap == null)) { ! conditionFunctionMap = new HashMap(targetFunctionMap); ! // add condition functions from BagFunction ! BagFunction.addConditionFunctions(conditionFunctionMap); // add condition functions from SetFunction ! SetFunction.addConditionFunctions(conditionFunctionMap); // add condition functions from HigherOrderFunction ! HigherOrderFunction.addConditionFunctions(conditionFunctionMap); ! } ! ! // finally, initialize the general map if that's what kind we are and ! // if it hasn't been initialized yet ! if ((type == GENERAL_FACTORY) && (generalFunctionMap == null)) { ! generalFunctionMap = new HashMap(conditionFunctionMap); ! // add AddFunction ! AddFunction.addFunctions(generalFunctionMap); // add SubtractFunction ! SubtractFunction.addFunctions(generalFunctionMap); // add MultiplyFunction ! MultiplyFunction.addFunctions(generalFunctionMap); // add DivideFunction ! DivideFunction.addFunctions(generalFunctionMap); // add ModFunction ! ModFunction.addFunctions(generalFunctionMap); // add AbsFunction ! AbsFunction.addFunctions(generalFunctionMap); // add RoundFunction ! RoundFunction.addFunctions(generalFunctionMap); // add FloorFunction ! FloorFunction.addFunctions(generalFunctionMap); // add DateMathFunction ! DateMathFunction.addFunctions(generalFunctionMap); // add general functions from BagFunction ! BagFunction.addGeneralFunctions(generalFunctionMap); // add NumericConvertFunction ! NumericConvertFunction.addFunctions(generalFunctionMap); // add StringNormalizeFunction ! StringNormalizeFunction.addFunctions(generalFunctionMap); // add general functions from SetFunction ! SetFunction.addGeneralFunctions(generalFunctionMap); ! // add the map function ! generalFunctionMap.put(MapFunction.NAME, new FunctionProxy() { ! public Function getInstance(Node root, String xpathVersion) ! throws Exception { ! return MapFunction.getInstance(root); ! } ! }); } } --- 95,189 ---- * maps are initialized correctly. */ ! private StandardFunctionFactory(int type, FunctionFactory superset) { ! super(superset); + switch (type) { + case TARGET_FACTORY: // add EqualFunction ! addFunctions((new EqualFunctionCluster()).getSupportedFunctions(). ! iterator()); // add LogicalFunction ! addFunctions((new LogicalFunctionCluster()). ! getSupportedFunctions().iterator()); // add NOfFunction ! addFunctions((new NOfFunctionCluster()).getSupportedFunctions(). ! iterator()); // add NotFunction ! addFunctions((new NotFunctionCluster()).getSupportedFunctions(). ! iterator()); // add ComparisonFunction ! addFunctions((new ComparisonFunctionCluster()). ! getSupportedFunctions().iterator()); // add MatchFunction ! addFunctions((new MatchFunctionCluster()).getSupportedFunctions(). ! iterator()); ! break; ! case CONDITION_FACTORY: // add condition functions from BagFunction ! addFunctions((new ConditionBagFunctionCluster()). ! getSupportedFunctions().iterator()); // add condition functions from SetFunction ! addFunctions((new ConditionSetFunctionCluster()). ! getSupportedFunctions().iterator()); // add condition functions from HigherOrderFunction ! addFunctions((new HigherOrderFunctionCluster()). ! getSupportedFunctions().iterator()); ! break; ! case GENERAL_FACTORY: // add AddFunction ! addFunctions((new AddFunctionCluster()).getSupportedFunctions(). ! iterator()); // add SubtractFunction ! addFunctions((new SubtractFunctionCluster()). ! getSupportedFunctions().iterator()); // add MultiplyFunction ! addFunctions((new MultiplyFunctionCluster()). ! getSupportedFunctions().iterator()); // add DivideFunction ! addFunctions((new DivideFunctionCluster()).getSupportedFunctions(). ! iterator()); // add ModFunction ! addFunctions((new ModFunctionCluster()).getSupportedFunctions(). ! iterator()); // add AbsFunction ! addFunctions((new AbsFunctionCluster()).getSupportedFunctions(). ! iterator()); // add RoundFunction ! addFunctions((new RoundFunctionCluster()).getSupportedFunctions(). ! iterator()); // add FloorFunction ! addFunctions((new FloorFunctionCluster()).getSupportedFunctions(). ! iterator()); // add DateMathFunction ! addFunctions((new DateMathFunctionCluster()). ! getSupportedFunctions().iterator()); // add general functions from BagFunction ! addFunctions((new GeneralBagFunctionCluster()). ! getSupportedFunctions().iterator()); // add NumericConvertFunction ! addFunctions((new NumericConvertFunctionCluster()). ! getSupportedFunctions().iterator()); // add StringNormalizeFunction ! addFunctions((new StringNormalizeFunctionCluster()). ! getSupportedFunctions().iterator()); // add general functions from SetFunction ! addFunctions((new GeneralSetFunctionCluster()). ! getSupportedFunctions().iterator()); ! ! // add the map function's proxy ! try { ! addAbstractFunction(new MapFunctionProxy(), ! new URI(MapFunction.NAME)); ! } catch (URISyntaxException e) { ! // this shouldn't ever happen, but just in case... ! throw new IllegalArgumentException("invalid function name"); ! } ! break; ! } ! } ! private void addFunctions(Iterator it) { ! while (it.hasNext()) { ! addFunction((Function)(it.next())); } } *************** *** 176,180 **** /** * Returns a FunctionFactory that will only provide those functions that ! * are usable in Target matching. * * @return a <code>FunctionFactory</code> for target functions --- 191,200 ---- /** * Returns a FunctionFactory that will only provide those functions that ! * are usable in Target matching. This method enforces a singleton ! * model, meaning that this always returns the same instance, creating ! * the factory if it hasn't been requested before. This is the default ! * model used by the <code>FunctionFactory</code>, ensuring quick ! * access to this factory. If you need a new instance of this factory ! * you should use the <code>getNewFactory</code> method. * * @return a <code>FunctionFactory</code> for target functions *************** *** 184,189 **** synchronized (factoryLock) { if (targetFactory == null) ! targetFactory = ! new StandardFunctionFactory(TARGET_FACTORY); } } --- 204,208 ---- synchronized (factoryLock) { if (targetFactory == null) ! setupFactories(); } } *************** *** 194,199 **** /** * Returns a FuntionFactory that will only provide those functions that ! * are usable in the root of the Condition. These Functions are a superset ! * of the Target functions. * * @return a <code>FunctionFactory</code> for condition functions --- 213,223 ---- /** * Returns a FuntionFactory that will only provide those functions that ! * are usable in the root of the Condition. These Functions are a ! * superset of the Target functions. This method enforces a singleton ! * model, meaning that this always returns the same instance, creating ! * the factory if it hasn't been requested before. This is the default ! * model used by the <code>FunctionFactory</code>, ensuring quick ! * access to this factory. If you need a new instance of this factory ! * you should use the <code>getNewFactory</code> method. * * @return a <code>FunctionFactory</code> for condition functions *************** *** 203,208 **** synchronized (factoryLock) { if (conditionFactory == null) ! conditionFactory = ! new StandardFunctionFactory(CONDITION_FACTORY); } } --- 227,231 ---- synchronized (factoryLock) { if (conditionFactory == null) ! setupFactories(); } } *************** *** 213,217 **** /** * Returns a FunctionFactory that provides access to all the functions. ! * These Functions are a superset of the Condition functions. * * @return a <code>FunctionFactory</code> for all functions --- 236,245 ---- /** * Returns a FunctionFactory that provides access to all the functions. ! * These Functions are a superset of the Condition functions. This method ! * enforces a singleton model, meaning that this always returns the same ! * instance, creating the factory if it hasn't been requested before. ! * This is the default model used by the <code>FunctionFactory</code>, ! * ensuring quick access to this factory. If you need a new instance of ! * this factory you should use the <code>getNewFactory</code> method. * * @return a <code>FunctionFactory</code> for all functions *************** *** 221,226 **** synchronized (factoryLock) { if (generalFactory == null) ! generalFactory = ! new StandardFunctionFactory(GENERAL_FACTORY); } } --- 249,253 ---- synchronized (factoryLock) { if (generalFactory == null) ! setupFactories(); } } *************** *** 230,519 **** /** ! * Adds the function to the factory. Most functions have no state, so ! * the singleton model used here is typically desireable. The factory will ! * enforce the requirement that a Target or Condition matching function ! * must be boolean. ! * ! * @param function the <code>Function</code> to add to the factory ! * ! * @throws IllegalArgumentException if the function's identifier is already ! * used or if the function is non-boolean ! * (when this is a Target or Condition ! * factory) ! */ ! public void addFunction(Function function) ! throws IllegalArgumentException ! { ! addFunctionHelper(function, function.getIdentifier()); ! } ! ! /** ! * Adds the abstract function proxy to the factory. This is used for ! * those functions which have state, or change behavior (for instance ! * the standard map function, which changes its return type based on ! * how it is used). ! * ! * @param proxy the <code>FunctionProxy</code> to add to the factory ! * @param identity the function's identifier ! * ! * @throws IllegalArgumentException if the function's identifier is already ! * used ! */ ! public void addAbstractFunction(FunctionProxy proxy, ! URI identity) ! throws IllegalArgumentException ! { ! addFunctionHelper(proxy, identity); ! } ! ! /** ! * This is the first of 4 basic helpers used by the function addition ! * code. This method picks the right starting point based on what kind ! * of factory this is. ! */ ! private void addFunctionHelper(Object object, URI identity) { ! String id = identity.toString(); ! ! switch (factoryType) { ! case TARGET_FACTORY: ! addTargetFunctionHelper(object, id); ! break; ! case CONDITION_FACTORY: ! addConditionFunctionHelper(object, id); ! break; ! case GENERAL_FACTORY: ! addGeneralFunctionHelper(object, id); ! break; ! } ! } ! ! /** ! * Adds the function or proxy to the Target map if it can be added to ! * the other maps as well and if it's not already in the Target map. ! */ ! private void addTargetFunctionHelper(Object object, String id) ! throws IllegalArgumentException ! { ! // make sure this doesn't already exist ! if (targetFunctionMap.containsKey(id)) ! throw new IllegalArgumentException("function already exists"); ! ! // next, add to the Condition list, since all Target functions are ! // also availabe as Condition functions ! addConditionFunctionHelper(object, id); ! ! // finally, add it to our list ! targetFunctionMap.put(id, object); ! } ! ! /** ! * Adds the function or proxy to the Condition map if it can be added to ! * the General map as well and if it's not already in the Condition map. ! */ ! private void addConditionFunctionHelper(Object object, String id) ! throws IllegalArgumentException ! { ! // in case we haven't created the Condition factory, do it now ! getConditionFactory(); ! ! // make sure this doesn't already exist ! if (conditionFunctionMap.containsKey(id)) ! throw new IllegalArgumentException("function already exists"); ! ! // next, add to the General list, since all Condition functions are ! // also availabe as General functions ! addGeneralFunctionHelper(object, id); ! ! // finally, add it to our list ! conditionFunctionMap.put(id, object); ! } ! ! /** ! * Adds the function or proxy to the General map if it's not already in ! * that map. ! */ ! private void addGeneralFunctionHelper(Object object, String id) ! throws IllegalArgumentException ! { ! // in case we haven't created the General factory, do it now ! getGeneralFactory(); ! ! // make sure this doesn't already exist ! if (generalFunctionMap.containsKey(id)) ! throw new IllegalArgumentException("function already exists"); ! ! // now add it to our list ! generalFunctionMap.put(id, object); ! } ! ! /** ! * Tries to get an instance of the specified function. ! * ! * @param identity the name of the function ! * ! * @throws UnknownIdentifierException if the name isn't known ! * @throws FunctionTypeException if the name is known to map to an ! * abstract function, and should therefore ! * be created through createAbstractFunction ! */ ! public Function createFunction(URI identity) ! throws UnknownIdentifierException, FunctionTypeException ! { ! return createFunction(identity.toString()); ! } ! ! /** ! * Tries to get an instance of the specified function. ! * ! * @param identity the name of the function ! * ! * @throws UnknownIdentifierException if the name isn't known ! * @throws FunctionTypeException if the name is known to map to an ! * abstract function, and should therefore ! * be created through createAbstractFunction ! */ ! public Function createFunction(String identity) ! throws UnknownIdentifierException, FunctionTypeException ! { ! Object entry = createFunctionHelper(identity); ! ! if (entry != null) { ! if (entry instanceof Function) { ! return (Function)entry; ! } else { ! // this is actually a proxy, which means the other create ! // method should have been called ! throw new FunctionTypeException("function is abstract"); ! } ! } else { ! // we couldn't find a match ! throw new UnknownIdentifierException(NAMES[factoryType] + ! " functions of type " + ! identity + " not supported"); ! } ! } ! ! /** ! * Tries to get an instance of the specified abstract function. ! * ! * @param identity the name of the function ! * @param root the DOM root containing info used to create the function ! * ! * @throws UnknownIdentifierException if the name isn't known ! * @throws FunctionTypeException if the name is known to map to a ! * concrete function, and should therefore ! * be created through createFunction ! * @throws ParsingException if the function can't be created with the ! * given inputs ! */ ! public Function createAbstractFunction(URI identity, Node root) ! throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! return createAbstractFunction(identity.toString(), root, null); ! } ! ! /** ! * Tries to get an instance of the specified abstract function. ! * ! * @param identity the name of the function ! * @param root the DOM root containing info used to create the function ! * @param xpathVersion the version specified in the contianing policy, or ! * null if no version was specified ! * ! * @throws UnknownIdentifierException if the name isn't known ! * @throws FunctionTypeException if the name is known to map to a ! * concrete function, and should therefore ! * be created through createFunction ! * @throws ParsingException if the function can't be created with the ! * given inputs ! */ ! public Function createAbstractFunction(URI identity, Node root, ! String xpathVersion) ! throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! return createAbstractFunction(identity.toString(), root, xpathVersion); ! } ! ! /** ! * Tries to get an instance of the specified abstract function. ! * ! * @param identity the name of the function ! * @param root the DOM root containing info used to create the function ! * ! * @throws UnknownIdentifierException if the name isn't known ! * @throws FunctionTypeException if the name is known to map to a ! * concrete function, and should therefore ! * be created through createFunction ! * @throws ParsingException if the function can't be created with the ! * given inputs */ ! public Function createAbstractFunction(String identity, Node root) ! throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! return createAbstractFunction(identity, root, null); ! } ! /** ! * Tries to get an instance of the specified abstract function. ! * ! * @param identity the name of the function ! * @param root the DOM root containing info used to create the function ! * @param xpathVersion the version specified in the contianing policy, or ! * null if no version was specified ! * ! * @throws UnknownIdentifierException if the name isn't known ! * @throws FunctionTypeException if the name is known to map to a ! * concrete function, and should therefore ! * be created through createFunction ! * @throws ParsingException if the function can't be created with the ! * given inputs ! */ ! public Function createAbstractFunction(String identity, Node root, ! String xpathVersion) ! throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! Object entry = createFunctionHelper(identity); ! ! if (entry != null) { ! if (entry instanceof FunctionProxy) { ! try { ! return ((FunctionProxy)entry).getInstance(root, ! xpathVersion); ! } catch (Exception e) { ! throw new ParsingException("couldn't create abstract" + ! " function " + identity, e); ! } ! } else { ! // this is actually a concrete function, which means that ! // the other create method should have been called ! throw new FunctionTypeException("function is concrete"); ! } ! } else { ! // we couldn't find a match ! throw new UnknownIdentifierException(NAMES[factoryType] + ! " abstract functions of " + ! "type " + identity + ! " not supported"); ! } } /** ! * Looks in the right map for the given key */ ! private Object createFunctionHelper(String identity) { ! switch (factoryType) { ! case TARGET_FACTORY: ! return targetFunctionMap.get(identity); ! case CONDITION_FACTORY: ! return conditionFunctionMap.get(identity); ! case GENERAL_FACTORY: ! return generalFunctionMap.get(identity); ! } ! ! return null; } --- 257,284 ---- /** ! * Returns a new instance of <code>FunctionFactoryProxy</code> with ! * new factories that support all the standard functions. */ ! public static FunctionFactoryProxy getNewFactory() { ! StandardFunctionFactory general = ! new StandardFunctionFactory(GENERAL_FACTORY, null); ! StandardFunctionFactory condition = ! new StandardFunctionFactory(CONDITION_FACTORY, general); ! StandardFunctionFactory target = ! new StandardFunctionFactory(TARGET_FACTORY, condition); ! return new BasicFunctionFactoryProxy(target, condition, general); } /** ! * Private helper that sets up the three factory instances with the ! * right dependencies on each other. */ ! private static void setupFactories() { ! generalFactory = new StandardFunctionFactory(GENERAL_FACTORY, null); ! conditionFactory = new StandardFunctionFactory(CONDITION_FACTORY, ! generalFactory); ! targetFactory = new StandardFunctionFactory(TARGET_FACTORY, ! conditionFactory); } Index: FunctionFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/FunctionFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** FunctionFactory.java 13 Feb 2004 17:52:14 -0000 1.4 --- FunctionFactory.java 15 Mar 2004 21:34:51 -0000 1.5 *************** *** 132,136 **** * Adds the function to the factory. Most functions have no state, so * the singleton model used here is typically desireable. The factory will ! * enforce the requirement that a Target or Condition matching function * must be boolean. * --- 132,136 ---- * Adds the function to the factory. Most functions have no state, so * the singleton model used here is typically desireable. The factory will ! * not enforce the requirement that a Target or Condition matching function * must be boolean. * *************** *** 138,147 **** * * @throws IllegalArgumentException if the function's identifier is already ! * used or if the function is non-boolean ! * (when this is a Target or Condition ! * factory) */ ! public abstract void addFunction(Function function) ! throws IllegalArgumentException; /** --- 138,144 ---- * * @throws IllegalArgumentException if the function's identifier is already ! * used */ ! public abstract void addFunction(Function function); /** *************** *** 158,163 **** */ public abstract void addAbstractFunction(FunctionProxy proxy, ! URI identity) ! throws IllegalArgumentException; /** --- 155,159 ---- */ public abstract void addAbstractFunction(FunctionProxy proxy, ! URI identity); /** *************** *** 176,182 **** * @throws IllegalArgumentException if the name is already in use */ ! public static void addTargetFunction(Function function) ! throws IllegalArgumentException ! { getTargetInstance().addFunction(function); } --- 172,176 ---- * @throws IllegalArgumentException if the name is already in use */ ! public static void addTargetFunction(Function function) { getTargetInstance().addFunction(function); } *************** *** 199,205 **** */ public static void addAbstractTargetFunction(FunctionProxy proxy, ! URI identity) ! throws IllegalArgumentException ! { getTargetInstance().addAbstractFunction(proxy, identity); } --- 193,197 ---- */ public static void addAbstractTargetFunction(FunctionProxy proxy, ! URI identity) { getTargetInstance().addAbstractFunction(proxy, identity); } *************** *** 220,226 **** * @throws IllegalArgumentException if the name is already in use */ ! public static void addConditionFunction(Function function) ! throws IllegalArgumentException ! { getConditionInstance().addFunction(function); } --- 212,216 ---- * @throws IllegalArgumentException if the name is already in use */ ! public static void addConditionFunction(Function function) { getConditionInstance().addFunction(function); } *************** *** 243,249 **** */ public static void addAbstractConditionFunction(FunctionProxy proxy, ! URI identity) ! throws IllegalArgumentException ! { getConditionInstance().addAbstractFunction(proxy, identity); } --- 233,237 ---- */ public static void addAbstractConditionFunction(FunctionProxy proxy, ! URI identity) { getConditionInstance().addAbstractFunction(proxy, identity); } *************** *** 264,270 **** * @throws IllegalArgumentException if the name is already in use */ ! public static void addGeneralFunction(Function function) ! throws IllegalArgumentException ! { getGeneralInstance().addFunction(function); } --- 252,256 ---- * @throws IllegalArgumentException if the name is already in use */ ! public static void addGeneralFunction(Function function) { getGeneralInstance().addFunction(function); } *************** *** 287,293 **** */ public static void addAbstractGeneralFunction(FunctionProxy proxy, ! URI identity) ! throws IllegalArgumentException ! { getGeneralInstance().addAbstractFunction(proxy, identity); } --- 273,277 ---- */ public static void addAbstractGeneralFunction(FunctionProxy proxy, ! URI identity) { getGeneralInstance().addAbstractFunction(proxy, identity); } --- NEW FILE: BaseFunctionFactory.java --- /* * @(#)BaseCombiningAlgFactory.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.ParsingException; import com.sun.xacml.UnknownIdentifierException; import java.net.URI; import java.util.HashMap; import org.w3c.dom.Node; /** * This is a basic implementation of <code>FunctionFactory</code>. It * implements the insertion and retrieval methods, but it doesn't actually * setup the factory with any functions. It also assumes a certain model * with regard to the different kinds of functions (Target, Condition, and * General). For this reason, you may want to re-use this class, or you * may want to extend FunctionFactory directly, if you're writing a new * factory implementation. * * @author Seth Proctor */ public class BaseFunctionFactory extends FunctionFactory { // the backing maps for the Function objects private HashMap functionMap = null; // the superset factory chained to this factory private FunctionFactory superset = null; /** * Default constructor. No superset factory is used. */ public BaseFunctionFactory() { this(null); } /** * Constructor that sets a "superset factory." This is useful since * the different function factories (Target, Condition, and General) * have a superset relationship (Condition functions are a superset * of Target functions, etc.). Adding a function to this factory will * automatically add the same function to the superset factory. * * @param superset the superset factory or null */ public BaseFunctionFactory(FunctionFactory superset) { functionMap = new HashMap(); this.superset = superset; } /** * Adds the function to the factory. Most functions have no state, so * the singleton model used here is typically desireable. The factory will * not enforce the requirement that a Target or Condition matching function * must be boolean. * * @param function the <code>Function</code> to add to the factory * * @throws IllegalArgumentException if the function's identifier is already * used or if the function is non-boolean * (when this is a Target or Condition * factory) */ public void addFunction(Function function) throws IllegalArgumentException { String id = function.getIdentifier().toString(); // make sure this doesn't already exist if (functionMap.containsKey(id)) throw new IllegalArgumentException("function already exists"); // add to the superset factory if (superset != null) superset.addFunction(function); // finally, add to this factory functionMap.put(id, function); } /** * Adds the abstract function proxy to the factory. This is used for * those functions which have state, or change behavior (for instance * the standard map function, which changes its return type based on * how it is used). * * @param proxy the <code>FunctionProxy</code> to add to the factory * @param identity the function's identifier * * @throws IllegalArgumentException if the function's identifier is already * used */ public void addAbstractFunction(FunctionProxy proxy, URI identity) throws IllegalArgumentException { String id = identity.toString(); // make sure this doesn't already exist if (functionMap.containsKey(id)) throw new IllegalArgumentException("function already exists"); // add to the superset factory if (superset != null) superset.addAbstractFunction(proxy, identity); // finally, add to this factory functionMap.put(id, proxy); } /** * Tries to get an instance of the specified function. * * @param identity the name of the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to an * abstract function, and should therefore * be created through createAbstractFunction */ public Function createFunction(URI identity) throws UnknownIdentifierException, FunctionTypeException { return createFunction(identity.toString()); } /** * Tries to get an instance of the specified function. * * @param identity the name of the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to an * abstract function, and should therefore * be created through createAbstractFunction */ public Function createFunction(String identity) throws UnknownIdentifierException, FunctionTypeException { Object entry = functionMap.get(identity); if (entry != null) { if (entry instanceof Function) { return (Function)entry; } else { // this is actually a proxy, which means the other create // method should have been called throw new FunctionTypeException("function is abstract"); } } else { // we couldn't find a match throw new UnknownIdentifierException("functions of type " + identity + " are not "+ "supported by this factory"); } } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(URI identity, Node root) throws UnknownIdentifierException, ParsingException, FunctionTypeException { return createAbstractFunction(identity.toString(), root, null); } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * @param xpathVersion the version specified in the contianing policy, or * null if no version was specified * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(URI identity, Node root, String xpathVersion) throws UnknownIdentifierException, ParsingException, FunctionTypeException { return createAbstractFunction(identity.toString(), root, xpathVersion); } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(String identity, Node root) throws UnknownIdentifierException, ParsingException, FunctionTypeException { return createAbstractFunction(identity, root, null); } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * @param xpathVersion the version specified in the contianing policy, or * null if no version was specified * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(String identity, Node root, String xpathVersion) throws UnknownIdentifierException, ParsingException, FunctionTypeException { Object entry = functionMap.get(identity); if (entry != null) { if (entry instanceof FunctionProxy) { try { return ((FunctionProxy)entry).getInstance(root, xpathVersion); } catch (Exception e) { throw new ParsingException("couldn't create abstract" + " function " + identity, e); } } else { // this is actually a concrete function, which means that // the other create method should have been called throw new FunctionTypeException("function is concrete"); } } else { // we couldn't find a match throw new UnknownIdentifierException("abstract functions of " + "type " + identity + " are not supported by " + "this factory"); } } } |
From: Seth P. <se...@us...> - 2004-03-15 21:44:04
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10845/com/sun/xacml/combine Modified Files: CombiningAlgFactory.java StandardCombiningAlgFactory.java Added Files: BaseCombiningAlgFactory.java Log Message: setup new, more flexible factory scheme Index: CombiningAlgFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/CombiningAlgFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CombiningAlgFactory.java 13 Feb 2004 17:52:11 -0000 1.6 --- CombiningAlgFactory.java 15 Mar 2004 21:34:50 -0000 1.7 *************** *** 37,41 **** package com.sun.xacml.combine; - import com.sun.xacml.ProcessingException; import com.sun.xacml.UnknownIdentifierException; --- 37,40 ---- *************** *** 101,108 **** * @param alg the combining algorithm to add * ! * @throws ProcessingException if the algId is already registered */ ! public abstract void addAlgorithm(CombiningAlgorithm alg) ! throws ProcessingException; /** --- 100,106 ---- * @param alg the combining algorithm to add * ! * @throws IllegalArgumentException if the algorithm is already registered */ ! public abstract void addAlgorithm(CombiningAlgorithm alg); /** *************** *** 121,129 **** * @param alg the combining algorithm to add * ! * @throws ProcessingException if the algId is already registered */ ! public static void addCombiningAlg(CombiningAlgorithm alg) ! throws ProcessingException ! { getInstance().addAlgorithm(alg); } --- 119,125 ---- * @param alg the combining algorithm to add * ! * @throws IllegalArgumentException if the algorithm is already registered */ ! public static void addCombiningAlg(CombiningAlgorithm alg) { getInstance().addAlgorithm(alg); } Index: StandardCombiningAlgFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/StandardCombiningAlgFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StandardCombiningAlgFactory.java 13 Feb 2004 17:54:33 -0000 1.1 --- StandardCombiningAlgFactory.java 15 Mar 2004 21:34:51 -0000 1.2 *************** *** 37,55 **** package com.sun.xacml.combine; - import com.sun.xacml.ProcessingException; - import com.sun.xacml.UnknownIdentifierException; - - import java.net.URI; - - import java.util.HashMap; - /** ! * This factory supports the standard set of datatypes specified in XACML * 1.0 and 1.1. It is the default factory used by the system. * * @author Seth Proctor */ ! public class StandardCombiningAlgFactory extends CombiningAlgFactory { --- 37,48 ---- package com.sun.xacml.combine; /** ! * This factory supports the standard set of algorithms specified in XACML * 1.0 and 1.1. It is the default factory used by the system. * * @author Seth Proctor */ ! public class StandardCombiningAlgFactory extends BaseCombiningAlgFactory { *************** *** 57,63 **** private static StandardCombiningAlgFactory factoryInstance = null; - // the map of available combining algorithms - private HashMap algMap; - // dummy object used as a lock for the getFactory routine // FIXME: this needs a better mechanism --- 50,53 ---- *************** *** 68,73 **** */ private StandardCombiningAlgFactory() { - algMap = new HashMap(); - addAlgorithm(new DenyOverridesRuleAlg()); addAlgorithm(new DenyOverridesPolicyAlg()); --- 58,61 ---- *************** *** 89,94 **** /** ! * Returns the single instance of this factory, creating it if it doesn't ! * exist yet. * * @return the factory instance --- 77,86 ---- /** ! * Returns an instance of this factory. This method enforces a singleton ! * model, meaning that this always returns the same instance, creating ! * the factory if it hasn't been requested before. This is the default ! * model used by the <code>CombiningAlgFactory</code>, ensuring quick ! * access to this factory. If you need a new instance of this factory ! * you should use the <code>getNewFactory</code> method. * * @return the factory instance *************** *** 106,151 **** /** ! * Adds a combining algorithm to the factory. This single instance will ! * be returned to anyone who asks the factory for an algorithm with the ! * id given here. ! * ! * @param alg the combining algorithm to add ! * ! * @throws ProcessingException if the algId is already registered ! */ ! public void addAlgorithm(CombiningAlgorithm alg) ! throws ProcessingException ! { ! String algId = alg.getIdentifier().toString(); ! ! // check that the id doesn't already exist in the factory ! if (algMap.containsKey(algId)) ! throw new ProcessingException("algorithm already registered"); ! ! // add the algorithm ! algMap.put(algId, alg); ! } ! ! /** ! * Tries to return the correct combinging algorithm based on the ! * given algorithm ID. ! * ! * @param algId the identifier by which the algorithm is known ! * ! * @return a combining algorithm * ! * @throws UnknownIdentifierException algId is unknown */ ! public CombiningAlgorithm createAlgorithm(URI algId) ! throws UnknownIdentifierException ! { ! String id = algId.toString(); ! ! if (algMap.containsKey(id)) { ! return (CombiningAlgorithm)(algMap.get(algId.toString())); ! } else { ! throw new UnknownIdentifierException("unknown combining algId: " ! + id); ! } } --- 98,108 ---- /** ! * Returns a new instance of <code>CombiningAlgFactory</code> that ! * supports all the standard algorithms. * ! * @return a new <code>StandardCombiningAlgFactory</code> */ ! public static CombiningAlgFactory getNewFactory() { ! return new StandardCombiningAlgFactory(); } --- NEW FILE: BaseCombiningAlgFactory.java --- /* * @(#)BaseCombiningAlgFactory.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.combine; import com.sun.xacml.UnknownIdentifierException; import java.net.URI; import java.util.HashMap; /** * This is a basic implementation of <code>CombiningAlgFactory</code>. It * implements the insertion and retrieval methods, but doesn't actually * setup the factory with any algorithms. * * @author Seth Proctor */ public class BaseCombiningAlgFactory extends CombiningAlgFactory { // the map of available combining algorithms private HashMap algMap; /** * Default constructor. */ public BaseCombiningAlgFactory() { algMap = new HashMap(); } /** * Adds a combining algorithm to the factory. This single instance will * be returned to anyone who asks the factory for an algorithm with the * id given here. * * @param alg the combining algorithm to add * * @throws ProcessingException if the algId is already registered */ public void addAlgorithm(CombiningAlgorithm alg) { String algId = alg.getIdentifier().toString(); // check that the id doesn't already exist in the factory if (algMap.containsKey(algId)) throw new IllegalArgumentException("algorithm already registered"); // add the algorithm algMap.put(algId, alg); } /** * Tries to return the correct combinging algorithm based on the * given algorithm ID. * * @param algId the identifier by which the algorithm is known * * @return a combining algorithm * * @throws UnknownIdentifierException algId is unknown */ public CombiningAlgorithm createAlgorithm(URI algId) throws UnknownIdentifierException { String id = algId.toString(); if (algMap.containsKey(id)) { return (CombiningAlgorithm)(algMap.get(algId.toString())); } else { throw new UnknownIdentifierException("unknown combining algId: " + id); } } } |
From: Seth P. <se...@us...> - 2004-03-15 21:44:02
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10845/com/sun/xacml/attr Modified Files: AttributeFactory.java StandardAttributeFactory.java Added Files: BaseAttributeFactory.java Log Message: setup new, more flexible factory scheme Index: StandardAttributeFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/StandardAttributeFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StandardAttributeFactory.java 13 Feb 2004 17:54:33 -0000 1.1 --- StandardAttributeFactory.java 15 Mar 2004 21:34:50 -0000 1.2 *************** *** 37,48 **** package com.sun.xacml.attr; ! import com.sun.xacml.ParsingException; ! import com.sun.xacml.UnknownIdentifierException; ! ! import java.net.URI; ! ! import java.util.HashMap; - import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; --- 37,55 ---- package com.sun.xacml.attr; ! import com.sun.xacml.attr.proxy.AnyURIAttributeProxy; ! import com.sun.xacml.attr.proxy.Base64BinaryAttributeProxy; ! import com.sun.xacml.attr.proxy.BooleanAttributeProxy; ! import com.sun.xacml.attr.proxy.DateAttributeProxy; ! import com.sun.xacml.attr.proxy.DateTimeAttributeProxy; ! import com.sun.xacml.attr.proxy.DayTimeDurationAttributeProxy; ! import com.sun.xacml.attr.proxy.DoubleAttributeProxy; ! import com.sun.xacml.attr.proxy.HexBinaryAttributeProxy; ! import com.sun.xacml.attr.proxy.IntegerAttributeProxy; ! import com.sun.xacml.attr.proxy.RFC822NameAttributeProxy; ! import com.sun.xacml.attr.proxy.StringAttributeProxy; ! import com.sun.xacml.attr.proxy.TimeAttributeProxy; ! import com.sun.xacml.attr.proxy.YearMonthDurationAttributeProxy; ! import com.sun.xacml.attr.proxy.X500NameAttributeProxy; import org.w3c.dom.Node; *************** *** 54,58 **** * @author Seth Proctor */ ! public class StandardAttributeFactory extends AttributeFactory { --- 61,65 ---- * @author Seth Proctor */ ! public class StandardAttributeFactory extends BaseAttributeFactory { *************** *** 60,66 **** private static StandardAttributeFactory factoryInstance = null; - // the map of proxies - private HashMap attributeMap; - // dummy object used as a lock for the getFactory routine // FIXME: this needs a better mechanism --- 67,70 ---- *************** *** 72,224 **** */ private StandardAttributeFactory() { ! attributeMap = new HashMap(); ! ! // boolean ! attributeMap.put(BooleanAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return BooleanAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return BooleanAttribute.getInstance(value); ! } ! }); ! ! // date ! attributeMap.put(DateAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DateAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DateAttribute.getInstance(value); ! } ! }); ! ! // time ! attributeMap.put(TimeAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return TimeAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return TimeAttribute.getInstance(value); ! } ! }); ! ! // dateTime ! attributeMap.put(DateTimeAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DateTimeAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DateTimeAttribute.getInstance(value); ! } ! }); ! ! // dayTimeDuration ! attributeMap.put(DayTimeDurationAttribute.identifier, ! new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DayTimeDurationAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DayTimeDurationAttribute.getInstance(value); ! } ! }); ! ! // yearMonthDuration ! attributeMap.put(YearMonthDurationAttribute.identifier, ! new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return YearMonthDurationAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return YearMonthDurationAttribute.getInstance(value); ! } ! }); ! ! // double ! attributeMap.put(DoubleAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DoubleAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DoubleAttribute.getInstance(value); ! } ! }); ! ! // integer ! attributeMap.put(IntegerAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return IntegerAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return IntegerAttribute.getInstance(value); ! } ! }); ! ! // string ! attributeMap.put(StringAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) { ! return StringAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) { ! return StringAttribute.getInstance(value); ! } ! }); ! ! // anyURI ! attributeMap.put(AnyURIAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return AnyURIAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return AnyURIAttribute.getInstance(value); ! } ! }); ! ! // hexBinary ! attributeMap.put(HexBinaryAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return HexBinaryAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return HexBinaryAttribute.getInstance(value); ! } ! }); ! ! // base64Binary ! attributeMap.put(Base64BinaryAttribute.identifier, ! new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return Base64BinaryAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return Base64BinaryAttribute.getInstance(value); ! } ! }); ! ! // x500Name ! attributeMap.put(X500NameAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return X500NameAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return X500NameAttribute.getInstance(value); ! } ! }); ! ! // rfc822Name ! attributeMap.put(RFC822NameAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) { ! return RFC822NameAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) { ! return RFC822NameAttribute.getInstance(value); ! } ! }); } /** ! * Returns the single instance of this factory, creating it if it doesn't ! * exist yet. * * @return the factory instance --- 76,109 ---- */ private StandardAttributeFactory() { ! addDatatype(BooleanAttribute.identifier, new BooleanAttributeProxy()); ! addDatatype(StringAttribute.identifier, new StringAttributeProxy()); ! addDatatype(DateAttribute.identifier, new DateAttributeProxy()); ! addDatatype(TimeAttribute.identifier, new TimeAttributeProxy()); ! addDatatype(DateTimeAttribute.identifier, ! new DateTimeAttributeProxy()); ! addDatatype(DayTimeDurationAttribute.identifier, ! new DayTimeDurationAttributeProxy()); ! addDatatype(YearMonthDurationAttribute.identifier, ! new YearMonthDurationAttributeProxy()); ! addDatatype(DoubleAttribute.identifier, new DoubleAttributeProxy()); ! addDatatype(IntegerAttribute.identifier, new IntegerAttributeProxy()); ! addDatatype(AnyURIAttribute.identifier, new AnyURIAttributeProxy()); ! addDatatype(HexBinaryAttribute.identifier, ! new HexBinaryAttributeProxy()); ! addDatatype(Base64BinaryAttribute.identifier, ! new Base64BinaryAttributeProxy()); ! addDatatype(X500NameAttribute.identifier, ! new X500NameAttributeProxy()); ! addDatatype(RFC822NameAttribute.identifier, ! new RFC822NameAttributeProxy()); } /** ! * Returns an instance of this factory. This method enforces a singleton ! * model, meaning that this always returns the same instance, creating ! * the factory if it hasn't been requested before. This is the default ! * model used by the <code>AttributeFactory</code>, ensuring quick ! * access to this factory. If you need a new instance of this factory ! * you should use the <code>getNewFactory</code> method. * * @return the factory instance *************** *** 236,359 **** /** ! * Adds a proxy to the factory, which in turn will allow new attribute ! * types to be created using the factory. Typically the proxy is ! * provided as an anonymous class that simply calls the getInstance ! * methods (or something similar) of some <code>AttributeValue</code> ! * class. ! * ! * @param id the name of the attribute type ! * @param proxy the proxy used to create new attributes of the given type ! */ ! public void addDatatype(String id, AttributeProxy proxy) { ! attributeMap.put(id, proxy); ! } ! ! /** ! * Creates a value based on the given DOM root node. The type of the ! * attribute is assumed to be present in the node as an XAML attribute ! * named <code>DataType</code>, as is the case with the ! * AttributeValueType in the policy schema. The value is assumed to be ! * the first child of this node. ! * ! * @param root the DOM root of an attribute value ! * ! * @return a new <code>AttributeValue</code> ! * ! * @throws UnknownIdentifierException if the type in the node isn't ! * known to the factory ! * @throws ParsingException if the node is invalid or can't be parsed ! * by the appropriate proxy ! */ ! public AttributeValue createValue(Node root) ! throws UnknownIdentifierException, ParsingException ! { ! Node node = root.getAttributes().getNamedItem("DataType"); ! ! return createValue(root, node.getNodeValue()); ! } ! ! /** ! * Creates a value based on the given DOM root node and data type. ! * ! * @param root the DOM root of an attribute value ! * @param dataType the type of the attribute ! * ! * @return a new <code>AttributeValue</code> ! * ! * @throws UnknownIdentifierException if the data type isn't known to ! * the factory ! * @throws ParsingException if the node is invalid or can't be parsed ! * by the appropriate proxy ! */ ! public AttributeValue createValue(Node root, URI dataType) ! throws UnknownIdentifierException, ParsingException ! { ! return createValue(root, dataType.toString()); ! } ! ! /** ! * Creates a value based on the given DOM root node and data type. ! * ! * @param root the DOM root of an attribute value ! * @param type the type of the attribute ! * ! * @return a new <code>AttributeValue</code> ! * ! * @throws UnknownIdentifierException if the type isn't known to ! * the factory ! * @throws ParsingException if the node is invalid or can't be parsed ! * by the appropriate proxy ! */ ! public AttributeValue createValue(Node root, String type) ! throws UnknownIdentifierException, ParsingException ! { ! AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); ! ! if (proxy != null) { ! try { ! return proxy.getInstance(root); ! } catch (Exception e) { ! throw new ParsingException("couldn't create " + type + ! " attribute based on DOM node"); ! } ! } else { ! throw new UnknownIdentifierException("Attributes of type " + type + ! " aren't supported."); ! } ! } ! ! /** ! * Creates a value based on the given data type and text-encoded value. ! * Used primarily by code that does an XPath query to get an ! * attribute value, and then needs to turn the resulting value into ! * an Attribute class. ! * ! * @param dataType the type of the attribute ! * @param value the text-encoded representation of an attribute's value ! * ! * @return a new <code>AttributeValue</code> * ! * @throws UnknownIdentifierException if the data type isn't known to ! * the factory ! * @throws ParsingException if the text is invalid or can't be parsed ! * by the appropriate proxy */ ! public AttributeValue createValue(URI dataType, String value) ! throws UnknownIdentifierException, ParsingException ! { ! String type = dataType.toString(); ! AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); ! ! if (proxy != null) { ! try { ! return proxy.getInstance(value); ! } catch (Exception e) { ! throw new ParsingException("couldn't create " + type + ! " attribute from input: " + value); ! } ! } else { ! throw new UnknownIdentifierException("Attributes of type " + type + ! " aren't supported."); ! } } --- 121,131 ---- /** ! * Returns a new instance of <code>AttributeFactory</code> that ! * supports all the standard datatypes. * ! * @return a new <code>StandardAttributeFactory</code> */ ! public static AttributeFactory getNewFactory() { ! return new StandardAttributeFactory(); } --- NEW FILE: BaseAttributeFactory.java --- /* * @(#)BaseAttributeFactory.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.attr; import com.sun.xacml.ParsingException; import com.sun.xacml.UnknownIdentifierException; import java.net.URI; import java.util.HashMap; import org.w3c.dom.Node; /** * This is a basic implementation of <code>AttributeFactory</code>. It * implements the insertion and retrieval methods, but doesn't actually * setup the factory with any datatypes. * * @author Seth Proctor */ public class BaseAttributeFactory extends AttributeFactory { // the map of proxies private HashMap attributeMap; /** * Default constructor. */ public BaseAttributeFactory() { attributeMap = new HashMap(); } /** * Adds a proxy to the factory, which in turn will allow new attribute * types to be created using the factory. Typically the proxy is * provided as an anonymous class that simply calls the getInstance * methods (or something similar) of some <code>AttributeValue</code> * class. * * @param id the name of the attribute type * @param proxy the proxy used to create new attributes of the given type */ public void addDatatype(String id, AttributeProxy proxy) { // make sure this doesn't already exist if (attributeMap.containsKey(id)) throw new IllegalArgumentException("datatype already exists"); attributeMap.put(id, proxy); } /** * Creates a value based on the given DOM root node. The type of the * attribute is assumed to be present in the node as an XACML attribute * named <code>DataType</code>, as is the case with the * AttributeValueType in the policy schema. The value is assumed to be * the first child of this node. * * @param root the DOM root of an attribute value * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the type in the node isn't * known to the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(Node root) throws UnknownIdentifierException, ParsingException { Node node = root.getAttributes().getNamedItem("DataType"); return createValue(root, node.getNodeValue()); } /** * Creates a value based on the given DOM root node and data type. * * @param root the DOM root of an attribute value * @param dataType the type of the attribute * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the data type isn't known to * the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(Node root, URI dataType) throws UnknownIdentifierException, ParsingException { return createValue(root, dataType.toString()); } /** * Creates a value based on the given DOM root node and data type. * * @param root the DOM root of an attribute value * @param type the type of the attribute * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the type isn't known to * the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(Node root, String type) throws UnknownIdentifierException, ParsingException { AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); if (proxy != null) { try { return proxy.getInstance(root); } catch (Exception e) { throw new ParsingException("couldn't create " + type + " attribute based on DOM node"); } } else { throw new UnknownIdentifierException("Attributes of type " + type + " aren't supported."); } } /** * Creates a value based on the given data type and text-encoded value. * Used primarily by code that does an XPath query to get an * attribute value, and then needs to turn the resulting value into * an Attribute class. * * @param dataType the type of the attribute * @param value the text-encoded representation of an attribute's value * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the data type isn't known to * the factory * @throws ParsingException if the text is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(URI dataType, String value) throws UnknownIdentifierException, ParsingException { String type = dataType.toString(); AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); if (proxy != null) { try { return proxy.getInstance(value); } catch (Exception e) { throw new ParsingException("couldn't create " + type + " attribute from input: " + value); } } else { throw new UnknownIdentifierException("Attributes of type " + type + " aren't supported."); } } } Index: AttributeFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AttributeFactory.java 13 Feb 2004 17:52:10 -0000 1.4 --- AttributeFactory.java 15 Mar 2004 21:34:50 -0000 1.5 *************** *** 107,110 **** --- 107,112 ---- * @param id the name of the attribute type * @param proxy the proxy used to create new attributes of the given type + * + * @throws IllegalArgumentException if the given id is already in use */ public abstract void addDatatype(String id, AttributeProxy proxy); *************** *** 127,134 **** * @param id the name of the attribute type * @param proxy the proxy used to create new attributes of the given type */ public static void addAttributeProxy(String id, AttributeProxy proxy) { - // FIXME: this may have to change when the final mechanism is in - // place for the default factory... getInstance().addDatatype(id, proxy); } --- 129,136 ---- * @param id the name of the attribute type * @param proxy the proxy used to create new attributes of the given type + * + * @throws IllegalArgumentException if the given id is already in use */ public static void addAttributeProxy(String id, AttributeProxy proxy) { getInstance().addDatatype(id, proxy); } |
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/cluster In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7574/com/sun/xacml/cond/cluster Added Files: AbsFunctionCluster.java AddFunctionCluster.java ComparisonFunctionCluster.java ConditionBagFunctionCluster.java ConditionSetFunctionCluster.java DateMathFunctionCluster.java DivideFunctionCluster.java EqualFunctionCluster.java FloorFunctionCluster.java FunctionCluster.java GeneralBagFunctionCluster.java GeneralSetFunctionCluster.java HigherOrderFunctionCluster.java LogicalFunctionCluster.java MatchFunctionCluster.java ModFunctionCluster.java MultiplyFunctionCluster.java NOfFunctionCluster.java NotFunctionCluster.java NumericConvertFunctionCluster.java RoundFunctionCluster.java StringNormalizeFunctionCluster.java SubtractFunctionCluster.java package.html Log Message: created new "cluster" for run-time configuration system --- NEW FILE: MatchFunctionCluster.java --- /* * @(#)MatchFunctionCluster.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.cluster; import com.sun.xacml.cond.MatchFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>MatchFunction</code>. * * @author Seth Proctor */ public class MatchFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new MatchFunction(MatchFunction.NAME_REGEXP_STRING_MATCH)); set.add(new MatchFunction(MatchFunction.NAME_X500NAME_MATCH)); set.add(new MatchFunction(MatchFunction.NAME_RFC822NAME_MATCH)); return set; } } --- NEW FILE: DivideFunctionCluster.java --- /* * @(#)DivideFunctionCluster.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.cluster; import com.sun.xacml.cond.DivideFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>DivideFunction</code>. * * @author Seth Proctor */ public class DivideFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new DivideFunction(DivideFunction.NAME_INTEGER_DIVIDE)); set.add(new DivideFunction(DivideFunction.NAME_DOUBLE_DIVIDE)); return set; } } --- NEW FILE: NOfFunctionCluster.java --- /* * @(#)NOfFunctionCluster.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.cluster; import com.sun.xacml.cond.NOfFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>NOfFunction</code>. * * @author Seth Proctor */ public class NOfFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new NOfFunction(NOfFunction.NAME_N_OF)); return set; } } --- NEW FILE: EqualFunctionCluster.java --- /* * @(#)EqualFunctionCluster.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.cluster; import com.sun.xacml.cond.EqualFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>EqualFunction</code>. * * @author Seth Proctor */ public class EqualFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new EqualFunction(EqualFunction.NAME_STRING_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_BOOLEAN_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_INTEGER_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_DOUBLE_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_DATE_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_TIME_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_DATETIME_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_DAYTIME_DURATION_EQUAL)); set.add(new EqualFunction(EqualFunction. NAME_YEARMONTH_DURATION_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_ANYURI_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_X500NAME_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_RFC822NAME_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_HEXBINARY_EQUAL)); set.add(new EqualFunction(EqualFunction.NAME_BASE64BINARY_EQUAL)); return set; } } --- NEW FILE: StringNormalizeFunctionCluster.java --- /* * @(#)StringNormalizeFunctionCluster.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.cluster; import com.sun.xacml.cond.StringNormalizeFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by * <code>StringNormalizeFunction</code>. * * @author Seth Proctor */ public class StringNormalizeFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new StringNormalizeFunction(StringNormalizeFunction. NAME_STRING_NORMALIZE_SPACE)); set.add(new StringNormalizeFunction(StringNormalizeFunction. NAME_STRING_NORMALIZE_TO_LOWER_CASE)); return set; } } --- NEW FILE: MultiplyFunctionCluster.java --- /* * @(#)MultiplyFunctionCluster.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.cluster; import com.sun.xacml.cond.MultiplyFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>MultiplyFunction</code>. * * @author Seth Proctor */ public class MultiplyFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new MultiplyFunction(MultiplyFunction.NAME_INTEGER_MULTIPLY)); set.add(new MultiplyFunction(MultiplyFunction.NAME_DOUBLE_MULTIPLY)); return set; } } --- NEW FILE: package.html --- <body> This package defines the <code>FunctionCluster</code> interface that is used to define a cluster of functions that are all implemented by some common class. Also included in this package, as a convenience, are cluster classes for all the standard functions. These are used by the standard factory and by the run-time configuration system. </body> --- NEW FILE: GeneralSetFunctionCluster.java --- /* * @(#)GeneralSetFunctionCluster.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.cluster; import com.sun.xacml.cond.FunctionBase; import com.sun.xacml.cond.GeneralSetFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>GeneralSetFunction</code>. * * @author Seth Proctor */ public class GeneralSetFunctionCluster implements FunctionCluster { /** * A complete list of all the XACML datatypes supported by the Set * functions, using the "simple" form of the names (eg, string * instead of http://www.w3.org/2001/XMLSchema#string) */ private static String simpleTypes [] = { "string", "boolean", "integer", "double", "date", "dateTime", "time", "anyURI", "hexBinary", "base64Binary", "dayTimeDuration", "yearMonthDuration", "x500Name", "rfc822Name" }; public Set getSupportedFunctions() { Set set = new HashSet(); for (int i = 0; i < simpleTypes.length; i++) { String baseName = FunctionBase.FUNCTION_NS + simpleTypes[i]; set.add(new GeneralSetFunction(baseName + GeneralSetFunction. NAME_BASE_INTERSECTION)); set.add(new GeneralSetFunction(baseName + GeneralSetFunction. NAME_BASE_UNION)); } return set; } } --- NEW FILE: RoundFunctionCluster.java --- /* * @(#)RoundFunctionCluster.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.cluster; import com.sun.xacml.cond.RoundFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>RoundFunction</code>. * * @author Seth Proctor */ public class RoundFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new RoundFunction(RoundFunction.NAME_ROUND)); return set; } } --- NEW FILE: AbsFunctionCluster.java --- /* * @(#)AbsFunctionCluster.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.cluster; import com.sun.xacml.cond.AbsFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>AbsFunction</code>. * * @author Seth Proctor */ public class AbsFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new AbsFunction(AbsFunction.NAME_INTEGER_ABS)); set.add(new AbsFunction(AbsFunction.NAME_DOUBLE_ABS)); return set; } } --- NEW FILE: AddFunctionCluster.java --- /* * @(#)AddFunctionCluster.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.cluster; import com.sun.xacml.cond.AddFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>AddFunction</code>. * * @author Seth Proctor */ public class AddFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new AddFunction(AddFunction.NAME_INTEGER_ADD)); set.add(new AddFunction(AddFunction.NAME_DOUBLE_ADD)); return set; } } --- NEW FILE: ConditionSetFunctionCluster.java --- /* * @(#)ConditionSetFunctionCluster.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.cluster; import com.sun.xacml.cond.FunctionBase; import com.sun.xacml.cond.ConditionSetFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>ConditionSetFunction</code>. * * @author Seth Proctor */ public class ConditionSetFunctionCluster implements FunctionCluster { /** * A complete list of all the XACML datatypes supported by the Set * functions, using the "simple" form of the names (eg, string * instead of http://www.w3.org/2001/XMLSchema#string) */ private static String simpleTypes [] = { "string", "boolean", "integer", "double", "date", "dateTime", "time", "anyURI", "hexBinary", "base64Binary", "dayTimeDuration", "yearMonthDuration", "x500Name", "rfc822Name" }; public Set getSupportedFunctions() { Set set = new HashSet(); for (int i = 0; i < simpleTypes.length; i++) { String baseName = FunctionBase.FUNCTION_NS + simpleTypes[i]; set.add(new ConditionSetFunction(baseName + ConditionSetFunction. NAME_BASE_AT_LEAST_ONE_MEMBER_OF)); set.add(new ConditionSetFunction(baseName + ConditionSetFunction. NAME_BASE_SUBSET)); set.add(new ConditionSetFunction(baseName + ConditionSetFunction. NAME_BASE_SET_EQUALS)); } return set; } } --- NEW FILE: LogicalFunctionCluster.java --- /* * @(#)LogicalFunctionCluster.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.cluster; import com.sun.xacml.cond.LogicalFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>LogicalFunction</code>. * * @author Seth Proctor */ public class LogicalFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new LogicalFunction(LogicalFunction.NAME_OR)); set.add(new LogicalFunction(LogicalFunction.NAME_AND)); return set; } } --- NEW FILE: FunctionCluster.java --- /* * @(#)FunctionCluster.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.cluster; import java.util.Set; /** * Interface used by classes that support more than one function. It's a * common design model to have a single class support more than one XACML * function. In those cases, you should provide a proxy that implements * <code>FunctionCluster</code> in addition to the <code>Function</code>. * This is particularly important for the run-time configuration system, * which uses this interface to create "clusters" of functions and therefore * can use a smaller configuration file. * * @author Seth Proctor */ public interface FunctionCluster { /** * Returns a single instance of each of the functions supported by * some class. The <code>Set</code> must contain instances of * <code>Function</code>, and it must be both non-null and non-empty. * It may contain only a single <code>Function</code>. * <p> * Note that this is only used to return concrete <code>Function</code>s. * It may not be used to report abstract functions. * * @return the functions supported by this class */ public Set getSupportedFunctions(); } --- NEW FILE: SubtractFunctionCluster.java --- /* * @(#)SubtractFunctionCluster.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.cluster; import com.sun.xacml.cond.SubtractFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>SubtractFunction</code>. * * @author Seth Proctor */ public class SubtractFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new SubtractFunction(SubtractFunction.NAME_INTEGER_SUBTRACT)); set.add(new SubtractFunction(SubtractFunction.NAME_DOUBLE_SUBTRACT)); return set; } } --- NEW FILE: NotFunctionCluster.java --- /* * @(#)NotFunctionCluster.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.cluster; import com.sun.xacml.cond.NotFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>NotFunction</code>. * * @author Seth Proctor */ public class NotFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new NotFunction(NotFunction.NAME_NOT)); return set; } } --- NEW FILE: DateMathFunctionCluster.java --- /* * @(#)DateMathFunctionCluster.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.cluster; import com.sun.xacml.cond.DateMathFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>DateMathFunction</code>. * * @author Seth Proctor */ public class DateMathFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new DateMathFunction(DateMathFunction. NAME_DATETIME_ADD_DAYTIMEDURATION)); set.add(new DateMathFunction(DateMathFunction. NAME_DATETIME_SUBTRACT_DAYTIMEDURATION)); set.add(new DateMathFunction(DateMathFunction. NAME_DATETIME_ADD_YEARMONTHDURATION)); set.add(new DateMathFunction(DateMathFunction. NAME_DATETIME_SUBTRACT_YEARMONTHDURATION)); set.add(new DateMathFunction(DateMathFunction. NAME_DATE_ADD_YEARMONTHDURATION)); set.add(new DateMathFunction(DateMathFunction. NAME_DATE_SUBTRACT_YEARMONTHDURATION)); return set; } } --- NEW FILE: ModFunctionCluster.java --- /* * @(#)ModFunctionCluster.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.cluster; import com.sun.xacml.cond.ModFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>ModFunction</code>. * * @author Seth Proctor */ public class ModFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new ModFunction(ModFunction.NAME_INTEGER_MOD)); return set; } } --- NEW FILE: HigherOrderFunctionCluster.java --- /* * @(#)HigherOrderFunctionCluster.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.cluster; import com.sun.xacml.cond.HigherOrderFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>HigherOrderFunction</code>. * * @author Seth Proctor */ public class HigherOrderFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new HigherOrderFunction(HigherOrderFunction.NAME_ANY_OF)); set.add(new HigherOrderFunction(HigherOrderFunction.NAME_ALL_OF)); set.add(new HigherOrderFunction(HigherOrderFunction.NAME_ANY_OF_ANY)); set.add(new HigherOrderFunction(HigherOrderFunction.NAME_ALL_OF_ANY)); set.add(new HigherOrderFunction(HigherOrderFunction.NAME_ANY_OF_ALL)); set.add(new HigherOrderFunction(HigherOrderFunction.NAME_ALL_OF_ALL)); return set; } } --- NEW FILE: FloorFunctionCluster.java --- /* * @(#)FloorFunctionCluster.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.cluster; import com.sun.xacml.cond.FloorFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>FloorFunction</code>. * * @author Seth Proctor */ public class FloorFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new FloorFunction(FloorFunction.NAME_FLOOR)); return set; } } --- NEW FILE: ComparisonFunctionCluster.java --- /* * @(#)ComparisonFunctionCluster.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.cluster; import com.sun.xacml.cond.ComparisonFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>ComparisonFunction</code>. * * @author Seth Proctor */ public class ComparisonFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new ComparisonFunction(ComparisonFunction. NAME_INTEGER_GREATER_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_INTEGER_GREATER_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_INTEGER_LESS_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_INTEGER_LESS_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DOUBLE_GREATER_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DOUBLE_GREATER_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DOUBLE_LESS_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DOUBLE_LESS_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_STRING_GREATER_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_STRING_GREATER_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_STRING_LESS_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_STRING_LESS_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_TIME_GREATER_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_TIME_GREATER_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_TIME_LESS_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_TIME_LESS_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATETIME_GREATER_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATETIME_GREATER_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATETIME_LESS_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATETIME_LESS_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATE_GREATER_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATE_GREATER_THAN_OR_EQUAL)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATE_LESS_THAN)); set.add(new ComparisonFunction(ComparisonFunction. NAME_DATE_LESS_THAN_OR_EQUAL)); return set; } } --- NEW FILE: NumericConvertFunctionCluster.java --- /* * @(#)NumericConvertFunctionCluster.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.cluster; import com.sun.xacml.cond.NumericConvertFunction; import java.util.HashSet; import java.util.Set; /** * Clusters all the functions supported by <code>NumericConvertFunction</code>. * * @author Seth Proctor */ public class NumericConvertFunctionCluster implements FunctionCluster { public Set getSupportedFunctions() { Set set = new HashSet(); set.add(new NumericConvertFunction(NumericConvertFunction. NAME_DOUBLE_TO_INTEGER)); set.add(new NumericConvertFunction(NumericConvertFunction. NAME_INTEGER_TO_DOUBLE)); return set; } } --- NEW FILE: ConditionBagFunctionCluster.java --- /* * @(#)ConditionBagFunctionCluster.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 N... [truncated message content] |
From: Seth P. <se...@us...> - 2004-03-15 20:26:13
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/cluster In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24716/cluster Log Message: Directory /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/cluster added to the repository |
From: Seth P. <se...@us...> - 2004-03-15 20:25:53
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/proxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24631/proxy Log Message: Directory /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/proxy added to the repository |
From: <se...@us...> - 2004-02-13 18:55:42
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12041/com/sun/xacml/finder/impl Modified Files: SelectorModule.java Log Message: fixed to handle XML attributes correctly Index: SelectorModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/SelectorModule.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SelectorModule.java 13 Feb 2004 17:55:32 -0000 1.4 --- SelectorModule.java 13 Feb 2004 18:49:51 -0000 1.5 *************** *** 154,158 **** if ((nodeType == Node.CDATA_SECTION_NODE) || (nodeType == Node.COMMENT_NODE) || ! (nodeType == Node.TEXT_NODE)) { // there is no child to this node text = node.getNodeValue(); --- 154,159 ---- if ((nodeType == Node.CDATA_SECTION_NODE) || (nodeType == Node.COMMENT_NODE) || ! (nodeType == Node.TEXT_NODE) || ! (nodeType == Node.ATTRIBUTE_NODE)) { // there is no child to this node text = node.getNodeValue(); |
From: <se...@us...> - 2004-02-13 18:01:23
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31765/com/sun/xacml/finder/impl Modified Files: SelectorModule.java Log Message: updated to use new factory interfaces Index: SelectorModule.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/finder/impl/SelectorModule.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SelectorModule.java 29 Aug 2003 18:58:33 -0000 1.3 --- SelectorModule.java 13 Feb 2004 17:55:32 -0000 1.4 *************** *** 1,7 **** /* ! * @(#)SelectorModule.java 1.4 01/31/03 * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 1,7 ---- /* ! * @(#)SelectorModule.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 143,146 **** --- 143,147 ---- try { ArrayList list = new ArrayList(); + AttributeFactory attrFactory = AttributeFactory.getInstance(); for (int i = 0; i < matches.getLength(); i++) { *************** *** 161,165 **** } ! list.add(AttributeFactory.createAttribute(type, text)); } --- 162,166 ---- } ! list.add(attrFactory.createValue(type, text)); } |
From: <se...@us...> - 2004-02-13 18:01:22
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31765/com/sun/xacml/cond Modified Files: Apply.java ComparisonFunction.java EqualFunction.java Log Message: updated to use new factory interfaces Index: Apply.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/Apply.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Apply.java 29 Aug 2003 18:58:33 -0000 1.5 --- Apply.java 13 Feb 2004 17:55:32 -0000 1.6 *************** *** 1,7 **** /* ! * @(#)Apply.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 ---- /* ! * @(#)Apply.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 186,189 **** --- 186,191 ---- List evals = new ArrayList(); + AttributeFactory attrFactory = AttributeFactory.getInstance(); + NodeList nodes = root.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { *************** *** 195,199 **** } else if (name.equals("AttributeValue")) { try { ! evals.add(AttributeFactory.createAttribute(node)); } catch (UnknownIdentifierException uie) { throw new ParsingException("Unknown DataType", uie); --- 197,201 ---- } else if (name.equals("AttributeValue")) { try { ! evals.add(attrFactory.createValue(node)); } catch (UnknownIdentifierException uie) { throw new ParsingException("Unknown DataType", uie); Index: ComparisonFunction.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/ComparisonFunction.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ComparisonFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- ComparisonFunction.java 13 Feb 2004 17:55:32 -0000 1.2 *************** *** 1,7 **** /* ! * @(#)ComparisonFunction.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 ---- /* ! * @(#)ComparisonFunction.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 39,43 **** import com.sun.xacml.EvaluationCtx; - import com.sun.xacml.attr.AttributeFactory; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.BooleanAttribute; --- 39,42 ---- Index: EqualFunction.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/EqualFunction.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** EqualFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- EqualFunction.java 13 Feb 2004 17:55:32 -0000 1.2 *************** *** 1,7 **** /* ! * @(#)EqualFunction.java 1.20 01/30/03 * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 1,7 ---- /* ! * @(#)EqualFunction.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 40,44 **** import com.sun.xacml.attr.AnyURIAttribute; - import com.sun.xacml.attr.AttributeFactory; import com.sun.xacml.attr.AttributeValue; import com.sun.xacml.attr.Base64BinaryAttribute; --- 40,43 ---- |
From: <se...@us...> - 2004-02-13 18:01:22
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31765/com/sun/xacml Modified Files: AbstractPolicy.java Obligation.java TargetMatch.java Log Message: updated to use new factory interfaces Index: AbstractPolicy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractPolicy.java 7 Jan 2004 21:31:18 -0000 1.7 --- AbstractPolicy.java 13 Feb 2004 17:55:32 -0000 1.8 *************** *** 1,7 **** /* ! * @(#)AbstractPolicy.java 1.12 01/30/03 * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 1,7 ---- /* ! * @(#)AbstractPolicy.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 182,186 **** URI algId = new URI(attrs.getNamedItem(combiningName). getNodeValue()); ! combiningAlg = CombiningAlgFactory.createCombiningAlg(algId); } catch (Exception e) { throw new ParsingException("Error parsing combining algorithm" + --- 182,187 ---- URI algId = new URI(attrs.getNamedItem(combiningName). getNodeValue()); ! CombiningAlgFactory factory = CombiningAlgFactory.getInstance(); ! combiningAlg = factory.createAlgorithm(algId); } catch (Exception e) { throw new ParsingException("Error parsing combining algorithm" + Index: Obligation.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/Obligation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Obligation.java 27 Oct 2003 04:44:01 -0000 1.3 --- Obligation.java 13 Feb 2004 17:55:32 -0000 1.4 *************** *** 3,7 **** * @(#)Obligation.java * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 3,7 ---- * @(#)Obligation.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 106,109 **** --- 106,110 ---- Set assignments = new HashSet(); + AttributeFactory attrFactory = AttributeFactory.getInstance(); NamedNodeMap attrs = root.getAttributes(); *************** *** 140,145 **** new URI(node.getAttributes(). getNamedItem("AttributeId").getNodeValue()); ! AttributeValue attrValue = ! AttributeFactory.createAttribute(node); assignments.add(new Attribute(attrId, null, null, attrValue)); --- 141,145 ---- new URI(node.getAttributes(). getNamedItem("AttributeId").getNodeValue()); ! AttributeValue attrValue = attrFactory.createValue(node); assignments.add(new Attribute(attrId, null, null, attrValue)); Index: TargetMatch.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/TargetMatch.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TargetMatch.java 29 Aug 2003 18:58:32 -0000 1.4 --- TargetMatch.java 13 Feb 2004 17:55:32 -0000 1.5 *************** *** 1,7 **** /* ! * @(#)TargetMatch.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 ---- /* ! * @(#)TargetMatch.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 156,159 **** --- 156,161 ---- AttributeValue attrValue = null; + AttributeFactory attrFactory = AttributeFactory.getInstance(); + // first off, figure out which of three types we are if (prefix.equals("Subject")) { *************** *** 203,207 **** } else if (name.equals("AttributeValue")) { try { ! attrValue = AttributeFactory.createAttribute(node); } catch (UnknownIdentifierException uie) { throw new ParsingException("Unknown Attribute Type", uie); --- 205,209 ---- } else if (name.equals("AttributeValue")) { try { ! attrValue = attrFactory.createValue(node); } catch (UnknownIdentifierException uie) { throw new ParsingException("Unknown Attribute Type", uie); |
From: <se...@us...> - 2004-02-13 18:01:22
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31765/com/sun/xacml/ctx Modified Files: Attribute.java Log Message: updated to use new factory interfaces Index: Attribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ctx/Attribute.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Attribute.java 27 Oct 2003 04:43:02 -0000 1.6 --- Attribute.java 13 Feb 2004 17:55:32 -0000 1.7 *************** *** 3,7 **** * @(#)Attribute.java * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 3,7 ---- * @(#)Attribute.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 135,138 **** --- 135,140 ---- AttributeValue value = null; + AttributeFactory attrFactory = AttributeFactory.getInstance(); + // First check that we're really parsing an Attribute if (! root.getNodeName().equals("Attribute")) { *************** *** 184,188 **** // now get the value try { ! value = AttributeFactory.createAttribute(node, type); } catch (UnknownIdentifierException uie) { throw new ParsingException("Unknown AttributeId", uie); --- 186,190 ---- // now get the value try { ! value = attrFactory.createValue(node, type); } catch (UnknownIdentifierException uie) { throw new ParsingException("Unknown AttributeId", uie); |
From: <se...@us...> - 2004-02-13 18:00:23
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31308/com/sun/xacml/attr Added Files: StandardAttributeFactory.java Log Message: introduced new, still unstable, factories for standard 1.0/1.1 behavior --- NEW FILE: StandardAttributeFactory.java --- /* * @(#)StandardAttributeFactory * * 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.attr; import com.sun.xacml.ParsingException; import com.sun.xacml.UnknownIdentifierException; import java.net.URI; import java.util.HashMap; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** * This factory supports the standard set of datatypes specified in XACML * 1.0 and 1.1. It is the default factory used by the system. * * @author Seth Proctor */ public class StandardAttributeFactory extends AttributeFactory { // the one instance of this factory private static StandardAttributeFactory factoryInstance = null; // the map of proxies private HashMap attributeMap; // dummy object used as a lock for the getFactory routine // FIXME: this needs a better mechanism private static Object factoryLock = new Object(); /** * Private constructor that sets up proxies for all of the standard * datatypes. */ private StandardAttributeFactory() { attributeMap = new HashMap(); // boolean attributeMap.put(BooleanAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return BooleanAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return BooleanAttribute.getInstance(value); } }); // date attributeMap.put(DateAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return DateAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DateAttribute.getInstance(value); } }); // time attributeMap.put(TimeAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return TimeAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return TimeAttribute.getInstance(value); } }); // dateTime attributeMap.put(DateTimeAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return DateTimeAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DateTimeAttribute.getInstance(value); } }); // dayTimeDuration attributeMap.put(DayTimeDurationAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return DayTimeDurationAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DayTimeDurationAttribute.getInstance(value); } }); // yearMonthDuration attributeMap.put(YearMonthDurationAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return YearMonthDurationAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return YearMonthDurationAttribute.getInstance(value); } }); // double attributeMap.put(DoubleAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return DoubleAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return DoubleAttribute.getInstance(value); } }); // integer attributeMap.put(IntegerAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return IntegerAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return IntegerAttribute.getInstance(value); } }); // string attributeMap.put(StringAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) { return StringAttribute.getInstance(root); } public AttributeValue getInstance(String value) { return StringAttribute.getInstance(value); } }); // anyURI attributeMap.put(AnyURIAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return AnyURIAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return AnyURIAttribute.getInstance(value); } }); // hexBinary attributeMap.put(HexBinaryAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return HexBinaryAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return HexBinaryAttribute.getInstance(value); } }); // base64Binary attributeMap.put(Base64BinaryAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return Base64BinaryAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return Base64BinaryAttribute.getInstance(value); } }); // x500Name attributeMap.put(X500NameAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) throws Exception { return X500NameAttribute.getInstance(root); } public AttributeValue getInstance(String value) throws Exception { return X500NameAttribute.getInstance(value); } }); // rfc822Name attributeMap.put(RFC822NameAttribute.identifier, new AttributeProxy() { public AttributeValue getInstance(Node root) { return RFC822NameAttribute.getInstance(root); } public AttributeValue getInstance(String value) { return RFC822NameAttribute.getInstance(value); } }); } /** * Returns the single instance of this factory, creating it if it doesn't * exist yet. * * @return the factory instance */ public static AttributeFactory getFactory() { if (factoryInstance == null) { synchronized (factoryLock) { if (factoryInstance == null) factoryInstance = new StandardAttributeFactory(); } } return factoryInstance; } /** * Adds a proxy to the factory, which in turn will allow new attribute * types to be created using the factory. Typically the proxy is * provided as an anonymous class that simply calls the getInstance * methods (or something similar) of some <code>AttributeValue</code> * class. * * @param id the name of the attribute type * @param proxy the proxy used to create new attributes of the given type */ public void addDatatype(String id, AttributeProxy proxy) { attributeMap.put(id, proxy); } /** * Creates a value based on the given DOM root node. The type of the * attribute is assumed to be present in the node as an XAML attribute * named <code>DataType</code>, as is the case with the * AttributeValueType in the policy schema. The value is assumed to be * the first child of this node. * * @param root the DOM root of an attribute value * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the type in the node isn't * known to the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(Node root) throws UnknownIdentifierException, ParsingException { Node node = root.getAttributes().getNamedItem("DataType"); return createValue(root, node.getNodeValue()); } /** * Creates a value based on the given DOM root node and data type. * * @param root the DOM root of an attribute value * @param dataType the type of the attribute * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the data type isn't known to * the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(Node root, URI dataType) throws UnknownIdentifierException, ParsingException { return createValue(root, dataType.toString()); } /** * Creates a value based on the given DOM root node and data type. * * @param root the DOM root of an attribute value * @param type the type of the attribute * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the type isn't known to * the factory * @throws ParsingException if the node is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(Node root, String type) throws UnknownIdentifierException, ParsingException { AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); if (proxy != null) { try { return proxy.getInstance(root); } catch (Exception e) { throw new ParsingException("couldn't create " + type + " attribute based on DOM node"); } } else { throw new UnknownIdentifierException("Attributes of type " + type + " aren't supported."); } } /** * Creates a value based on the given data type and text-encoded value. * Used primarily by code that does an XPath query to get an * attribute value, and then needs to turn the resulting value into * an Attribute class. * * @param dataType the type of the attribute * @param value the text-encoded representation of an attribute's value * * @return a new <code>AttributeValue</code> * * @throws UnknownIdentifierException if the data type isn't known to * the factory * @throws ParsingException if the text is invalid or can't be parsed * by the appropriate proxy */ public AttributeValue createValue(URI dataType, String value) throws UnknownIdentifierException, ParsingException { String type = dataType.toString(); AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); if (proxy != null) { try { return proxy.getInstance(value); } catch (Exception e) { throw new ParsingException("couldn't create " + type + " attribute from input: " + value); } } else { throw new UnknownIdentifierException("Attributes of type " + type + " aren't supported."); } } } |
From: <se...@us...> - 2004-02-13 18:00:23
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31308/com/sun/xacml/cond Added Files: StandardFunctionFactory.java Log Message: introduced new, still unstable, factories for standard 1.0/1.1 behavior --- NEW FILE: StandardFunctionFactory.java --- /* * @(#)StandardFunctionFactory.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.ParsingException; import com.sun.xacml.UnknownIdentifierException; import com.sun.xacml.attr.BooleanAttribute; import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; import java.util.Iterator; import java.util.HashMap; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** * This factory supports the standard set of functions specified in XACML * 1.0 and 1.1. It is the default factory used by the system. * * @author Seth Proctor */ public class StandardFunctionFactory extends FunctionFactory { // internal identifiers for each of the three types private static final int TARGET_FACTORY = 0; private static final int CONDITION_FACTORY = 1; private static final int GENERAL_FACTORY = 2; // the backing maps for the Function objects private static HashMap targetFunctionMap = null; private static HashMap conditionFunctionMap = null; private static HashMap generalFunctionMap = null; // the three singleton instances private static FunctionFactory targetFactory = null; private static FunctionFactory conditionFactory = null; private static FunctionFactory generalFactory = null; /** * A mapping of the three types from the *_FACTORY fields to their String * representations. This is particularly useful for error messages. */ private static final String [] NAMES = { "Target", "Condition", "General" }; // the type of this instance private int factoryType; // dummy object used as a lock for the getFactory routines // FIXME: this needs a better mechanism private static Object factoryLock = new Object(); /** * Creates a new StandardFunctionFactory, making sure that the default * maps are initialized correctly. */ private StandardFunctionFactory(int type) { factoryType = type; // first off, we always have to fill in the target map, since this // is the base that all three types use if (targetFunctionMap == null) { targetFunctionMap = new HashMap(); // add EqualFunction EqualFunction.addFunctions(targetFunctionMap); // add LogicalFunction LogicalFunction.addFunctions(targetFunctionMap); // add NOfFunction NOfFunction.addFunctions(targetFunctionMap); // add NotFunction NotFunction.addFunctions(targetFunctionMap); // add ComparisonFunction ComparisonFunction.addFunctions(targetFunctionMap); // add MatchFunction MatchFunction.addFunctions(targetFunctionMap); } // next, initialize the condition map if that's what kind we are (or // if we're a GENERAL, in which case we need all the functions) and if // it hasn't been initialized yet if (((type == CONDITION_FACTORY) || (type == GENERAL_FACTORY)) && (conditionFunctionMap == null)) { conditionFunctionMap = new HashMap(targetFunctionMap); // add condition functions from BagFunction BagFunction.addConditionFunctions(conditionFunctionMap); // add condition functions from SetFunction SetFunction.addConditionFunctions(conditionFunctionMap); // add condition functions from HigherOrderFunction HigherOrderFunction.addConditionFunctions(conditionFunctionMap); } // finally, initialize the general map if that's what kind we are and // if it hasn't been initialized yet if ((type == GENERAL_FACTORY) && (generalFunctionMap == null)) { generalFunctionMap = new HashMap(conditionFunctionMap); // add AddFunction AddFunction.addFunctions(generalFunctionMap); // add SubtractFunction SubtractFunction.addFunctions(generalFunctionMap); // add MultiplyFunction MultiplyFunction.addFunctions(generalFunctionMap); // add DivideFunction DivideFunction.addFunctions(generalFunctionMap); // add ModFunction ModFunction.addFunctions(generalFunctionMap); // add AbsFunction AbsFunction.addFunctions(generalFunctionMap); // add RoundFunction RoundFunction.addFunctions(generalFunctionMap); // add FloorFunction FloorFunction.addFunctions(generalFunctionMap); // add DateMathFunction DateMathFunction.addFunctions(generalFunctionMap); // add general functions from BagFunction BagFunction.addGeneralFunctions(generalFunctionMap); // add NumericConvertFunction NumericConvertFunction.addFunctions(generalFunctionMap); // add StringNormalizeFunction StringNormalizeFunction.addFunctions(generalFunctionMap); // add general functions from SetFunction SetFunction.addGeneralFunctions(generalFunctionMap); // add the map function generalFunctionMap.put(MapFunction.NAME, new FunctionProxy() { public Function getInstance(Node root, String xpathVersion) throws Exception { return MapFunction.getInstance(root); } }); } } /** * Returns a FunctionFactory that will only provide those functions that * are usable in Target matching. * * @return a <code>FunctionFactory</code> for target functions */ public static FunctionFactory getTargetFactory() { if (targetFactory == null) { synchronized (factoryLock) { if (targetFactory == null) targetFactory = new StandardFunctionFactory(TARGET_FACTORY); } } return targetFactory; } /** * Returns a FuntionFactory that will only provide those functions that * are usable in the root of the Condition. These Functions are a superset * of the Target functions. * * @return a <code>FunctionFactory</code> for condition functions */ public static FunctionFactory getConditionFactory() { if (conditionFactory == null) { synchronized (factoryLock) { if (conditionFactory == null) conditionFactory = new StandardFunctionFactory(CONDITION_FACTORY); } } return conditionFactory; } /** * Returns a FunctionFactory that provides access to all the functions. * These Functions are a superset of the Condition functions. * * @return a <code>FunctionFactory</code> for all functions */ public static FunctionFactory getGeneralFactory() { if (generalFactory == null) { synchronized (factoryLock) { if (generalFactory == null) generalFactory = new StandardFunctionFactory(GENERAL_FACTORY); } } return generalFactory; } /** * Adds the function to the factory. Most functions have no state, so * the singleton model used here is typically desireable. The factory will * enforce the requirement that a Target or Condition matching function * must be boolean. * * @param function the <code>Function</code> to add to the factory * * @throws IllegalArgumentException if the function's identifier is already * used or if the function is non-boolean * (when this is a Target or Condition * factory) */ public void addFunction(Function function) throws IllegalArgumentException { addFunctionHelper(function, function.getIdentifier()); } /** * Adds the abstract function proxy to the factory. This is used for * those functions which have state, or change behavior (for instance * the standard map function, which changes its return type based on * how it is used). * * @param proxy the <code>FunctionProxy</code> to add to the factory * @param identity the function's identifier * * @throws IllegalArgumentException if the function's identifier is already * used */ public void addAbstractFunction(FunctionProxy proxy, URI identity) throws IllegalArgumentException { addFunctionHelper(proxy, identity); } /** * This is the first of 4 basic helpers used by the function addition * code. This method picks the right starting point based on what kind * of factory this is. */ private void addFunctionHelper(Object object, URI identity) { String id = identity.toString(); switch (factoryType) { case TARGET_FACTORY: addTargetFunctionHelper(object, id); break; case CONDITION_FACTORY: addConditionFunctionHelper(object, id); break; case GENERAL_FACTORY: addGeneralFunctionHelper(object, id); break; } } /** * Adds the function or proxy to the Target map if it can be added to * the other maps as well and if it's not already in the Target map. */ private void addTargetFunctionHelper(Object object, String id) throws IllegalArgumentException { // make sure this doesn't already exist if (targetFunctionMap.containsKey(id)) throw new IllegalArgumentException("function already exists"); // next, add to the Condition list, since all Target functions are // also availabe as Condition functions addConditionFunctionHelper(object, id); // finally, add it to our list targetFunctionMap.put(id, object); } /** * Adds the function or proxy to the Condition map if it can be added to * the General map as well and if it's not already in the Condition map. */ private void addConditionFunctionHelper(Object object, String id) throws IllegalArgumentException { // in case we haven't created the Condition factory, do it now getConditionFactory(); // make sure this doesn't already exist if (conditionFunctionMap.containsKey(id)) throw new IllegalArgumentException("function already exists"); // next, add to the General list, since all Condition functions are // also availabe as General functions addGeneralFunctionHelper(object, id); // finally, add it to our list conditionFunctionMap.put(id, object); } /** * Adds the function or proxy to the General map if it's not already in * that map. */ private void addGeneralFunctionHelper(Object object, String id) throws IllegalArgumentException { // in case we haven't created the General factory, do it now getGeneralFactory(); // make sure this doesn't already exist if (generalFunctionMap.containsKey(id)) throw new IllegalArgumentException("function already exists"); // now add it to our list generalFunctionMap.put(id, object); } /** * Tries to get an instance of the specified function. * * @param identity the name of the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to an * abstract function, and should therefore * be created through createAbstractFunction */ public Function createFunction(URI identity) throws UnknownIdentifierException, FunctionTypeException { return createFunction(identity.toString()); } /** * Tries to get an instance of the specified function. * * @param identity the name of the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to an * abstract function, and should therefore * be created through createAbstractFunction */ public Function createFunction(String identity) throws UnknownIdentifierException, FunctionTypeException { Object entry = createFunctionHelper(identity); if (entry != null) { if (entry instanceof Function) { return (Function)entry; } else { // this is actually a proxy, which means the other create // method should have been called throw new FunctionTypeException("function is abstract"); } } else { // we couldn't find a match throw new UnknownIdentifierException(NAMES[factoryType] + " functions of type " + identity + " not supported"); } } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(URI identity, Node root) throws UnknownIdentifierException, ParsingException, FunctionTypeException { return createAbstractFunction(identity.toString(), root, null); } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * @param xpathVersion the version specified in the contianing policy, or * null if no version was specified * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(URI identity, Node root, String xpathVersion) throws UnknownIdentifierException, ParsingException, FunctionTypeException { return createAbstractFunction(identity.toString(), root, xpathVersion); } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(String identity, Node root) throws UnknownIdentifierException, ParsingException, FunctionTypeException { return createAbstractFunction(identity, root, null); } /** * Tries to get an instance of the specified abstract function. * * @param identity the name of the function * @param root the DOM root containing info used to create the function * @param xpathVersion the version specified in the contianing policy, or * null if no version was specified * * @throws UnknownIdentifierException if the name isn't known * @throws FunctionTypeException if the name is known to map to a * concrete function, and should therefore * be created through createFunction * @throws ParsingException if the function can't be created with the * given inputs */ public Function createAbstractFunction(String identity, Node root, String xpathVersion) throws UnknownIdentifierException, ParsingException, FunctionTypeException { Object entry = createFunctionHelper(identity); if (entry != null) { if (entry instanceof FunctionProxy) { try { return ((FunctionProxy)entry).getInstance(root, xpathVersion); } catch (Exception e) { throw new ParsingException("couldn't create abstract" + " function " + identity, e); } } else { // this is actually a concrete function, which means that // the other create method should have been called throw new FunctionTypeException("function is concrete"); } } else { // we couldn't find a match throw new UnknownIdentifierException(NAMES[factoryType] + " abstract functions of " + "type " + identity + " not supported"); } } /** * Looks in the right map for the given key */ private Object createFunctionHelper(String identity) { switch (factoryType) { case TARGET_FACTORY: return targetFunctionMap.get(identity); case CONDITION_FACTORY: return conditionFunctionMap.get(identity); case GENERAL_FACTORY: return generalFunctionMap.get(identity); } return null; } } |
From: <se...@us...> - 2004-02-13 18:00:22
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31308/com/sun/xacml/combine Added Files: StandardCombiningAlgFactory.java Log Message: introduced new, still unstable, factories for standard 1.0/1.1 behavior --- NEW FILE: StandardCombiningAlgFactory.java --- /* * @(#)StandardCombiningAlgFactory.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.combine; import com.sun.xacml.ProcessingException; import com.sun.xacml.UnknownIdentifierException; import java.net.URI; import java.util.HashMap; /** * This factory supports the standard set of datatypes specified in XACML * 1.0 and 1.1. It is the default factory used by the system. * * @author Seth Proctor */ public class StandardCombiningAlgFactory extends CombiningAlgFactory { // the single factory instance private static StandardCombiningAlgFactory factoryInstance = null; // the map of available combining algorithms private HashMap algMap; // dummy object used as a lock for the getFactory routine // FIXME: this needs a better mechanism private static Object factoryLock = new Object(); /** * Default constructor. */ private StandardCombiningAlgFactory() { algMap = new HashMap(); addAlgorithm(new DenyOverridesRuleAlg()); addAlgorithm(new DenyOverridesPolicyAlg()); addAlgorithm(new OrderedDenyOverridesRuleAlg()); addAlgorithm(new OrderedDenyOverridesPolicyAlg()); addAlgorithm(new PermitOverridesRuleAlg()); addAlgorithm(new PermitOverridesPolicyAlg()); addAlgorithm(new OrderedPermitOverridesRuleAlg()); addAlgorithm(new OrderedPermitOverridesPolicyAlg()); addAlgorithm(new FirstApplicableRuleAlg()); addAlgorithm(new FirstApplicablePolicyAlg()); addAlgorithm(new OnlyOneApplicablePolicyAlg()); } /** * Returns the single instance of this factory, creating it if it doesn't * exist yet. * * @return the factory instance */ public static CombiningAlgFactory getFactory() { if (factoryInstance == null) { synchronized (factoryLock) { if (factoryInstance == null) factoryInstance = new StandardCombiningAlgFactory(); } } return factoryInstance; } /** * Adds a combining algorithm to the factory. This single instance will * be returned to anyone who asks the factory for an algorithm with the * id given here. * * @param alg the combining algorithm to add * * @throws ProcessingException if the algId is already registered */ public void addAlgorithm(CombiningAlgorithm alg) throws ProcessingException { String algId = alg.getIdentifier().toString(); // check that the id doesn't already exist in the factory if (algMap.containsKey(algId)) throw new ProcessingException("algorithm already registered"); // add the algorithm algMap.put(algId, alg); } /** * Tries to return the correct combinging algorithm based on the * given algorithm ID. * * @param algId the identifier by which the algorithm is known * * @return a combining algorithm * * @throws UnknownIdentifierException algId is unknown */ public CombiningAlgorithm createAlgorithm(URI algId) throws UnknownIdentifierException { String id = algId.toString(); if (algMap.containsKey(id)) { return (CombiningAlgorithm)(algMap.get(algId.toString())); } else { throw new UnknownIdentifierException("unknown combining algId: " + id); } } } |
From: <se...@us...> - 2004-02-13 17:58:44
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30760/com/sun/xacml/attr Modified Files: AttributeFactory.java Added Files: AttributeFactoryProxy.java Log Message: introducing new, pluggable, still unstable factory interfaces --- NEW FILE: AttributeFactoryProxy.java --- /* * @(#)AttributeFactoryProxy.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.attr; /** * A simple proxy interface used to install new * <code>AttributeFactory</code>s. * * @author Seth Proctor */ public interface AttributeFactoryProxy { /** * Returns an instance of the <code>AttributeFactory</code> for which * this is a proxy. * * @return an <code>AttributeFactory</code> instance */ public AttributeFactory getFactory(); } Index: AttributeFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/AttributeFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AttributeFactory.java 29 Aug 2003 18:56:48 -0000 1.3 --- AttributeFactory.java 13 Feb 2004 17:52:10 -0000 1.4 *************** *** 1,7 **** /* ! * @(#)AttributeFactory.java 1.21 01/31/03 * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 1,7 ---- /* ! * @(#)AttributeFactory.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 42,47 **** import java.net.URI; - import java.util.HashMap; - import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; --- 42,45 ---- *************** *** 49,221 **** /** ! * This factory can create <code>AttributeValue/code>s for all of the ! * standard attributes in XACML, and allows programmers to add new attribute ! * types. * * @author Seth Proctor * @author Marco Barreno */ ! public class AttributeFactory { ! // the map of proxies ! private static HashMap attributeMap; /** ! * The default types must always be available */ static { ! attributeMap = new HashMap(); ! ! // boolean ! attributeMap.put(BooleanAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return BooleanAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return BooleanAttribute.getInstance(value); ! } ! }); ! ! // date ! attributeMap.put(DateAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DateAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DateAttribute.getInstance(value); ! } ! }); ! ! // time ! attributeMap.put(TimeAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return TimeAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return TimeAttribute.getInstance(value); ! } ! }); ! ! // dateTime ! attributeMap.put(DateTimeAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DateTimeAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DateTimeAttribute.getInstance(value); ! } ! }); ! ! // dayTimeDuration ! attributeMap.put(DayTimeDurationAttribute.identifier, ! new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DayTimeDurationAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DayTimeDurationAttribute.getInstance(value); ! } ! }); ! ! // yearMonthDuration ! attributeMap.put(YearMonthDurationAttribute.identifier, ! new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return YearMonthDurationAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return YearMonthDurationAttribute.getInstance(value); ! } ! }); ! ! // double ! attributeMap.put(DoubleAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return DoubleAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return DoubleAttribute.getInstance(value); ! } ! }); ! ! // integer ! attributeMap.put(IntegerAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return IntegerAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return IntegerAttribute.getInstance(value); ! } ! }); ! ! // string ! attributeMap.put(StringAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) { ! return StringAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) { ! return StringAttribute.getInstance(value); ! } ! }); ! ! // anyURI ! attributeMap.put(AnyURIAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return AnyURIAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return AnyURIAttribute.getInstance(value); ! } ! }); ! ! // hexBinary ! attributeMap.put(HexBinaryAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return HexBinaryAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return HexBinaryAttribute.getInstance(value); ! } ! }); ! ! // base64Binary ! attributeMap.put(Base64BinaryAttribute.identifier, ! new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return Base64BinaryAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return Base64BinaryAttribute.getInstance(value); ! } ! }); ! ! // x500Name ! attributeMap.put(X500NameAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) throws Exception { ! return X500NameAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) throws Exception { ! return X500NameAttribute.getInstance(value); ! } ! }); ! // rfc822Name ! attributeMap.put(RFC822NameAttribute.identifier, new AttributeProxy() { ! public AttributeValue getInstance(Node root) { ! return RFC822NameAttribute.getInstance(root); ! } ! public AttributeValue getInstance(String value) { ! return RFC822NameAttribute.getInstance(value); ! } ! }); } /** ! * In this simple factory model we only have one instance of the factory, ! * and we don't need to expose this interface. */ ! private AttributeFactory() { } --- 47,99 ---- /** ! * This is an abstract factory class for creating XACML attribute values. ! * There may be any number of factories available in the system, though ! * there is always one default factory used by the core code. * * @author Seth Proctor * @author Marco Barreno */ ! public abstract class AttributeFactory { ! // the proxy used to get the default factory ! private static AttributeFactoryProxy defaultFactoryProxy; /** ! * static intialiazer that sets up the default factory proxy ! * NOTE: this will change when the right setup mechanism is in place */ static { ! defaultFactoryProxy = new AttributeFactoryProxy() { ! public AttributeFactory getFactory() { ! return StandardAttributeFactory.getFactory(); ! } ! }; ! }; ! /** ! * Default constructor. Used only by subclasses. ! */ ! protected AttributeFactory() { ! } /** ! * Returns the default factory. Depending on the default factory's ! * implementation, this may return a singleton instance or new instances ! * with each invokation. ! * ! * @return the default <code>AttributeFactory</code> */ ! public static final AttributeFactory getInstance() { ! return defaultFactoryProxy.getFactory(); ! } + /** + * Sets the default factory. Note that this is just a placeholder for + * now, and will be replaced with a more useful mechanism soon. + */ + public static final void setDefaultFactory(AttributeFactoryProxy proxy) { + defaultFactoryProxy = proxy; } *************** *** 230,235 **** * @param proxy the proxy used to create new attributes of the given type */ public static void addAttributeProxy(String id, AttributeProxy proxy) { ! attributeMap.put(id, proxy); } --- 108,135 ---- * @param proxy the proxy used to create new attributes of the given type */ + public abstract void addDatatype(String id, AttributeProxy proxy); + + /** + * Adds a proxy to the default factory, which in turn will allow new + * attribute types to be created using the factory. Typically the proxy + * is provided as an anonymous class that simply calls the getInstance + * methods (or something similar) of some <code>AttributeValue</code> + * class. + * + * @deprecated As of version 1.2, replaced by + * {@link #addDatatype(String,AttributeProxy)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param id the name of the attribute type + * @param proxy the proxy used to create new attributes of the given type + */ public static void addAttributeProxy(String id, AttributeProxy proxy) { ! // FIXME: this may have to change when the final mechanism is in ! // place for the default factory... ! getInstance().addDatatype(id, proxy); } *************** *** 250,259 **** * by the appropriate proxy */ public static AttributeValue createAttribute(Node root) throws UnknownIdentifierException, ParsingException { ! Node node = root.getAttributes().getNamedItem("DataType"); ! ! return createAttribute(root, node.getNodeValue()); } --- 150,184 ---- * by the appropriate proxy */ + public abstract AttributeValue createValue(Node root) + throws UnknownIdentifierException, ParsingException; + + /** + * Creates a value based on the given DOM root node. The type of the + * attribute is assumed to be present in the node as an XAML attribute + * named <code>DataType</code>, as is the case with the + * AttributeValueType in the policy schema. The value is assumed to be + * the first child of this node. This uses the default factory. + * + * @deprecated As of version 1.2, replaced by + * {@link #createValue(Node)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param root the DOM root of an attribute value + * + * @return a new <code>AttributeValue</code> + * + * @throws UnknownIdentifierException if the type in the node isn't + * known to the factory + * @throws ParsingException if the node is invalid or can't be parsed + * by the appropriate proxy + */ public static AttributeValue createAttribute(Node root) throws UnknownIdentifierException, ParsingException { ! return getInstance().createValue(root); } *************** *** 271,278 **** * by the appropriate proxy */ public static AttributeValue createAttribute(Node root, URI dataType) throws UnknownIdentifierException, ParsingException { ! return createAttribute(root, dataType.toString()); } --- 196,228 ---- * by the appropriate proxy */ + public abstract AttributeValue createValue(Node root, URI dataType) + throws UnknownIdentifierException, ParsingException; + + /** + * Creates a value based on the given DOM root node and data type. This + * uses the default factory. + * + * @deprecated As of version 1.2, replaced by + * {@link #createValue(Node,URI)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param root the DOM root of an attribute value + * @param dataType the type of the attribute + * + * @return a new <code>AttributeValue</code> + * + * @throws UnknownIdentifierException if the data type isn't known to + * the factory + * @throws ParsingException if the node is invalid or can't be parsed + * by the appropriate proxy + */ public static AttributeValue createAttribute(Node root, URI dataType) throws UnknownIdentifierException, ParsingException { ! return getInstance().createValue(root, dataType); } *************** *** 290,309 **** * by the appropriate proxy */ public static AttributeValue createAttribute(Node root, String type) throws UnknownIdentifierException, ParsingException { ! AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); ! ! if (proxy != null) { ! try { ! return proxy.getInstance(root); ! } catch (Exception e) { ! throw new ParsingException("couldn't create " + type + ! " attribute based on DOM node"); ! } ! } else { ! throw new UnknownIdentifierException("Attributes of type " + type + ! " aren't supported."); ! } } --- 240,272 ---- * by the appropriate proxy */ + public abstract AttributeValue createValue(Node root, String type) + throws UnknownIdentifierException, ParsingException; + + /** + * Creates a value based on the given DOM root node and data type. This + * uses the default factory. + * + * @deprecated As of version 1.2, replaced by + * {@link #createValue(Node,String)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param root the DOM root of an attribute value + * @param type the type of the attribute + * + * @return a new <code>AttributeValue</code> + * + * @throws UnknownIdentifierException if the type isn't known to + * the factory + * @throws ParsingException if the node is invalid or can't be parsed + * by the appropriate proxy + */ public static AttributeValue createAttribute(Node root, String type) throws UnknownIdentifierException, ParsingException { ! return getInstance().createValue(root, type); } *************** *** 324,344 **** * by the appropriate proxy */ public static AttributeValue createAttribute(URI dataType, String value) throws UnknownIdentifierException, ParsingException { ! String type = dataType.toString(); ! AttributeProxy proxy = (AttributeProxy)(attributeMap.get(type)); ! ! if (proxy != null) { ! try { ! return proxy.getInstance(value); ! } catch (Exception e) { ! throw new ParsingException("couldn't create " + type + ! " attribute from input: " + value); ! } ! } else { ! throw new UnknownIdentifierException("Attributes of type " + type + ! " aren't supported."); ! } } --- 287,321 ---- * by the appropriate proxy */ + public abstract AttributeValue createValue(URI dataType, String value) + throws UnknownIdentifierException, ParsingException; + + /** + * Creates a value based on the given data type and text-encoded value. + * Used primarily by code that does an XPath query to get an + * attribute value, and then needs to turn the resulting value into + * an Attribute class. This uses the default factory. + * + * @deprecated As of version 1.2, replaced by + * {@link #createValue(URI,String)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param dataType the type of the attribute + * @param value the text-encoded representation of an attribute's value + * + * @return a new <code>AttributeValue</code> + * + * @throws UnknownIdentifierException if the data type isn't known to + * the factory + * @throws ParsingException if the text is invalid or can't be parsed + * by the appropriate proxy + */ public static AttributeValue createAttribute(URI dataType, String value) throws UnknownIdentifierException, ParsingException { ! return getInstance().createValue(dataType, value); } |
From: <se...@us...> - 2004-02-13 17:58:04
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30760/com/sun/xacml/cond Modified Files: FunctionFactory.java Added Files: FunctionFactoryProxy.java Log Message: introducing new, pluggable, still unstable factory interfaces --- NEW FILE: FunctionFactoryProxy.java --- /* * @(#)FunctionFactoryProxy.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; /** * A simple proxy interface used to install new <code>FunctionFactory</code>s. * The three kinds of factory (Target, Condition, and General) are tied * together in this interface because implementors writing new factories * should always implement all three types and provide them together. * * @author Seth Proctor */ public interface FunctionFactoryProxy { /** * Returns the Target version of an instance of the * <code>FunctionFactory</code> for which this is a proxy. * * @return a <code>FunctionFactory</code> instance */ public FunctionFactory getTargetFactory(); /** * Returns the Condition version of an instance of the * <code>FunctionFactory</code> for which this is a proxy. * * @return a <code>FunctionFactory</code> instance */ public FunctionFactory getConditionFactory(); /** * Returns the General version of an instance of the * <code>FunctionFactory</code> for which this is a proxy. * * @return a <code>FunctionFactory</code> instance */ public FunctionFactory getGeneralFactory(); } Index: FunctionFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/FunctionFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FunctionFactory.java 27 Oct 2003 04:55:07 -0000 1.3 --- FunctionFactory.java 13 Feb 2004 17:52:14 -0000 1.4 *************** *** 3,7 **** * @(#)FunctionFactory.java * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 3,7 ---- * @(#)FunctionFactory.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 40,226 **** import com.sun.xacml.UnknownIdentifierException; - import com.sun.xacml.attr.BooleanAttribute; - import java.net.URI; - import java.net.URISyntaxException; - - import java.util.Collection; - import java.util.Iterator; - import java.util.HashMap; - import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; /** ! * Factory used to create all functions. There are three singleton factories: ! * a general factory, a condition factory, and a target factory, which provide ! * functions that can be used anywhere, only in a condition's root and only in ! * a target (respectively). The factories initially have all of the standard ! * XACML functions, and new functions can be added as needed. * <p> ! * Note that this factory is not thread safe, so care should be taken when ! * using this code in a multi-threaded application. Also note that all ! * functions, except for abstract functions, are singletons, so any instance ! * that is added to the factory will be the same one returned from the ! * create methods. This is done because most functions don't have state, so ! * there is no need to have more than one, or to spend the time creating ! * multiple instances that all do the same thing. * * @author Marco Barreno * @author Seth Proctor */ ! public class FunctionFactory { ! // the backing maps for the Function objects ! private static HashMap targetFunctionMap = null; ! private static HashMap conditionFunctionMap = null; ! private static HashMap generalFunctionMap = null; ! ! // the three singleton instances ! private static FunctionFactory targetFactory = null; ! private static FunctionFactory conditionFactory = null; ! private static FunctionFactory generalFactory = null; ! ! // internal identifiers for each of the three types ! private static final int TARGET_FACTORY = 0; ! private static final int CONDITION_FACTORY = 1; ! private static final int GENERAL_FACTORY = 2; ! ! // the names of the three types, used for error messages ! private static final String [] ! NAMES = { "Target", "Condition", "General" }; ! ! // the type of this instance ! private int factoryType; /** ! * Creates a new FunctionFactory, making sure that the default maps ! * are initialized correctly. */ ! private FunctionFactory(int which) { ! ! factoryType = which; ! ! // first off, we always have to fill in the target map, since this ! // is the base that all three types use ! if (targetFunctionMap == null) { ! targetFunctionMap = new HashMap(); ! ! // add EqualFunction ! EqualFunction.addFunctions(targetFunctionMap); ! // add LogicalFunction ! LogicalFunction.addFunctions(targetFunctionMap); ! // add NOfFunction ! NOfFunction.addFunctions(targetFunctionMap); ! // add NotFunction ! NotFunction.addFunctions(targetFunctionMap); ! // add ComparisonFunction ! ComparisonFunction.addFunctions(targetFunctionMap); ! // add MatchFunction ! MatchFunction.addFunctions(targetFunctionMap); ! } ! ! // next, initialize the condition map if that's what kind we are (or ! // if we're a GENERAL, in which case we need all the functions) and if ! // it hasn't been initialized yet ! if (((which == CONDITION_FACTORY) || (which == GENERAL_FACTORY)) ! && (conditionFunctionMap == null)) { ! conditionFunctionMap = new HashMap(targetFunctionMap); ! ! // add condition functions from BagFunction ! BagFunction.addConditionFunctions(conditionFunctionMap); ! // add condition functions from SetFunction ! SetFunction.addConditionFunctions(conditionFunctionMap); ! // add condition functions from HigherOrderFunction ! HigherOrderFunction.addConditionFunctions(conditionFunctionMap); ! } ! ! // finally, initialize the general map if that's what kind we are and ! // if it hasn't been initialized yet ! if ((which == GENERAL_FACTORY) && (generalFunctionMap == null)) { ! generalFunctionMap = new HashMap(conditionFunctionMap); ! // add AddFunction ! AddFunction.addFunctions(generalFunctionMap); ! // add SubtractFunction ! SubtractFunction.addFunctions(generalFunctionMap); ! // add MultiplyFunction ! MultiplyFunction.addFunctions(generalFunctionMap); ! // add DivideFunction ! DivideFunction.addFunctions(generalFunctionMap); ! // add ModFunction ! ModFunction.addFunctions(generalFunctionMap); ! // add AbsFunction ! AbsFunction.addFunctions(generalFunctionMap); ! // add RoundFunction ! RoundFunction.addFunctions(generalFunctionMap); ! // add FloorFunction ! FloorFunction.addFunctions(generalFunctionMap); ! // add DateMathFunction ! DateMathFunction.addFunctions(generalFunctionMap); ! // add general functions from BagFunction ! BagFunction.addGeneralFunctions(generalFunctionMap); ! // add NumericConvertFunction ! NumericConvertFunction.addFunctions(generalFunctionMap); ! // add StringNormalizeFunction ! StringNormalizeFunction.addFunctions(generalFunctionMap); ! // add general functions from SetFunction ! SetFunction.addGeneralFunctions(generalFunctionMap); - // add the map function - generalFunctionMap.put(MapFunction.NAME, new FunctionProxy() { - public Function getInstance(Node root, String xpathVersion) - throws Exception { - return MapFunction.getInstance(root); - } - }); - } } /** ! * Returns a FunctionFactory that will only provide those functions that ! * are usable in Target matching. * * @return a <code>FunctionFactory</code> for target functions */ ! public static FunctionFactory getTargetInstance() { ! if (targetFactory == null) ! targetFactory = new FunctionFactory(TARGET_FACTORY); ! ! return targetFactory; } /** ! * Returns a FuntionFactory that will only provide those functions that ! * are usable in the root of the Condition. These Functions are a superset ! * of the Target functions. * * @return a <code>FunctionFactory</code> for condition functions */ ! public static FunctionFactory getConditionInstance() { ! if (conditionFactory == null) ! conditionFactory = new FunctionFactory(CONDITION_FACTORY); ! ! return conditionFactory; } /** ! * Returns a FunctionFactory that provides access to all the functions. ! * These Functions are a superset of the Condition functions. * * @return a <code>FunctionFactory</code> for all functions */ ! public static FunctionFactory getGeneralInstance() { ! if (generalFactory == null) ! generalFactory = new FunctionFactory(GENERAL_FACTORY); ! return generalFactory; } /** * Adds a target function. * * @param function the function to add * --- 40,175 ---- import com.sun.xacml.UnknownIdentifierException; import java.net.URI; import org.w3c.dom.Node; /** ! * Factory used to create all functions. There are three kinds of factories: ! * general, condition, and target. These provide functions that can be used ! * anywhere, only in a condition's root and only in a target (respectively). * <p> ! * Note that all functions, except for abstract functions, are singletons, so ! * any instance that is added to a factory will be the same one returned ! * from the create methods. This is done because most functions don't have ! * state, so there is no need to have more than one, or to spend the time ! * creating multiple instances that all do the same thing. * * @author Marco Barreno * @author Seth Proctor */ ! public abstract class FunctionFactory { ! // the proxies used to get the default factorys ! private static FunctionFactoryProxy defaultFactoryProxy; /** ! * static intialiazer that sets up the default factory proxies ! * NOTE: this will change when the right setup mechanism is in place */ ! static { ! defaultFactoryProxy = new FunctionFactoryProxy() { ! public FunctionFactory getTargetFactory() { ! return StandardFunctionFactory.getTargetFactory(); ! } ! public FunctionFactory getConditionFactory() { ! return StandardFunctionFactory.getConditionFactory(); ! } ! public FunctionFactory getGeneralFactory() { ! return StandardFunctionFactory.getGeneralFactory(); ! } ! }; ! }; ! /** ! * Default constructor. Used only by subclasses. ! */ ! protected FunctionFactory() { } /** ! * Returns the default FunctionFactory that will only provide those ! * functions that are usable in Target matching. * * @return a <code>FunctionFactory</code> for target functions */ ! public static final FunctionFactory getTargetInstance() { ! return defaultFactoryProxy.getTargetFactory(); } /** ! * Returns the default FuntionFactory that will only provide those ! * functions that are usable in the root of the Condition. These Functions ! * are a superset of the Target functions. * * @return a <code>FunctionFactory</code> for condition functions */ ! public static final FunctionFactory getConditionInstance() { ! return defaultFactoryProxy.getConditionFactory(); } /** ! * Returns the default FunctionFactory that provides access to all the ! * functions. These Functions are a superset of the Condition functions. * * @return a <code>FunctionFactory</code> for all functions */ ! public static final FunctionFactory getGeneralInstance() { ! return defaultFactoryProxy.getGeneralFactory(); ! } ! /** ! * Sets the default factory. Note that this is just a placeholder for ! * now, and will be replaced with a more useful mechanism soon. ! */ ! public static final void setDefaultFactory(FunctionFactoryProxy proxy) { ! defaultFactoryProxy = proxy; } /** + * Adds the function to the factory. Most functions have no state, so + * the singleton model used here is typically desireable. The factory will + * enforce the requirement that a Target or Condition matching function + * must be boolean. + * + * @param function the <code>Function</code> to add to the factory + * + * @throws IllegalArgumentException if the function's identifier is already + * used or if the function is non-boolean + * (when this is a Target or Condition + * factory) + */ + public abstract void addFunction(Function function) + throws IllegalArgumentException; + + /** + * Adds the abstract function proxy to the factory. This is used for + * those functions which have state, or change behavior (for instance + * the standard map function, which changes its return type based on + * how it is used). + * + * @param proxy the <code>FunctionProxy</code> to add to the factory + * @param identity the function's identifier + * + * @throws IllegalArgumentException if the function's identifier is already + * used + */ + public abstract void addAbstractFunction(FunctionProxy proxy, + URI identity) + throws IllegalArgumentException; + + /** * Adds a target function. * + * @deprecated As of version 1.2, replaced by + * {@link #addFunction(Function)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * * @param function the function to add * *************** *** 230,234 **** throws IllegalArgumentException { ! addTargetFunctionHelper(function, function.getIdentifier()); } --- 179,183 ---- throws IllegalArgumentException { ! getTargetInstance().addFunction(function); } *************** *** 236,239 **** --- 185,196 ---- * Adds an abstract target function. * + * @deprecated As of version 1.2, replaced by + * {@link #addAbstractFunction(FunctionProxy,URI)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * * @param proxy the function proxy to add * @param identity the name of the function *************** *** 245,272 **** throws IllegalArgumentException { ! addTargetFunctionHelper(proxy, identity); ! } ! ! /** ! * Adds the given function, and makes sure all the other factories ! * also know about the new function. Throws an exception if the name ! * is already in use. ! */ ! private static void addTargetFunctionHelper(Object object, URI identity) ! throws IllegalArgumentException ! { ! // make sure that the single instance has been created ! getTargetInstance(); ! ! // make sure this doesn't already exist ! if (targetFunctionMap.containsKey(identity.toString())) ! throw new IllegalArgumentException("function already exists"); ! ! // next, add to the Condition list, since all Target functions are ! // also availabe as Condition functions ! addConditionFunctionHelper(object, identity); ! ! // finally, add it to our list ! targetFunctionMap.put(identity.toString(), object); } --- 202,206 ---- throws IllegalArgumentException { ! getTargetInstance().addAbstractFunction(proxy, identity); } *************** *** 274,277 **** --- 208,219 ---- * Adds a condition function. * + * @deprecated As of version 1.2, replaced by + * {@link #addFunction(Function)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * * @param function the function to add * *************** *** 281,285 **** throws IllegalArgumentException { ! addConditionFunctionHelper(function, function.getIdentifier()); } --- 223,227 ---- throws IllegalArgumentException { ! getConditionInstance().addFunction(function); } *************** *** 287,290 **** --- 229,240 ---- * Adds an abstract condition function. * + * @deprecated As of version 1.2, replaced by + * {@link #addAbstractFunction(FunctionProxy,URI)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * * @param proxy the function proxy to add * @param identity the name of the function *************** *** 296,323 **** throws IllegalArgumentException { ! addConditionFunctionHelper(proxy, identity); ! } ! ! /** ! * Adds the given function, and makes sure the general factory ! * also know about the new function. Throws an exception if the name ! * is already in use. ! */ ! private static void addConditionFunctionHelper(Object object, URI identity) ! throws IllegalArgumentException ! { ! // make sure that the single instance has been created ! getConditionInstance(); ! ! // make sure this doesn't already exist ! if (conditionFunctionMap.containsKey(identity.toString())) ! throw new IllegalArgumentException("function already exists"); ! ! // next, add to the General list, since all Condition functions are ! // also availabe as General functions ! addGeneralFunctionHelper(object, identity); ! ! // finally, add it to our list ! conditionFunctionMap.put(identity.toString(), object); } --- 246,250 ---- throws IllegalArgumentException { ! getConditionInstance().addAbstractFunction(proxy, identity); } *************** *** 325,328 **** --- 252,263 ---- * Adds a general function. * + * @deprecated As of version 1.2, replaced by + * {@link #addFunction(Function)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * * @param function the function to add * *************** *** 332,336 **** throws IllegalArgumentException { ! addGeneralFunctionHelper(function, function.getIdentifier()); } --- 267,271 ---- throws IllegalArgumentException { ! getGeneralInstance().addFunction(function); } *************** *** 338,341 **** --- 273,284 ---- * Adds an abstract general function. * + * @deprecated As of version 1.2, replaced by + * {@link #addAbstractFunction(FunctionProxy,URI)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * * @param proxy the function proxy to add * @param identity the name of the function *************** *** 347,369 **** throws IllegalArgumentException { ! addGeneralFunctionHelper(proxy, identity); ! } ! ! /** ! * Adds the given function. Throws an exception if the name is already ! * in use. ! */ ! private static void addGeneralFunctionHelper(Object object, URI identity) ! throws IllegalArgumentException ! { ! // make sure that the single instance has been created ! getGeneralInstance(); ! ! // make sure this doesn't already exist ! if (generalFunctionMap.containsKey(identity.toString())) ! throw new IllegalArgumentException("function already exists"); ! ! // now add it to our list ! generalFunctionMap.put(identity.toString(), object); } --- 290,294 ---- throws IllegalArgumentException { ! getGeneralInstance().addAbstractFunction(proxy, identity); } *************** *** 378,386 **** * be created through createAbstractFunction */ ! public Function createFunction(URI identity) ! throws UnknownIdentifierException, FunctionTypeException ! { ! return createFunction(identity.toString()); ! } /** --- 303,308 ---- * be created through createAbstractFunction */ ! public abstract Function createFunction(URI identity) ! throws UnknownIdentifierException, FunctionTypeException; /** *************** *** 394,417 **** * be created through createAbstractFunction */ ! public Function createFunction(String identity) ! throws UnknownIdentifierException, FunctionTypeException ! { ! Object entry = createFunctionHelper(identity); ! ! if (entry != null) { ! if (entry instanceof Function) { ! return (Function)entry; ! } else { ! // this is actually a proxy, which means the other create ! // method should have been called ! throw new FunctionTypeException("function is abstract"); ! } ! } else { ! // we couldn't find a match ! throw new UnknownIdentifierException(NAMES[factoryType] + ! " functions of type " + ! identity + " not supported"); ! } ! } /** --- 316,321 ---- * be created through createAbstractFunction */ ! public abstract Function createFunction(String identity) ! throws UnknownIdentifierException, FunctionTypeException; /** *************** *** 428,437 **** * given inputs */ ! public Function createAbstractFunction(URI identity, Node root) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! return createAbstractFunction(identity.toString(), root, null); ! } /** --- 332,338 ---- * given inputs */ ! public abstract Function createAbstractFunction(URI identity, Node root) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException; /** *************** *** 450,460 **** * given inputs */ ! public Function createAbstractFunction(URI identity, Node root, ! String xpathVersion) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! return createAbstractFunction(identity.toString(), root, xpathVersion); ! } /** --- 351,358 ---- * given inputs */ ! public abstract Function createAbstractFunction(URI identity, Node root, ! String xpathVersion) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException; /** *************** *** 471,480 **** * given inputs */ ! public Function createAbstractFunction(String identity, Node root) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! return createAbstractFunction(identity, root, null); ! } /** --- 369,375 ---- * given inputs */ ! public abstract Function createAbstractFunction(String identity, Node root) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException; /** *************** *** 493,541 **** * given inputs */ ! public Function createAbstractFunction(String identity, Node root, ! String xpathVersion) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException ! { ! Object entry = createFunctionHelper(identity); ! ! if (entry != null) { ! if (entry instanceof FunctionProxy) { ! try { ! return ((FunctionProxy)entry).getInstance(root, ! xpathVersion); ! } catch (Exception e) { ! throw new ParsingException("couldn't create abstract" + ! " function " + identity, e); ! } ! } else { ! // this is actually a concrete function, which means that ! // the other create method should have been called ! throw new FunctionTypeException("function is concrete"); ! } ! } else { ! // we couldn't find a match ! throw new UnknownIdentifierException(NAMES[factoryType] + ! " abstract functions of " + ! "type " + identity + ! " not supported"); ! } ! } ! ! /** ! * Looks in the right map for the given key ! */ ! private Object createFunctionHelper(String identity) { ! switch (factoryType) { ! case TARGET_FACTORY: ! return targetFunctionMap.get(identity); ! case CONDITION_FACTORY: ! return conditionFunctionMap.get(identity); ! case GENERAL_FACTORY: ! return generalFunctionMap.get(identity); ! } ! ! return null; ! } } --- 388,395 ---- * given inputs */ ! public abstract Function createAbstractFunction(String identity, Node root, ! String xpathVersion) throws UnknownIdentifierException, ParsingException, ! FunctionTypeException; } |
From: <se...@us...> - 2004-02-13 17:58:03
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30760/com/sun/xacml/combine Modified Files: CombiningAlgFactory.java Added Files: CombiningAlgFactoryProxy.java Log Message: introducing new, pluggable, still unstable factory interfaces --- NEW FILE: CombiningAlgFactoryProxy.java --- /* * @(#)CombiningAlgFactoryProxy.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.combine; /** * A simple proxy interface used to install new * <code>CombiningAlgFactory</code>s. * * @author Seth Proctor */ public interface CombiningAlgFactoryProxy { /** * Returns an instance of the <code>CombiningAlgFactory</code> for which * this is a proxy. * * @return a <code>CombiningAlgFactory</code> instance */ public CombiningAlgFactory getFactory(); } Index: CombiningAlgFactory.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/combine/CombiningAlgFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CombiningAlgFactory.java 25 Oct 2003 21:35:55 -0000 1.5 --- CombiningAlgFactory.java 13 Feb 2004 17:52:11 -0000 1.6 *************** *** 3,7 **** * @(#)CombiningAlgFactory.java * ! * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without --- 3,7 ---- * @(#)CombiningAlgFactory.java * ! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without *************** *** 42,97 **** import java.net.URI; - import java.util.HashMap; - /** * Provides a factory mechanism for installing and retrieving combining ! * algorithms. By default this supports all the standard combining ! * algorithms listed in the XACML specification. * * @author Seth Proctor */ ! public class CombiningAlgFactory { ! // the single map of available combining algorithms ! private static HashMap algMap; /** ! * Static initializer that sets up all the default algs */ static { ! algMap = new HashMap(); ! ! /** ! * NOTE: there only needs to be one instance of each Alg, so for now ! * this doesn't use the proxy mechanism, and is instead a simple ! * mapping to a single instance. ! */ ! ! addCombiningAlg(new DenyOverridesRuleAlg()); ! addCombiningAlg(new DenyOverridesPolicyAlg()); ! ! addCombiningAlg(new OrderedDenyOverridesRuleAlg()); ! addCombiningAlg(new OrderedDenyOverridesPolicyAlg()); ! ! addCombiningAlg(new PermitOverridesRuleAlg()); ! addCombiningAlg(new PermitOverridesPolicyAlg()); ! ! addCombiningAlg(new OrderedPermitOverridesRuleAlg()); ! addCombiningAlg(new OrderedPermitOverridesPolicyAlg()); ! ! addCombiningAlg(new FirstApplicableRuleAlg()); ! addCombiningAlg(new FirstApplicablePolicyAlg()); ! addCombiningAlg(new OnlyOneApplicablePolicyAlg()); } /** ! * Default constructor. There is only one instance of this factory, ! * so there is never any need to construct this class. */ ! protected CombiningAlgFactory() { } --- 42,95 ---- import java.net.URI; /** * Provides a factory mechanism for installing and retrieving combining ! * algorithms. * * @author Seth Proctor */ ! public abstract class CombiningAlgFactory { ! // the proxy used to get the default factory ! private static CombiningAlgFactoryProxy defaultFactoryProxy; /** ! * static intialiazer that sets up the default factory proxy ! * NOTE: this will change when the right setup mechanism is in place */ static { ! defaultFactoryProxy = new CombiningAlgFactoryProxy() { ! public CombiningAlgFactory getFactory() { ! return StandardCombiningAlgFactory.getFactory(); ! } ! }; ! }; ! /** ! * Default constructor. Used only by subclasses. ! */ ! protected CombiningAlgFactory() { ! } /** ! * Returns the default factory. Depending on the default factory's ! * implementation, this may return a singleton instance or new instances ! * with each invokation. ! * ! * @return the default <code>CombiningAlgFactory</code> */ ! public static final CombiningAlgFactory getInstance() { ! return defaultFactoryProxy.getFactory(); ! } + /** + * Sets the default factory. Note that this is just a placeholder for + * now, and will be replaced with a more useful mechanism soon. + */ + public static final void setDefaultFactory(CombiningAlgFactoryProxy proxy) + { + defaultFactoryProxy = proxy; } *************** *** 105,119 **** * @throws ProcessingException if the algId is already registered */ public static void addCombiningAlg(CombiningAlgorithm alg) throws ProcessingException { ! String algId = alg.getIdentifier().toString(); ! ! // check that the id doesn't already exist in the factory ! if (algMap.containsKey(algId)) ! throw new ProcessingException("algorithm already registered"); ! ! // add the algorithm ! algMap.put(algId, alg); } --- 103,130 ---- * @throws ProcessingException if the algId is already registered */ + public abstract void addAlgorithm(CombiningAlgorithm alg) + throws ProcessingException; + + /** + * Adds a combining algorithm to the factory. This single instance will + * be returned to anyone who asks the factory for an algorithm with the + * id given here. + * + * @deprecated As of version 1.2, replaced by + * {@link #addAlgorithm(CombiningAlgorithm)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param alg the combining algorithm to add + * + * @throws ProcessingException if the algId is already registered + */ public static void addCombiningAlg(CombiningAlgorithm alg) throws ProcessingException { ! getInstance().addAlgorithm(alg); } *************** *** 128,142 **** * @throws UnknownIdentifierException algId is unknown */ public static CombiningAlgorithm createCombiningAlg(URI algId) throws UnknownIdentifierException { ! String id = algId.toString(); ! ! if (algMap.containsKey(id)) { ! return (CombiningAlgorithm)(algMap.get(algId.toString())); ! } else { ! throw new UnknownIdentifierException("unknown combining algId: " ! + id); ! } } --- 139,167 ---- * @throws UnknownIdentifierException algId is unknown */ + public abstract CombiningAlgorithm createAlgorithm(URI algId) + throws UnknownIdentifierException; + + /** + * Tries to return the correct combinging algorithm based on the + * given algorithm ID. + * + * @deprecated As of version 1.2, replaced by + * {@link #createAlgorithm(URI)}. + * The new factory system requires you to get a factory + * instance and then call the non-static methods on that + * factory. The static versions of these methods have been + * left in for now, but are slower and will be removed in + * a future version. + * + * @param algId the identifier by which the algorithm is known + * + * @return a combining algorithm + * + * @throws UnknownIdentifierException algId is unknown + */ public static CombiningAlgorithm createCombiningAlg(URI algId) throws UnknownIdentifierException { ! return getInstance().createAlgorithm(algId); } |
From: <se...@us...> - 2004-01-07 21:31:23
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr In directory sc8-pr-cvs1:/tmp/cvs-serv23329/sun/xacml/attr Modified Files: BagAttribute.java Log Message: brought over a few fixes from the 1.1 branch Index: BagAttribute.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/attr/BagAttribute.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** BagAttribute.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- BagAttribute.java 7 Jan 2004 21:31:18 -0000 1.2 *************** *** 67,75 **** /** * Creates a new <code>BagAttribute</code> that represents ! * the <code>Set</code> supplied. If the set is null or empty, then ! * the new bag is empty. * * @param type the data type of all the attributes in the set ! * @param bag the <code>Collection</code> value to be represented */ public BagAttribute(URI type, Collection bag) { --- 67,75 ---- /** * Creates a new <code>BagAttribute</code> that represents ! * the <code>Collection</code> of <code>AttributeValue</code>s supplied. ! * If the set is null or empty, then the new bag is empty. * * @param type the data type of all the attributes in the set ! * @param bag a <code>Collection</code> of <code>AttributeValue</code>s */ public BagAttribute(URI type, Collection bag) { |
From: <se...@us...> - 2004-01-07 21:31:23
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond In directory sc8-pr-cvs1:/tmp/cvs-serv23329/sun/xacml/cond Modified Files: MatchFunction.java Log Message: brought over a few fixes from the 1.1 branch Index: MatchFunction.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/cond/MatchFunction.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** MatchFunction.java 13 Feb 2003 22:19:10 -0000 1.1.1.1 --- MatchFunction.java 7 Jan 2004 21:31:18 -0000 1.2 *************** *** 174,185 **** // in several ways; the next several code blocks transform // the XACML syntax into a semantically equivalent Pattern syntax // in order to handle the requirement that the string is // considered to match the pattern if any substring matches ! // the pattern, we prepend ".*" and append ".*" to the reg exp ! StringBuffer buf = new StringBuffer(arg0); ! buf = buf.insert(0, ".*"); ! buf = buf.insert(buf.length(), ".*"); // in order to handle Unicode blocks, we replace all --- 174,190 ---- // in several ways; the next several code blocks transform // the XACML syntax into a semantically equivalent Pattern syntax + + StringBuffer buf = new StringBuffer(arg0); + // in order to handle the requirement that the string is // considered to match the pattern if any substring matches ! // the pattern, we prepend ".*" and append ".*" to the reg exp, ! // but only if there isn't an anchor (^ or $) in place ! if (arg0.charAt(0) != '^') ! buf = buf.insert(0, ".*"); ! if (arg0.charAt(arg0.length() - 1) != '$') ! buf = buf.insert(buf.length(), ".*"); // in order to handle Unicode blocks, we replace all |
From: <se...@us...> - 2004-01-07 21:31:21
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1:/tmp/cvs-serv23329/sun/xacml Modified Files: AbstractPolicy.java Log Message: brought over a few fixes from the 1.1 branch Index: AbstractPolicy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AbstractPolicy.java 29 Aug 2003 18:58:32 -0000 1.6 --- AbstractPolicy.java 7 Jan 2004 21:31:18 -0000 1.7 *************** *** 45,48 **** --- 45,49 ---- import java.io.OutputStream; + import java.io.PrintStream; import java.net.URI; *************** *** 411,417 **** } ! it = obligations.iterator(); ! while (it.hasNext()) { ! ((Obligation)(it.next())).encode(output, indenter); } } --- 412,429 ---- } ! if (obligations.size() != 0) { ! PrintStream out = new PrintStream(output); ! String indent = indenter.makeString(); ! ! out.println(indent + "<Obligations>"); ! indenter.in(); ! ! it = obligations.iterator(); ! while (it.hasNext()) { ! ((Obligation)(it.next())).encode(output, indenter); ! } ! ! out.println(indent + "</Obligations>"); ! indenter.out(); } } |
From: <se...@us...> - 2003-12-04 22:08:47
|
Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml In directory sc8-pr-cvs1:/tmp/cvs-serv24180/com/sun/xacml Modified Files: Tag: branch_1_1 AbstractPolicy.java Log Message: fixed Obligations encoding Index: AbstractPolicy.java =================================================================== RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/AbstractPolicy.java,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** AbstractPolicy.java 29 Aug 2003 18:58:32 -0000 1.6 --- AbstractPolicy.java 4 Dec 2003 22:08:44 -0000 1.6.2.1 *************** *** 45,48 **** --- 45,49 ---- import java.io.OutputStream; + import java.io.PrintStream; import java.net.URI; *************** *** 411,417 **** } ! it = obligations.iterator(); ! while (it.hasNext()) { ! ((Obligation)(it.next())).encode(output, indenter); } } --- 412,429 ---- } ! if (obligations.size() != 0) { ! PrintStream out = new PrintStream(output); ! String indent = indenter.makeString(); ! ! out.println(indent + "<Obligations>"); ! indenter.in(); ! ! it = obligations.iterator(); ! while (it.hasNext()) { ! ((Obligation)(it.next())).encode(output, indenter); ! } ! ! out.println(indent + "</Obligations>"); ! indenter.out(); } } |