org.jboss.security.xacml.sunxacml.attr
Class AttributeFactory

java.lang.Object
  extended by org.jboss.security.xacml.sunxacml.attr.AttributeFactory
Direct Known Subclasses:
BaseAttributeFactory

public abstract class AttributeFactory
extends Object

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.

Since:
1.0
Author:
Seth Proctor, Marco Barreno

Constructor Summary
protected AttributeFactory()
          Default constructor.
 
Method Summary
static void addAttributeProxy(String id, AttributeProxy proxy)
          Deprecated. As of version 1.2, replaced by 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. Note that this operates only on the default factory.
abstract  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.
static AttributeValue createAttribute(Node root)
          Deprecated. As of version 1.2, replaced by 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.
static AttributeValue createAttribute(Node root, String type)
          Deprecated. As of version 1.2, replaced by 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.
static AttributeValue createAttribute(Node root, URI dataType)
          Deprecated. As of version 1.2, replaced by 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.
static AttributeValue createAttribute(URI dataType, String value)
          Deprecated. As of version 1.2, replaced by 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.
abstract  AttributeValue createValue(Node root)
          Creates a value based on the given DOM root node.
abstract  AttributeValue createValue(Node root, String type)
          Creates a value based on the given DOM root node and data type.
abstract  AttributeValue createValue(Node root, URI dataType)
          Creates a value based on the given DOM root node and data type.
abstract  AttributeValue createValue(URI dataType, String value)
          Creates a value based on the given data type and text-encoded value.
static AttributeFactory getInstance()
          Returns the default factory.
static AttributeFactory getInstance(String identifier)
          Returns a factory based on the given identifier.
abstract  Set getSupportedDatatypes()
          Returns the datatype identifiers supported by this factory.
static void registerFactory(String identifier, AttributeFactoryProxy proxy)
          Registers the given factory proxy with the given identifier.
static void setDefaultFactory(AttributeFactoryProxy proxy)
          Sets the default factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AttributeFactory

protected AttributeFactory()
Default constructor. Used only by subclasses.

Method Detail

getInstance

public static final AttributeFactory getInstance()
Returns the default factory. Depending on the default factory's implementation, this may return a singleton instance or new instances with each invokation.

Returns:
the default AttributeFactory

getInstance

public static final AttributeFactory getInstance(String identifier)
                                          throws UnknownIdentifierException
Returns a factory based on the given identifier. You may register as many factories as you like, and then retrieve them through this interface, but a factory may only be registered once using a given identifier. By default, the standard XACML 1.0 and 2.0 identifiers are regsietered to provide the standard factory.

Parameters:
identifier - the identifier for a factory
Returns:
an AttributeFactory
Throws:
UnknownIdentifierException - if the given identifier isn't registered

setDefaultFactory

public static final void setDefaultFactory(AttributeFactoryProxy proxy)
Sets the default factory. This does not register the factory proxy as an identifiable factory.

Parameters:
proxy - the AttributeFactoryProxy to set as the new default factory proxy

registerFactory

public static final void registerFactory(String identifier,
                                         AttributeFactoryProxy proxy)
                                  throws IllegalArgumentException
Registers the given factory proxy with the given identifier. If the identifier is already used, then this throws an exception. If the identifier is not already used, then it will always be bound to the given proxy.

Parameters:
identifier - the identifier for the proxy
proxy - the AttributeFactoryProxy to register with the given identifier
Throws:
IllegalArgumentException - if the identifier is already used

addDatatype

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

Parameters:
id - the name of the attribute type
proxy - the proxy used to create new attributes of the given type
Throws:
IllegalArgumentException - if the given id is already in use

addAttributeProxy

public static void addAttributeProxy(String id,
                                     AttributeProxy proxy)
Deprecated. As of version 1.2, replaced by 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. Note that this operates only on the default factory.

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 AttributeValue class.

Parameters:
id - the name of the attribute type
proxy - the proxy used to create new attributes of the given type
Throws:
IllegalArgumentException - if the given id is already in use

getSupportedDatatypes

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

Returns:
a Set of Strings

createValue

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

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

createAttribute

public static AttributeValue createAttribute(Node root)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by 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.

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 DataType, 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.

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 abstract AttributeValue createValue(Node root,
                                           URI dataType)
                                    throws UnknownIdentifierException,
                                           ParsingException
Creates a value based on the given DOM root node and data type.

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

createAttribute

public static AttributeValue createAttribute(Node root,
                                             URI dataType)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by 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.

Creates a value based on the given DOM root node and data type. This uses the default factory.

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 abstract AttributeValue createValue(Node root,
                                           String type)
                                    throws UnknownIdentifierException,
                                           ParsingException
Creates a value based on the given DOM root node and data type.

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

createAttribute

public static AttributeValue createAttribute(Node root,
                                             String type)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by 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.

Creates a value based on the given DOM root node and data type. This uses the default factory.

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

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

createAttribute

public static AttributeValue createAttribute(URI dataType,
                                             String value)
                                      throws UnknownIdentifierException,
                                             ParsingException
Deprecated. As of version 1.2, replaced by 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.

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.

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


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.