APIdia Launch Partner
Top Description Fields Constructors Methods
javax.xml.crypto.dom

public Class DOMCryptoContext

extends Object
implements XMLCryptoContext
Class Inheritance
All Implemented Interfaces
javax.xml.crypto.XMLCryptoContext
Known Direct Subclasses
javax.xml.crypto.dsig.dom.DOMSignContext, javax.xml.crypto.dsig.dom.DOMValidateContext, org.jcp.xml.dsig.internal.dom.DOMKeyInfoFactory.UnmarshalContext, org.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory.UnmarshalContext
Imports
javax.xml.crypto.KeySelector, .URIDereferencer, .XMLCryptoContext, java.util.Collections, .HashMap, .Iterator, .Map, org.w3c.dom.Element

This class provides a DOM-specific implementation of the XMLCryptoContext interface. It also includes additional methods that are specific to a DOM-based implementation for registering and retrieving elements that contain attributes of type ID.
Authors
Sean Mullan, JSR 105 Expert Group
Since
1.6

Field Summary

Modifier and TypeField and Description
private String
private String
private URIDereferencer
private HashMap<String, Element>
private KeySelector
private HashMap<String, String>
private HashMap<Object, Object>
private HashMap<String, Object>

Constructor Summary

AccessConstructor and Description
protected
DOMCryptoContext()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public Object
get(Object key)

Implements javax.xml.crypto.XMLCryptoContext.get.

This implementation uses an internal HashMap to get the object that the specified key maps to.

public String
getBaseURI()

Implements javax.xml.crypto.XMLCryptoContext.getBaseURI.

Returns the base URI.

public String
public Element

Returns:

the Element with the specified ID attribute value, or null if none.
getElementById
(String
the value of the ID
idValue
)

Returns the Element with the specified ID attribute value.

public KeySelector
getKeySelector()

Implements javax.xml.crypto.XMLCryptoContext.getKeySelector.

Returns the key selector for finding a key.

public String
getNamespacePrefix(String namespaceURI, String defaultPrefix)

Implements javax.xml.crypto.XMLCryptoContext.getNamespacePrefix.

This implementation uses an internal HashMap to get the prefix that the specified URI maps to.

public Object
getProperty(String name)

Implements javax.xml.crypto.XMLCryptoContext.getProperty.

This implementation uses an internal HashMap to get the object that the specified name maps to.

public URIDereferencer
getURIDereferencer()

Implements javax.xml.crypto.XMLCryptoContext.getURIDereferencer.

Returns a URIDereferencer that is used to dereference URIReferences.

public Iterator<Map.Entry<String, Element>>

Returns:

a read-only iterator over the set of mappings
iterator
()

Returns a read-only iterator over the set of Id/Element mappings of this DOMCryptoContext.

public Object
put(Object key, Object value)

Implements javax.xml.crypto.XMLCryptoContext.put.

This implementation uses an internal HashMap to map the key to the specified object.

public String
putNamespacePrefix(String namespaceURI, String prefix)

Implements javax.xml.crypto.XMLCryptoContext.putNamespacePrefix.

This implementation uses an internal HashMap to map the URI to the specified prefix.

public void
setBaseURI(String baseURI)

Implements javax.xml.crypto.XMLCryptoContext.setBaseURI.

Sets the base URI.

public void
setDefaultNamespacePrefix(String defaultPrefix)

Implements javax.xml.crypto.XMLCryptoContext.setDefaultNamespacePrefix.

Sets the default namespace prefix.

public void
setIdAttributeNS(Element
the element
element
,
String
the namespace URI of the attribute (specify null if not applicable)
namespaceURI
,
String
the local name of the attribute
localName
)

Registers the element's attribute specified by the namespace URI and local name to be of type ID. The attribute must have a non-empty value.

public void
setKeySelector(KeySelector ks)

Implements javax.xml.crypto.XMLCryptoContext.setKeySelector.

Sets the key selector for finding a key.

public Object
setProperty(String name, Object value)

Implements javax.xml.crypto.XMLCryptoContext.setProperty.

This implementation uses an internal HashMap to map the name to the specified object.

public void
setURIDereferencer(URIDereferencer dereferencer)

Implements javax.xml.crypto.XMLCryptoContext.setURIDereferencer.

Sets a URIDereferencer that is used to dereference URIReferences.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseURIback to summary
private String baseURI
defaultPrefixback to summary
private String defaultPrefix
dereferencerback to summary
private URIDereferencer dereferencer
idMapback to summary
private HashMap<String, Element> idMap
ksback to summary
private KeySelector ks
nsMapback to summary
private HashMap<String, String> nsMap
objMapback to summary
private HashMap<Object, Object> objMap
propMapback to summary
private HashMap<String, Object> propMap

Constructor Detail

DOMCryptoContextback to summary
protected DOMCryptoContext()

Default constructor. (For invocation by subclass constructors).

Method Detail

getback to summary
public Object get(Object key)

Implements javax.xml.crypto.XMLCryptoContext.get.

This implementation uses an internal HashMap to get the object that the specified key maps to.

getBaseURIback to summary
public String getBaseURI()

Implements javax.xml.crypto.XMLCryptoContext.getBaseURI.

Doc from javax.xml.crypto.XMLCryptoContext.getBaseURI.

Returns the base URI.

getDefaultNamespacePrefixback to summary
public String getDefaultNamespacePrefix()

Implements javax.xml.crypto.XMLCryptoContext.getDefaultNamespacePrefix.

Doc from javax.xml.crypto.XMLCryptoContext.getDefaultNamespacePrefix.

Returns the default namespace prefix. The default namespace prefix is the prefix for all namespace URIs not explicitly set by the putNamespacePrefix method.

getElementByIdback to summary
public Element getElementById(String idValue)

Returns the Element with the specified ID attribute value.

This implementation uses an internal HashMap to get the element that the specified attribute value maps to.

Parameters
idValue:String

the value of the ID

Returns:Element

the Element with the specified ID attribute value, or null if none.

Exceptions
NullPointerException:
if idValue is null
See Also
setIdAttributeNS
getKeySelectorback to summary
public KeySelector getKeySelector()

Implements javax.xml.crypto.XMLCryptoContext.getKeySelector.

Doc from javax.xml.crypto.XMLCryptoContext.getKeySelector.

Returns the key selector for finding a key.

getNamespacePrefixback to summary
public String getNamespacePrefix(String namespaceURI, String defaultPrefix)

Implements javax.xml.crypto.XMLCryptoContext.getNamespacePrefix.

This implementation uses an internal HashMap to get the prefix that the specified URI maps to. It returns the defaultPrefix if it maps to null.

Exceptions
NullPointerException:
if namespaceURI is null
getPropertyback to summary
public Object getProperty(String name)

Implements javax.xml.crypto.XMLCryptoContext.getProperty.

This implementation uses an internal HashMap to get the object that the specified name maps to.

Exceptions
NullPointerException:
if name is null
getURIDereferencerback to summary
public URIDereferencer getURIDereferencer()

Implements javax.xml.crypto.XMLCryptoContext.getURIDereferencer.

Doc from javax.xml.crypto.XMLCryptoContext.getURIDereferencer.

Returns a URIDereferencer that is used to dereference URIReferences.

iteratorback to summary
public Iterator<Map.Entry<String, Element>> iterator()

Returns a read-only iterator over the set of Id/Element mappings of this DOMCryptoContext. Attempts to modify the set via the Iterator#remove method throw an UnsupportedOperationException. The mappings are returned in no particular order. Each element in the iteration is represented as a java.util.Map.Entry. If the DOMCryptoContext is modified while an iteration is in progress, the results of the iteration are undefined.

Returns:Iterator<Map.Entry<String, Element>>

a read-only iterator over the set of mappings

putback to summary
public Object put(Object key, Object value)

Implements javax.xml.crypto.XMLCryptoContext.put.

This implementation uses an internal HashMap to map the key to the specified object.

Exceptions
IllegalArgumentException:
if some aspect of this key or value prevents it from being stored in this context
putNamespacePrefixback to summary
public String putNamespacePrefix(String namespaceURI, String prefix)

Implements javax.xml.crypto.XMLCryptoContext.putNamespacePrefix.

This implementation uses an internal HashMap to map the URI to the specified prefix.

Exceptions
NullPointerException:
if namespaceURI is null
setBaseURIback to summary
public void setBaseURI(String baseURI)

Implements javax.xml.crypto.XMLCryptoContext.setBaseURI.

Doc from javax.xml.crypto.XMLCryptoContext.setBaseURI.

Sets the base URI.

Exceptions
IllegalArgumentException:
if baseURI is not RFC 2396 compliant
setDefaultNamespacePrefixback to summary
public void setDefaultNamespacePrefix(String defaultPrefix)

Implements javax.xml.crypto.XMLCryptoContext.setDefaultNamespacePrefix.

Doc from javax.xml.crypto.XMLCryptoContext.setDefaultNamespacePrefix.

Sets the default namespace prefix. This sets the namespace prefix for all namespace URIs not explicitly set by the putNamespacePrefix method.

setIdAttributeNSback to summary
public void setIdAttributeNS(Element element, String namespaceURI, String localName)

Registers the element's attribute specified by the namespace URI and local name to be of type ID. The attribute must have a non-empty value.

This implementation uses an internal HashMap to map the attribute's value to the specified element.

Parameters
element:Element

the element

namespaceURI:String

the namespace URI of the attribute (specify null if not applicable)

localName:String

the local name of the attribute

Exceptions
IllegalArgumentException:
if localName is not an attribute of the specified element or it does not contain a specific value
NullPointerException:
if element or localName is null
See Also
getElementById
setKeySelectorback to summary
public void setKeySelector(KeySelector ks)

Implements javax.xml.crypto.XMLCryptoContext.setKeySelector.

Doc from javax.xml.crypto.XMLCryptoContext.setKeySelector.

Sets the key selector for finding a key.

setPropertyback to summary
public Object setProperty(String name, Object value)

Implements javax.xml.crypto.XMLCryptoContext.setProperty.

This implementation uses an internal HashMap to map the name to the specified object.

Exceptions
NullPointerException:
if name is null
setURIDereferencerback to summary
public void setURIDereferencer(URIDereferencer dereferencer)

Implements javax.xml.crypto.XMLCryptoContext.setURIDereferencer.

Doc from javax.xml.crypto.XMLCryptoContext.setURIDereferencer.

Sets a URIDereferencer that is used to dereference URIReferences. The specified URIDereferencer is used in place of an implementation's default URIDereferencer.