Example usage for javax.xml.crypto.dom DOMCryptoContext setIdAttributeNS

List of usage examples for javax.xml.crypto.dom DOMCryptoContext setIdAttributeNS

Introduction

In this page you can find the example usage for javax.xml.crypto.dom DOMCryptoContext setIdAttributeNS.

Prototype

public void setIdAttributeNS(Element element, String namespaceURI, String localName) 

Source Link

Document

Registers the element's attribute specified by the namespace URI and local name to be of type ID.

Usage

From source file:org.jcp.xml.dsig.internal.dom.DOMReference.java

/**
 * Creates a <code>DOMReference</code> from an element.
 *
 * @param refElem a Reference element//from  w  w w  . ja v  a2 s . c o  m
 */
public DOMReference(Element refElem, XMLCryptoContext context, Provider provider) throws MarshalException {
    // unmarshal Transforms, if specified
    Element nextSibling = DOMUtils.getFirstChildElement(refElem);
    List<Transform> transforms = new ArrayList<Transform>(5);
    if (nextSibling.getLocalName().equals("Transforms")) {
        Element transformElem = DOMUtils.getFirstChildElement(nextSibling);
        while (transformElem != null) {
            transforms.add(new DOMTransform(transformElem, context, provider));
            transformElem = DOMUtils.getNextSiblingElement(transformElem);
        }
        nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
    }

    // unmarshal DigestMethod
    Element dmElem = nextSibling;
    this.digestMethod = DOMDigestMethod.unmarshal(dmElem);

    // unmarshal DigestValue
    try {
        Element dvElem = DOMUtils.getNextSiblingElement(dmElem);
        this.digestValue = Base64.decode(dvElem);
    } catch (Base64DecodingException bde) {
        throw new MarshalException(bde);
    }

    // unmarshal attributes
    this.uri = DOMUtils.getAttributeValue(refElem, "URI");
    this.id = DOMUtils.getAttributeValue(refElem, "Id");
    if (this.id != null) {
        DOMCryptoContext dcc = (DOMCryptoContext) context;
        dcc.setIdAttributeNS(refElem, null, "Id");
    }

    this.type = DOMUtils.getAttributeValue(refElem, "Type");
    this.here = refElem.getAttributeNodeNS(null, "URI");
    this.refElem = refElem;
    this.transforms = transforms;
    this.allTransforms = transforms;
    this.appliedTransformData = null;
    this.provider = provider;
}