SunTM's XACML Implementation for JavaTM

com.sun.xacml.attr
Class BaseAttributeFactory

java.lang.Object
  extended bycom.sun.xacml.attr.AttributeFactory
      extended bycom.sun.xacml.attr.BaseAttributeFactory
Direct Known Subclasses:
StandardAttributeFactory

public class BaseAttributeFactory
extends AttributeFactory

This is a basic implementation of AttributeFactory. It implements the insertion and retrieval methods, but doesn't actually setup the factory with any datatypes.

Note that while this class is thread-safe on all creation methods, it is not safe to add support for a new datatype while creating an instance of a value. 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
BaseAttributeFactory()
          Default constructor.
BaseAttributeFactory(Map attributes)
          Constructor that configures this factory with an initial set of supported datatypes.
 
Method Summary
 void addDatatype(String id, AttributeProxy proxy)
          Adds a proxy to the factory, which in turn will allow new attribute types to be created using the factory.
 AttributeValue createValue(Node root)
          Creates a value based on the given DOM root node.
 AttributeValue createValue(Node root, String type)
          Creates a value based on the given DOM root node and data type.
 AttributeValue createValue(Node root, URI dataType)
          Creates a value based on the given DOM root node and data type.
 AttributeValue createValue(URI dataType, String value)
          Creates a value based on the given data type and text-encoded value.
 Set getSupportedDatatypes()
          Returns the datatype identifiers supported by this factory.
 
Methods inherited from class com.sun.xacml.attr.AttributeFactory
addAttributeProxy, createAttribute, createAttribute, createAttribute, createAttribute, getInstance, setDefaultFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseAttributeFactory

public BaseAttributeFactory()
Default constructor.


BaseAttributeFactory

public BaseAttributeFactory(Map attributes)
Constructor that configures this factory with an initial set of supported datatypes.

Parameters:
attributes - a Map of Strings to AttributeProxys
Throws:
IllegalArgumentException - if any elements of the Map are not AttributeProxys
Method Detail

addDatatype

public void addDatatype(String id,
                        AttributeProxy proxy)
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 AttributeValue class.

Specified by:
addDatatype in class AttributeFactory
Parameters:
id - the name of the attribute type
proxy - the proxy used to create new attributes of the given type

getSupportedDatatypes

public Set getSupportedDatatypes()
Returns the datatype identifiers supported by this factory.

Specified by:
getSupportedDatatypes in class AttributeFactory
Returns:
a Set of Strings

createValue

public 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 XACML attribute named DataType, as is the case with the AttributeValueType in the policy schema. The value is assumed to be the first child of this node.

Specified by:
createValue in class AttributeFactory
Parameters:
root - the DOM root of an attribute value
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the type in the node isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createValue

public AttributeValue createValue(Node root,
                                  URI dataType)
                           throws UnknownIdentifierException,
                                  ParsingException
Creates a value based on the given DOM root node and data type.

Specified by:
createValue in class AttributeFactory
Parameters:
root - the DOM root of an attribute value
dataType - the type of the attribute
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the data type isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createValue

public AttributeValue createValue(Node root,
                                  String type)
                           throws UnknownIdentifierException,
                                  ParsingException
Creates a value based on the given DOM root node and data type.

Specified by:
createValue in class AttributeFactory
Parameters:
root - the DOM root of an attribute value
type - the type of the attribute
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the type isn't known to the factory
ParsingException - if the node is invalid or can't be parsed by the appropriate proxy

createValue

public 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.

Specified by:
createValue in class AttributeFactory
Parameters:
dataType - the type of the attribute
value - the text-encoded representation of an attribute's value
Returns:
a new AttributeValue
Throws:
UnknownIdentifierException - if the data type isn't known to the factory
ParsingException - if the text is invalid or can't be parsed by the appropriate proxy

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.