Java Code Examples for com.sun.org.apache.xml.internal.security.transforms.Transforms

The following examples show how to use com.sun.org.apache.xml.internal.security.transforms.Transforms. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openjdk-8   Source File: RetrievalMethod.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: Manifest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 3
/**
 * Resolves the input from the given retrieval method
 * @return
 * @throws XMLSecurityException
 */
private static XMLSignatureInput resolveInput(
    RetrievalMethod rm, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    Attr uri = rm.getURIAttr();
    // Apply the transforms
    Transforms transforms = rm.getTransforms();
    ResourceResolver resRes = ResourceResolver.getInstance(uri, baseURI, secureValidation);
    XMLSignatureInput resource = resRes.resolve(uri, baseURI, secureValidation);
    if (transforms != null) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "We have Transforms");
        }
        resource = transforms.performTransforms(resource);
    }
    return resource;
}
 
Example 4
Source Project: openjdk-jdk9   Source File: Manifest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 5
/**
 * Resolves the input from the given retrieval method
 * @return
 * @throws XMLSecurityException
 */
private static XMLSignatureInput resolveInput(
    RetrievalMethod rm, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    Attr uri = rm.getURIAttr();
    // Apply the transforms
    Transforms transforms = rm.getTransforms();
    ResourceResolver resRes = ResourceResolver.getInstance(uri, baseURI, secureValidation);
    XMLSignatureInput resource = resRes.resolve(uri, baseURI, secureValidation);
    if (transforms != null) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "We have Transforms");
        }
        resource = transforms.performTransforms(resource);
    }
    return resource;
}
 
Example 6
/**
 * Resolves the input from the given retrieval method
 * @return
 * @throws XMLSecurityException
 */
private static XMLSignatureInput resolveInput(
    RetrievalMethod rm, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    Attr uri = rm.getURIAttr();
    // Apply the transforms
    Transforms transforms = rm.getTransforms();
    ResourceResolver resRes = ResourceResolver.getInstance(uri, baseURI, secureValidation);
    XMLSignatureInput resource = resRes.resolve(uri, baseURI, secureValidation);
    if (transforms != null) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "We have Transforms");
        }
        resource = transforms.performTransforms(resource);
    }
    return resource;
}
 
Example 7
Source Project: jdk1.8-source-analysis   Source File: RetrievalMethod.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
Example 8
Source Project: dragonwell8_jdk   Source File: Manifest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 9
Source Project: dragonwell8_jdk   Source File: Reference.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
Example 10
/**
 * Resolves the input from the given retrieval method
 * @return
 * @throws XMLSecurityException
 */
private static XMLSignatureInput resolveInput(
    RetrievalMethod rm, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    Attr uri = rm.getURIAttr();
    // Apply the transforms
    Transforms transforms = rm.getTransforms();
    ResourceResolver resRes = ResourceResolver.getInstance(uri, baseURI, secureValidation);
    XMLSignatureInput resource = resRes.resolve(uri, baseURI, secureValidation);
    if (transforms != null) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "We have Transforms");
        }
        resource = transforms.performTransforms(resource);
    }
    return resource;
}
 
Example 11
Source Project: jdk8u-dev-jdk   Source File: Reference.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
Example 12
Source Project: TencentKona-8   Source File: Manifest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 13
Source Project: TencentKona-8   Source File: Reference.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
Example 14
Source Project: jdk8u60   Source File: Reference.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
Example 15
Source Project: jdk8u-jdk   Source File: Reference.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Build a {@link Reference} from an {@link Element}
 *
 * @param element <code>Reference</code> element
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param manifest is the {@link Manifest} of {@link SignedInfo} in which the Reference occurs.
 * @param secureValidation whether secure validation is enabled or not
 * We need this because the Manifest has the individual {@link ResourceResolver}s which have
 * been set by the user
 * @throws XMLSecurityException
 */
protected Reference(Element element, String baseURI, Manifest manifest, boolean secureValidation)
    throws XMLSecurityException {
    super(element, baseURI);
    this.secureValidation = secureValidation;
    this.baseURI = baseURI;
    Element el = XMLUtils.getNextElement(element.getFirstChild());
    if (Constants._TAG_TRANSFORMS.equals(el.getLocalName())
        && Constants.SignatureSpecNS.equals(el.getNamespaceURI())) {
        transforms = new Transforms(el, this.baseURI);
        transforms.setSecureValidation(secureValidation);
        if (secureValidation && transforms.getLength() > MAXIMUM_TRANSFORM_COUNT) {
            Object exArgs[] = { transforms.getLength(), MAXIMUM_TRANSFORM_COUNT };

            throw new XMLSecurityException("signature.tooManyTransforms", exArgs);
        }
        el = XMLUtils.getNextElement(el.getNextSibling());
    }
    digestMethodElem = el;
    digestValueElement = XMLUtils.getNextElement(digestMethodElem.getNextSibling());
    this.manifest = manifest;
}
 
Example 16
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
Example 17
/**
 * Resolves the input from the given retrieval method
 * @return
 * @throws XMLSecurityException
 */
private static XMLSignatureInput resolveInput(
    RetrievalMethod rm, String baseURI, boolean secureValidation
) throws XMLSecurityException {
    Attr uri = rm.getURIAttr();
    // Apply the transforms
    Transforms transforms = rm.getTransforms();
    ResourceResolver resRes = ResourceResolver.getInstance(uri, baseURI, secureValidation);
    XMLSignatureInput resource = resRes.resolve(uri, baseURI, secureValidation);
    if (transforms != null) {
        if (log.isLoggable(java.util.logging.Level.FINE)) {
            log.log(java.util.logging.Level.FINE, "We have Transforms");
        }
        resource = transforms.performTransforms(resource);
    }
    return resource;
}
 
Example 18
Source Project: JDKSourceCode1.8   Source File: RetrievalMethod.java    License: MIT License 6 votes vote down vote up
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
Example 19
Source Project: openjdk-8   Source File: Manifest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 20
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
Example 21
Source Project: openjdk-8-source   Source File: Manifest.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * This <code>addDocument</code> method is used to add a new resource to the
 * signed info. A {@link com.sun.org.apache.xml.internal.security.signature.Reference} is built
 * from the supplied values.
 *
 * @param baseURI the URI of the resource where the XML instance was stored
 * @param referenceURI <code>URI</code> attribute in <code>Reference</code> for specifying
 * where data is
 * @param transforms com.sun.org.apache.xml.internal.security.signature.Transforms object with an ordered
 * list of transformations to be performed.
 * @param digestURI The digest algorithm URI to be used.
 * @param referenceId
 * @param referenceType
 * @throws XMLSignatureException
 */
public void addDocument(
    String baseURI, String referenceURI, Transforms transforms,
    String digestURI, String referenceId, String referenceType
) throws XMLSignatureException {
    // the this.doc is handed implicitly by the this.getOwnerDocument()
    Reference ref =
        new Reference(this.doc, baseURI, referenceURI, this, transforms, digestURI);

    if (referenceId != null) {
        ref.setId(referenceId);
    }

    if (referenceType != null) {
        ref.setType(referenceType);
    }

    // add Reference object to our cache vector
    this.references.add(ref);

    // add the Element of the Reference object to the Manifest/SignedInfo
    this.constructionElement.appendChild(ref.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 22
/**
 * Method getTransforms
 *
 * @throws XMLSecurityException
 * @return the transformations
 */
public Transforms getTransforms() throws XMLSecurityException {
    try {
        Element transformsElem =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_TRANSFORMS, 0);

        if (transformsElem != null) {
            return new Transforms(transformsElem, this.baseURI);
        }

        return null;
    } catch (XMLSignatureException ex) {
        throw new XMLSecurityException("empty", ex);
    }
}
 
Example 23
Source Project: jdk8u_jdk   Source File: Reference.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor Reference
 *
 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
 * @param baseURI the URI of the resource where the XML instance will be stored
 * @param referenceURI URI indicate where is data which will digested
 * @param manifest
 * @param transforms {@link Transforms} applied to data
 * @param messageDigestAlgorithm {@link MessageDigestAlgorithm Digest algorithm} which is
 * applied to the data
 * TODO should we throw XMLSignatureException if MessageDigestAlgoURI is wrong?
 * @throws XMLSignatureException
 */
protected Reference(
    Document doc, String baseURI, String referenceURI, Manifest manifest,
    Transforms transforms, String messageDigestAlgorithm
) throws XMLSignatureException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    this.baseURI = baseURI;
    this.manifest = manifest;

    this.setURI(referenceURI);

    // important: The ds:Reference must be added to the associated ds:Manifest
    //            or ds:SignedInfo _before_ the this.resolverResult() is called.
    // this.manifest.appendChild(this.constructionElement);
    // this.manifest.appendChild(this.doc.createTextNode("\n"));

    if (transforms != null) {
        this.transforms=transforms;
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
    MessageDigestAlgorithm mda =
        MessageDigestAlgorithm.getInstance(this.doc, messageDigestAlgorithm);

    digestMethodElem = mda.getElement();
    this.constructionElement.appendChild(digestMethodElem);
    XMLUtils.addReturnToElement(this.constructionElement);

    digestValueElement =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_DIGESTVALUE);

    this.constructionElement.appendChild(digestValueElement);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 24
Source Project: jdk8u_jdk   Source File: RetrievalMethod.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor RetrievalMethod
 *
 * @param doc
 * @param URI
 * @param transforms
 * @param Type
 */
public RetrievalMethod(Document doc, String URI, Transforms transforms, String Type) {
    super(doc);

    this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);

    if (Type != null) {
        this.constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
    }

    if (transforms != null) {
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
}
 
Example 25
Source Project: TencentKona-8   Source File: Reference.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor Reference
 *
 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
 * @param baseURI the URI of the resource where the XML instance will be stored
 * @param referenceURI URI indicate where is data which will digested
 * @param manifest
 * @param transforms {@link Transforms} applied to data
 * @param messageDigestAlgorithm {@link MessageDigestAlgorithm Digest algorithm} which is
 * applied to the data
 * TODO should we throw XMLSignatureException if MessageDigestAlgoURI is wrong?
 * @throws XMLSignatureException
 */
protected Reference(
    Document doc, String baseURI, String referenceURI, Manifest manifest,
    Transforms transforms, String messageDigestAlgorithm
) throws XMLSignatureException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    this.baseURI = baseURI;
    this.manifest = manifest;

    this.setURI(referenceURI);

    // important: The ds:Reference must be added to the associated ds:Manifest
    //            or ds:SignedInfo _before_ the this.resolverResult() is called.
    // this.manifest.appendChild(this.constructionElement);
    // this.manifest.appendChild(this.doc.createTextNode("\n"));

    if (transforms != null) {
        this.transforms=transforms;
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
    MessageDigestAlgorithm mda =
        MessageDigestAlgorithm.getInstance(this.doc, messageDigestAlgorithm);

    digestMethodElem = mda.getElement();
    this.constructionElement.appendChild(digestMethodElem);
    XMLUtils.addReturnToElement(this.constructionElement);

    digestValueElement =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_DIGESTVALUE);

    this.constructionElement.appendChild(digestValueElement);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 26
/**
 * Constructor RetrievalMethod
 *
 * @param doc
 * @param URI
 * @param transforms
 * @param Type
 */
public RetrievalMethod(Document doc, String URI, Transforms transforms, String Type) {
    super(doc);

    this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);

    if (Type != null) {
        this.constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
    }

    if (transforms != null) {
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
}
 
Example 27
Source Project: jdk8u-jdk   Source File: Reference.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor Reference
 *
 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
 * @param baseURI the URI of the resource where the XML instance will be stored
 * @param referenceURI URI indicate where is data which will digested
 * @param manifest
 * @param transforms {@link Transforms} applied to data
 * @param messageDigestAlgorithm {@link MessageDigestAlgorithm Digest algorithm} which is
 * applied to the data
 * TODO should we throw XMLSignatureException if MessageDigestAlgoURI is wrong?
 * @throws XMLSignatureException
 */
protected Reference(
    Document doc, String baseURI, String referenceURI, Manifest manifest,
    Transforms transforms, String messageDigestAlgorithm
) throws XMLSignatureException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    this.baseURI = baseURI;
    this.manifest = manifest;

    this.setURI(referenceURI);

    // important: The ds:Reference must be added to the associated ds:Manifest
    //            or ds:SignedInfo _before_ the this.resolverResult() is called.
    // this.manifest.appendChild(this.constructionElement);
    // this.manifest.appendChild(this.doc.createTextNode("\n"));

    if (transforms != null) {
        this.transforms=transforms;
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
    MessageDigestAlgorithm mda =
        MessageDigestAlgorithm.getInstance(this.doc, messageDigestAlgorithm);

    digestMethodElem = mda.getElement();
    this.constructionElement.appendChild(digestMethodElem);
    XMLUtils.addReturnToElement(this.constructionElement);

    digestValueElement =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_DIGESTVALUE);

    this.constructionElement.appendChild(digestValueElement);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 28
/**
 * Constructor RetrievalMethod
 *
 * @param doc
 * @param URI
 * @param transforms
 * @param Type
 */
public RetrievalMethod(Document doc, String URI, Transforms transforms, String Type) {
    super(doc);

    this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);

    if (Type != null) {
        this.constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
    }

    if (transforms != null) {
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
}
 
Example 29
Source Project: jdk8u60   Source File: Reference.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor Reference
 *
 * @param doc the {@link Document} in which <code>XMLsignature</code> is placed
 * @param baseURI the URI of the resource where the XML instance will be stored
 * @param referenceURI URI indicate where is data which will digested
 * @param manifest
 * @param transforms {@link Transforms} applied to data
 * @param messageDigestAlgorithm {@link MessageDigestAlgorithm Digest algorithm} which is
 * applied to the data
 * TODO should we throw XMLSignatureException if MessageDigestAlgoURI is wrong?
 * @throws XMLSignatureException
 */
protected Reference(
    Document doc, String baseURI, String referenceURI, Manifest manifest,
    Transforms transforms, String messageDigestAlgorithm
) throws XMLSignatureException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    this.baseURI = baseURI;
    this.manifest = manifest;

    this.setURI(referenceURI);

    // important: The ds:Reference must be added to the associated ds:Manifest
    //            or ds:SignedInfo _before_ the this.resolverResult() is called.
    // this.manifest.appendChild(this.constructionElement);
    // this.manifest.appendChild(this.doc.createTextNode("\n"));

    if (transforms != null) {
        this.transforms=transforms;
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
    MessageDigestAlgorithm mda =
        MessageDigestAlgorithm.getInstance(this.doc, messageDigestAlgorithm);

    digestMethodElem = mda.getElement();
    this.constructionElement.appendChild(digestMethodElem);
    XMLUtils.addReturnToElement(this.constructionElement);

    digestValueElement =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_DIGESTVALUE);

    this.constructionElement.appendChild(digestValueElement);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example 30
Source Project: JDKSourceCode1.8   Source File: RetrievalMethod.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor RetrievalMethod
 *
 * @param doc
 * @param URI
 * @param transforms
 * @param Type
 */
public RetrievalMethod(Document doc, String URI, Transforms transforms, String Type) {
    super(doc);

    this.constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);

    if (Type != null) {
        this.constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
    }

    if (transforms != null) {
        this.constructionElement.appendChild(transforms.getElement());
        XMLUtils.addReturnToElement(this.constructionElement);
    }
}