SunTM's XACML Implementation for JavaTM

com.sun.xacml.cond
Class BaseFunctionFactory

java.lang.Object
  extended bycom.sun.xacml.cond.FunctionFactory
      extended bycom.sun.xacml.cond.BaseFunctionFactory
Direct Known Subclasses:
StandardFunctionFactory

public class BaseFunctionFactory
extends FunctionFactory

This is a basic implementation of FunctionFactory. 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.

Note that while this class is thread-safe on all creation methods, it is not safe to add support for a new function while creating an instance of a function. This follows from the assumption that most people will initialize these factories up-front, and then start processing without ever modifying the factories. If you need these mutual operations to be thread-safe, then you should write a wrapper class that implements the right synchronization.

Since:
1.2

Constructor Summary
BaseFunctionFactory()
          Default constructor.
BaseFunctionFactory(FunctionFactory superset)
          Constructor that sets a "superset factory".
BaseFunctionFactory(FunctionFactory superset, Set supportedFunctions, Map supportedAbstractFunctions)
          Constructor that defines the initial functions supported by this factory and uses a superset factory.
BaseFunctionFactory(Set supportedFunctions, Map supportedAbstractFunctions)
          Constructor that defines the initial functions supported by this factory but doesn't use a superset factory.
 
Method Summary
 void addAbstractFunction(FunctionProxy proxy, URI identity)
          Adds the abstract function proxy to the factory.
 void addFunction(Function function)
          Adds the function to the factory.
 Function createAbstractFunction(String identity, Node root)
          Tries to get an instance of the specified abstract function.
 Function createAbstractFunction(String identity, Node root, String xpathVersion)
          Tries to get an instance of the specified abstract function.
 Function createAbstractFunction(URI identity, Node root)
          Tries to get an instance of the specified abstract function.
 Function createAbstractFunction(URI identity, Node root, String xpathVersion)
          Tries to get an instance of the specified abstract function.
 Function createFunction(String identity)
          Tries to get an instance of the specified function.
 Function createFunction(URI identity)
          Tries to get an instance of the specified function.
 Set getSupportedFunctions()
          Returns the function identifiers supported by this factory.
 
Methods inherited from class com.sun.xacml.cond.FunctionFactory
addAbstractConditionFunction, addAbstractGeneralFunction, addAbstractTargetFunction, addConditionFunction, addGeneralFunction, addTargetFunction, getConditionInstance, getGeneralInstance, getTargetInstance, setDefaultFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseFunctionFactory

public BaseFunctionFactory()
Default constructor. No superset factory is used.


BaseFunctionFactory

public BaseFunctionFactory(FunctionFactory superset)
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.

Parameters:
superset - the superset factory or null

BaseFunctionFactory

public BaseFunctionFactory(Set supportedFunctions,
                           Map supportedAbstractFunctions)
Constructor that defines the initial functions supported by this factory but doesn't use a superset factory.

Parameters:
supportedFunctions - a Set of Functions
supportedAbstractFunctions - a mapping from URI to FunctionProxy

BaseFunctionFactory

public BaseFunctionFactory(FunctionFactory superset,
                           Set supportedFunctions,
                           Map supportedAbstractFunctions)
Constructor that defines the initial functions supported by this factory and uses a superset factory. Note that the functions supplied here are not propagated up to the superset factory, so you must either make sure the superst factory is correctly initialized or use BaseFunctionFactory(FunctionFactory) and then manually add each function.

Parameters:
superset - the superset factory or null
supportedFunctions - a Set of Functions
supportedAbstractFunctions - a mapping from URI to FunctionProxy
Method Detail

addFunction

public void addFunction(Function function)
                 throws IllegalArgumentException
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.

Specified by:
addFunction in class FunctionFactory
Parameters:
function - the Function 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)

addAbstractFunction

public void addAbstractFunction(FunctionProxy proxy,
                                URI identity)
                         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).

Specified by:
addAbstractFunction in class FunctionFactory
Parameters:
proxy - the FunctionProxy to add to the factory
identity - the function's identifier
Throws:
IllegalArgumentException - if the function's identifier is already used

getSupportedFunctions

public Set getSupportedFunctions()
Returns the function identifiers supported by this factory.

Specified by:
getSupportedFunctions in class FunctionFactory
Returns:
a Set of Strings

createFunction

public Function createFunction(URI identity)
                        throws UnknownIdentifierException,
                               FunctionTypeException
Tries to get an instance of the specified function.

Specified by:
createFunction in class FunctionFactory
Parameters:
identity - the name of the function
Throws:
UnknownIdentifierException - if the name isn't known
FunctionTypeException - if the name is known to map to an abstract function, and should therefore be created through createAbstractFunction

createFunction

public Function createFunction(String identity)
                        throws UnknownIdentifierException,
                               FunctionTypeException
Tries to get an instance of the specified function.

Specified by:
createFunction in class FunctionFactory
Parameters:
identity - the name of the function
Throws:
UnknownIdentifierException - if the name isn't known
FunctionTypeException - if the name is known to map to an abstract function, and should therefore be created through createAbstractFunction

createAbstractFunction

public Function createAbstractFunction(URI identity,
                                       Node root)
                                throws UnknownIdentifierException,
                                       ParsingException,
                                       FunctionTypeException
Tries to get an instance of the specified abstract function.

Specified by:
createAbstractFunction in class FunctionFactory
Parameters:
identity - the name of the function
root - the DOM root containing info used to create the function
Throws:
UnknownIdentifierException - if the name isn't known
FunctionTypeException - if the name is known to map to a concrete function, and should therefore be created through createFunction
ParsingException - if the function can't be created with the given inputs

createAbstractFunction

public Function createAbstractFunction(URI identity,
                                       Node root,
                                       String xpathVersion)
                                throws UnknownIdentifierException,
                                       ParsingException,
                                       FunctionTypeException
Tries to get an instance of the specified abstract function.

Specified by:
createAbstractFunction in class FunctionFactory
Parameters:
identity - the name of the function
root - the DOM root containing info used to create the function
xpathVersion - the version specified in the contianing policy, or null if no version was specified
Throws:
UnknownIdentifierException - if the name isn't known
FunctionTypeException - if the name is known to map to a concrete function, and should therefore be created through createFunction
ParsingException - if the function can't be created with the given inputs

createAbstractFunction

public Function createAbstractFunction(String identity,
                                       Node root)
                                throws UnknownIdentifierException,
                                       ParsingException,
                                       FunctionTypeException
Tries to get an instance of the specified abstract function.

Specified by:
createAbstractFunction in class FunctionFactory
Parameters:
identity - the name of the function
root - the DOM root containing info used to create the function
Throws:
UnknownIdentifierException - if the name isn't known
FunctionTypeException - if the name is known to map to a concrete function, and should therefore be created through createFunction
ParsingException - if the function can't be created with the given inputs

createAbstractFunction

public Function createAbstractFunction(String identity,
                                       Node root,
                                       String xpathVersion)
                                throws UnknownIdentifierException,
                                       ParsingException,
                                       FunctionTypeException
Tries to get an instance of the specified abstract function.

Specified by:
createAbstractFunction in class FunctionFactory
Parameters:
identity - the name of the function
root - the DOM root containing info used to create the function
xpathVersion - the version specified in the contianing policy, or null if no version was specified
Throws:
UnknownIdentifierException - if the name isn't known
FunctionTypeException - if the name is known to map to a concrete function, and should therefore be created through createFunction
ParsingException - if the function can't be created with the given inputs

Sun's XACML Implementation Version 1.2

Copyright 2003-2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

Sun, Sun Microsystems, the Sun Logo, and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.