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

The following examples show how to use com.sun.org.apache.xml.internal.security.transforms.Transforms. 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 File: Reference.java    From jdk8u60 with 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 #2
Source File: RetrievalMethodResolver.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #3
Source File: RetrievalMethod.java    From openjdk-jdk8u with 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 #4
Source File: Manifest.java    From openjdk-jdk9 with 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
Source File: RetrievalMethodResolver.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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
Source File: RetrievalMethodResolver.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 File: Manifest.java    From jdk1.8-source-analysis with 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 #8
Source File: RetrievalMethod.java    From jdk1.8-source-analysis with 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 #9
Source File: Manifest.java    From openjdk-8-source with 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 #10
Source File: RetrievalMethod.java    From openjdk-jdk8u-backup with 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 #11
Source File: Manifest.java    From dragonwell8_jdk with 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 #12
Source File: Manifest.java    From openjdk-8 with 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 File: RetrievalMethod.java    From openjdk-8 with 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 #14
Source File: Reference.java    From jdk8u-jdk with 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 File: RetrievalMethod.java    From jdk8u-dev-jdk with 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 #16
Source File: Reference.java    From TencentKona-8 with 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 #17
Source File: Manifest.java    From TencentKona-8 with 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 #18
Source File: RetrievalMethodResolver.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #19
Source File: RetrievalMethod.java    From JDKSourceCode1.8 with 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 #20
Source File: Reference.java    From jdk8u-dev-jdk with 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 #21
Source File: RetrievalMethodResolver.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #22
Source File: Reference.java    From dragonwell8_jdk with 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 #23
Source File: Reference.java    From jdk8u-jdk with 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 File: RetrievalMethod.java    From TencentKona-8 with 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 File: RetrievalMethod.java    From openjdk-jdk8u-backup with 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 #26
Source File: Reference.java    From jdk8u60 with 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 #27
Source File: Reference.java    From TencentKona-8 with 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
Source File: Reference.java    From jdk8u_jdk with 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 #29
Source File: RetrievalMethod.java    From openjdk-jdk8u with 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 #30
Source File: RetrievalMethod.java    From JDKSourceCode1.8 with 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);
    }
}