FileDocCategorySizeDatePackage
DOMSignContext.javaAPI DocJava SE 6 API6945Tue Jun 10 00:27:06 BST 2008javax.xml.crypto.dsig.dom

DOMSignContext

public class DOMSignContext extends DOMCryptoContext implements XMLSignContext
A DOM-specific {@link XMLSignContext}. This class contains additional methods to specify the location in a DOM tree where an {@link XMLSignature} object is to be marshalled when generating the signature.

Note that DOMSignContext instances can contain information and state specific to the XML signature structure it is used with. The results are unpredictable if a DOMSignContext is used with different signature structures (for example, you should not use the same DOMSignContext instance to sign two different {@link XMLSignature} objects).

author
Sean Mullan
author
JSR 105 Expert Group
since
1.6

Fields Summary
private Node
parent
private Node
nextSibling
Constructors Summary
public DOMSignContext(Key signingKey, Node parent)
Creates a DOMSignContext with the specified signing key and parent node. The signing key is stored in a {@link KeySelector#singletonKeySelector singleton KeySelector} that is returned by the {@link #getKeySelector getKeySelector} method. The marshalled XMLSignature will be added as the last child element of the specified parent node unless a next sibling node is specified by invoking the {@link #setNextSibling setNextSibling} method.

param
signingKey the signing key
param
parent the parent node
throws
NullPointerException if signingKey or parent is null

 
        if (signingKey == null) {
            throw new NullPointerException("signingKey cannot be null");
        } 
        if (parent == null) {
            throw new NullPointerException("parent cannot be null");
        }
        setKeySelector(KeySelector.singletonKeySelector(signingKey));
        this.parent = parent;
    
public DOMSignContext(Key signingKey, Node parent, Node nextSibling)
Creates a DOMSignContext with the specified signing key, parent and next sibling nodes. The signing key is stored in a {@link KeySelector#singletonKeySelector singleton KeySelector} that is returned by the {@link #getKeySelector getKeySelector} method. The marshalled XMLSignature will be inserted as a child element of the specified parent node and immediately before the specified next sibling node.

param
signingKey the signing key
param
parent the parent node
param
nextSibling the next sibling node
throws
NullPointerException if signingKey, parent or nextSibling is null

 
        if (signingKey == null) {
            throw new NullPointerException("signingKey cannot be null");
        }
        if (parent == null) {
            throw new NullPointerException("parent cannot be null");
        }
        if (nextSibling == null) {
            throw new NullPointerException("nextSibling cannot be null");
        }
        setKeySelector(KeySelector.singletonKeySelector(signingKey));
        this.parent = parent;
        this.nextSibling = nextSibling;
    
public DOMSignContext(KeySelector ks, Node parent)
Creates a DOMSignContext with the specified key selector and parent node. The marshalled XMLSignature will be added as the last child element of the specified parent node unless a next sibling node is specified by invoking the {@link #setNextSibling setNextSibling} method.

param
ks the key selector
param
parent the parent node
throws
NullPointerException if ks or parent is null

        if (ks == null) {
            throw new NullPointerException("key selector cannot be null");
        } 
        if (parent == null) {
            throw new NullPointerException("parent cannot be null");
        }
        setKeySelector(ks);
        this.parent = parent;
    
public DOMSignContext(KeySelector ks, Node parent, Node nextSibling)
Creates a DOMSignContext with the specified key selector, parent and next sibling nodes. The marshalled XMLSignature will be inserted as a child element of the specified parent node and immediately before the specified next sibling node.

param
ks the key selector
param
parent the parent node
param
nextSibling the next sibling node
throws
NullPointerException if ks, parent or nextSibling is null

 
        if (ks == null) {
            throw new NullPointerException("key selector cannot be null");
        }
        if (parent == null) {
            throw new NullPointerException("parent cannot be null");
        }
        if (nextSibling == null) {
            throw new NullPointerException("nextSibling cannot be null");
        }
        setKeySelector(ks);
        this.parent = parent;
        this.nextSibling = nextSibling;
    
Methods Summary
public org.w3c.dom.NodegetNextSibling()
Returns the nextSibling node.

return
the nextSibling node, or null if not specified.
see
#setNextSibling(Node)

	return nextSibling;
    
public org.w3c.dom.NodegetParent()
Returns the parent node.

return
the parent node (never null)
see
#setParent(Node)

	return parent;
    
public voidsetNextSibling(org.w3c.dom.Node nextSibling)
Sets the next sibling node.

param
nextSibling the next sibling node. The marshalled XMLSignature will be inserted immediately before this node. Specify null to remove the current setting.
see
#getNextSibling

	this.nextSibling = nextSibling;
    
public voidsetParent(org.w3c.dom.Node parent)
Sets the parent node.

param
parent the parent node. The marshalled XMLSignature will be added as a child element of this node.
throws
NullPointerException if parent is null
see
#getParent

	if (parent == null) {
	    throw new NullPointerException("parent is null");
	}
	this.parent = parent;