com.sun.org.apache.xml.internal.security.utils.XMLUtils Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.security.utils.XMLUtils. 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: RSAKeyValue.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Constructor RSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public RSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.RSAPublicKey ) {
        this.addBigIntegerElement(
            ((RSAPublicKey) key).getModulus(), Constants._TAG_MODULUS
        );
        this.addBigIntegerElement(
            ((RSAPublicKey) key).getPublicExponent(), Constants._TAG_EXPONENT
        );
    } else {
        Object exArgs[] = { Constants._TAG_RSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #2
Source File: XMLSignatureInput.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the node set from input which was specified as the parameter of
 * {@link XMLSignatureInput} constructor
 * @param circumvent
 *
 * @return the node set
 * @throws SAXException
 * @throws IOException
 * @throws ParserConfigurationException
 * @throws CanonicalizationException
 */
public Set<Node> getNodeSet(boolean circumvent) throws ParserConfigurationException,
    IOException, SAXException, CanonicalizationException {
    if (inputNodeSet != null) {
        return inputNodeSet;
    }
    if (inputOctetStreamProxy == null && subNode != null) {
        if (circumvent) {
            XMLUtils.circumventBug2650(XMLUtils.getOwnerDocument(subNode));
        }
        inputNodeSet = new LinkedHashSet<Node>();
        XMLUtils.getSet(subNode, inputNodeSet, excludeNode, excludeComments);
        return inputNodeSet;
    } else if (isOctetStream()) {
        convertToNodes();
        Set<Node> result = new LinkedHashSet<Node>();
        XMLUtils.getSet(subNode, result, null, false);
        return result;
    }

    throw new RuntimeException("getNodeSet() called but no input data present");
}
 
Example #3
Source File: SingleKeyResolver.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method engineResolveSecretKey
 *
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved SecretKey key or null if no {@link SecretKey} could be obtained
 *
 * @throws KeyResolverException
 */
public SecretKey engineResolveSecretKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (secretKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return secretKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
Example #4
Source File: SingleKeyResolver.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method engineResolveSecretKey
 *
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved SecretKey key or null if no {@link SecretKey} could be obtained
 *
 * @throws KeyResolverException
 */
public SecretKey engineResolveSecretKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (secretKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return secretKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
Example #5
Source File: XPath2FilterContainer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method newInstances
 *
 * @param doc
 * @param params
 * @return the nodelist with the data
 */
public static NodeList newInstances(Document doc, String[][] params) {
    HelperNodeList nl = new HelperNodeList();

    XMLUtils.addReturnToElement(doc, nl);

    for (int i = 0; i < params.length; i++) {
        String type = params[i][0];
        String xpath = params[i][1];

        if (!(type.equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT)
            || type.equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT)
            || type.equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION))){
            throw new IllegalArgumentException("The type(" + i + ")=\"" + type
                                               + "\" is illegal");
        }

        XPath2FilterContainer c = new XPath2FilterContainer(doc, xpath, type);

        nl.appendChild(c.getElement());
        XMLUtils.addReturnToElement(doc, nl);
    }

    return nl;
}
 
Example #6
Source File: KeyInfoReferenceResolver.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Validate the Element referred to by the KeyInfoReference.
 *
 * @param referentElement
 *
 * @throws XMLSecurityException
 */
private void validateReference(Element referentElement) throws XMLSecurityException {
    if (!XMLUtils.elementIsInSignatureSpace(referentElement, Constants._TAG_KEYINFO)) {
        Object exArgs[] = { new QName(referentElement.getNamespaceURI(), referentElement.getLocalName()) };
        throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.WrongType", exArgs);
    }

    KeyInfo referent = new KeyInfo(referentElement, "");
    if (referent.containsKeyInfoReference()) {
        if (secureValidation) {
            throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.ReferenceWithSecure");
        } else {
            // Don't support chains of references at this time. If do support in the future, this is where the code
            // would go to validate that don't have a cycle, resulting in an infinite loop. This may be unrealistic
            // to implement, and/or very expensive given remote URI references.
            throw new XMLSecurityException("KeyInfoReferenceResolver.InvalidReferentElement.ReferenceWithoutSecure");
        }
    }

}
 
Example #7
Source File: Manifest.java    From jdk8u60 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 #8
Source File: SingleKeyResolver.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method engineResolvePrivateKey
 * @inheritDoc
 * @param element
 * @param baseURI
 * @param storage
 * @return resolved PrivateKey key or null if no {@link PrivateKey} could be obtained
 * @throws KeyResolverException
 */
public PrivateKey engineLookupAndResolvePrivateKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (privateKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return privateKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
Example #9
Source File: XMLSignatureInputDebugger.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method getHTMLRepresentation
 *
 * @return The HTML Representation.
 * @throws XMLSignatureException
 */
public String getHTMLRepresentation() throws XMLSignatureException {
    if ((this.xpathNodeSet == null) || (this.xpathNodeSet.size() == 0)) {
        return HTMLPrefix + "<blink>no node set, sorry</blink>" + HTMLSuffix;
    }

    // get only a single node as anchor to fetch the owner document
    Node n = this.xpathNodeSet.iterator().next();

    this.doc = XMLUtils.getOwnerDocument(n);

    try {
        this.writer = new StringWriter();

        this.canonicalizeXPathNodeSet(this.doc);
        this.writer.close();

        return this.writer.toString();
    } catch (IOException ex) {
        throw new XMLSignatureException("empty", ex);
    } finally {
        this.xpathNodeSet = null;
        this.doc = null;
        this.writer = null;
    }
}
 
Example #10
Source File: SignatureProperties.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs {@link SignatureProperties} from {@link Element}
 * @param element <code>SignatureProperties</code> element
 * @param BaseURI the URI of the resource where the XML instance was stored
 * @throws XMLSecurityException
 */
public SignatureProperties(Element element, String BaseURI) throws XMLSecurityException {
    super(element, BaseURI);

    Attr attr = element.getAttributeNodeNS(null, "Id");
    if (attr != null) {
        element.setIdAttributeNode(attr, true);
    }

    int length = getLength();
    for (int i = 0; i < length; i++) {
        Element propertyElem =
            XMLUtils.selectDsNode(this.constructionElement, Constants._TAG_SIGNATUREPROPERTY, i);
        Attr propertyAttr = propertyElem.getAttributeNodeNS(null, "Id");
        if (propertyAttr != null) {
            propertyElem.setIdAttributeNode(propertyAttr, true);
        }
    }
}
 
Example #11
Source File: IntegrityHmac.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Method engineAddContextToElement
 *
 * @param element
 */
public void engineAddContextToElement(Element element) {
    if (element == null) {
        throw new IllegalArgumentException("null element");
    }

    if (this.HMACOutputLengthSet) {
        Document doc = element.getOwnerDocument();
        Element HMElem =
            XMLUtils.createElementInSignatureSpace(doc, Constants._TAG_HMACOUTPUTLENGTH);
        Text HMText =
            doc.createTextNode(Integer.valueOf(this.HMACOutputLength).toString());

        HMElem.appendChild(HMText);
        XMLUtils.addReturnToElement(element);
        element.appendChild(HMElem);
        XMLUtils.addReturnToElement(element);
    }
}
 
Example #12
Source File: XPath2FilterContainer.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Method newInstances
 *
 * @param doc
 * @param params
 * @return the nodelist with the data
 */
public static NodeList newInstances(Document doc, String[][] params) {
    HelperNodeList nl = new HelperNodeList();

    XMLUtils.addReturnToElement(doc, nl);

    for (int i = 0; i < params.length; i++) {
        String type = params[i][0];
        String xpath = params[i][1];

        if (!(type.equals(XPath2FilterContainer._ATT_FILTER_VALUE_INTERSECT)
            || type.equals(XPath2FilterContainer._ATT_FILTER_VALUE_SUBTRACT)
            || type.equals(XPath2FilterContainer._ATT_FILTER_VALUE_UNION))){
            throw new IllegalArgumentException("The type(" + i + ")=\"" + type
                                               + "\" is illegal");
        }

        XPath2FilterContainer c = new XPath2FilterContainer(doc, xpath, type);

        nl.appendChild(c.getElement());
        XMLUtils.addReturnToElement(doc, nl);
    }

    return nl;
}
 
Example #13
Source File: XMLSignature.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Base64 encodes and sets the bytes as the content of the SignatureValue
 * Node.
 *
 * @param bytes bytes to be used by SignatureValue before Base64 encoding
 */
private void setSignatureValueElement(byte[] bytes) {

    while (signatureValueElement.hasChildNodes()) {
        signatureValueElement.removeChild(signatureValueElement.getFirstChild());
    }

    String base64codedValue = Base64.encode(bytes);

    if (base64codedValue.length() > 76 && !XMLUtils.ignoreLineBreaks()) {
        base64codedValue = "\n" + base64codedValue + "\n";
    }

    Text t = this.doc.createTextNode(base64codedValue);
    signatureValueElement.appendChild(t);
}
 
Example #14
Source File: SignedInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public String getInclusiveNamespaces() {
    String c14nMethodURI = c14nMethod.getAttributeNS(null, Constants._ATT_ALGORITHM);
    if (!(c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#") ||
        c14nMethodURI.equals("http://www.w3.org/2001/10/xml-exc-c14n#WithComments"))) {
        return null;
    }

    Element inclusiveElement = XMLUtils.getNextElement(c14nMethod.getFirstChild());

    if (inclusiveElement != null) {
        try {
            String inclusiveNamespaces =
                new InclusiveNamespaces(
                    inclusiveElement,
                    InclusiveNamespaces.ExclusiveCanonicalizationNamespace
                ).getInclusiveNamespaces();
            return inclusiveNamespaces;
        } catch (XMLSecurityException e) {
            return null;
        }
    }
    return null;
}
 
Example #15
Source File: SignedInfo.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor SignedInfo
 *
 * @param doc <code>SignedInfo</code> is placed in this document
 * @param signatureMethodURI URI representation of the Digest and
 *    Signature algorithm
 * @param hMACOutputLength
 * @param canonicalizationMethodURI URI representation of the
 *    Canonicalization method
 * @throws XMLSecurityException
 */
public SignedInfo(
    Document doc, String signatureMethodURI,
    int hMACOutputLength, String canonicalizationMethodURI
) throws XMLSecurityException {
    super(doc);

    c14nMethod =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_CANONICALIZATIONMETHOD);

    c14nMethod.setAttributeNS(null, Constants._ATT_ALGORITHM, canonicalizationMethodURI);
    this.constructionElement.appendChild(c14nMethod);
    XMLUtils.addReturnToElement(this.constructionElement);

    if (hMACOutputLength > 0) {
        this.signatureAlgorithm =
            new SignatureAlgorithm(this.doc, signatureMethodURI, hMACOutputLength);
    } else {
        this.signatureAlgorithm = new SignatureAlgorithm(this.doc, signatureMethodURI);
    }

    signatureMethod = this.signatureAlgorithm.getElement();
    this.constructionElement.appendChild(signatureMethod);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example #16
Source File: SingleKeyResolver.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method engineLookupAndResolvePublicKey
 *
 * @param element
 * @param baseURI
 * @param storage
 * @return null if no {@link PublicKey} could be obtained
 * @throws KeyResolverException
 */
public PublicKey engineLookupAndResolvePublicKey(
    Element element, String baseURI, StorageResolver storage
) throws KeyResolverException {
    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName() + "?");
    }

    if (publicKey != null
        && XMLUtils.elementIsInSignatureSpace(element, Constants._TAG_KEYNAME)) {
        String name = element.getFirstChild().getNodeValue();
        if (keyName.equals(name)) {
            return publicKey;
        }
    }

    log.log(java.util.logging.Level.FINE, "I can't");
    return null;
}
 
Example #17
Source File: XMLSignature.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Creates a XMLSignature in a Document
 * @param doc
 * @param baseURI
 * @param SignatureMethodElem
 * @param CanonicalizationMethodElem
 * @throws XMLSecurityException
 */
public XMLSignature(
    Document doc,
    String baseURI,
    Element SignatureMethodElem,
    Element CanonicalizationMethodElem
) throws XMLSecurityException {
    super(doc);

    String xmlnsDsPrefix = getDefaultPrefix(Constants.SignatureSpecNS);
    if (xmlnsDsPrefix == null || xmlnsDsPrefix.length() == 0) {
        this.constructionElement.setAttributeNS(
            Constants.NamespaceSpecNS, "xmlns", Constants.SignatureSpecNS
        );
    } else {
        this.constructionElement.setAttributeNS(
            Constants.NamespaceSpecNS, "xmlns:" + xmlnsDsPrefix, Constants.SignatureSpecNS
        );
    }
    XMLUtils.addReturnToElement(this.constructionElement);

    this.baseURI = baseURI;
    this.signedInfo =
        new SignedInfo(this.doc, SignatureMethodElem, CanonicalizationMethodElem);

    this.constructionElement.appendChild(this.signedInfo.getElement());
    XMLUtils.addReturnToElement(this.constructionElement);

    // create an empty SignatureValue; this is filled by setSignatureValueElement
    signatureValueElement =
        XMLUtils.createElementInSignatureSpace(this.doc, Constants._TAG_SIGNATUREVALUE);

    this.constructionElement.appendChild(signatureValueElement);
    XMLUtils.addReturnToElement(this.constructionElement);
}
 
Example #18
Source File: KeyInfo.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method itemKeyInfoReference
 *
 * @param i
 * @return the asked KeyInfoReference element, null if the index is too big
 * @throws XMLSecurityException
 */
public KeyInfoReference itemKeyInfoReference(int i) throws XMLSecurityException {
    Element e =
        XMLUtils.selectDs11Node(
            this.constructionElement.getFirstChild(), Constants._TAG_KEYINFOREFERENCE, i);

    if (e != null) {
        return new KeyInfoReference(e, this.baseURI);
    }
    return null;
}
 
Example #19
Source File: X509Data.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method itemIssuerSerial
 *
 * @param i
 * @return the X509IssuerSerial, null if not present
 * @throws XMLSecurityException
 */
public XMLX509IssuerSerial itemIssuerSerial(int i) throws XMLSecurityException {
    Element e =
        XMLUtils.selectDsNode(
            this.constructionElement.getFirstChild(), Constants._TAG_X509ISSUERSERIAL, i);

    if (e != null) {
        return new XMLX509IssuerSerial(e, this.baseURI);
    }
    return null;
}
 
Example #20
Source File: DSAKeyValue.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param P
 * @param Q
 * @param G
 * @param Y
 */
public DSAKeyValue(Document doc, BigInteger P, BigInteger Q, BigInteger G, BigInteger Y) {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);
    this.addBigIntegerElement(P, Constants._TAG_P);
    this.addBigIntegerElement(Q, Constants._TAG_Q);
    this.addBigIntegerElement(G, Constants._TAG_G);
    this.addBigIntegerElement(Y, Constants._TAG_Y);
}
 
Example #21
Source File: XMLSignature.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the KeyInfo child. If we are in signing mode and the KeyInfo
 * does not exist yet, it is created on demand and added to the Signature.
 * <br>
 * This allows to add arbitrary content to the KeyInfo during signing.
 *
 * @return the KeyInfo object
 */
public KeyInfo getKeyInfo() {
    // check to see if we are signing and if we have to create a keyinfo
    if (this.state == MODE_SIGN && this.keyInfo == null) {

        // create the KeyInfo
        this.keyInfo = new KeyInfo(this.doc);

        // get the Element from KeyInfo
        Element keyInfoElement = this.keyInfo.getElement();
        Element firstObject =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_OBJECT, 0
            );

        if (firstObject != null) {
            // add it before the object
            this.constructionElement.insertBefore(keyInfoElement, firstObject);
            XMLUtils.addReturnBeforeChild(this.constructionElement, firstObject);
        } else {
            // add it as the last element to the signature
            this.constructionElement.appendChild(keyInfoElement);
            XMLUtils.addReturnToElement(this.constructionElement);
        }
    }

    return this.keyInfo;
}
 
Example #22
Source File: Transforms.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the nonnegative number of transformations.
 *
 * @return the number of transformations
 */
public int getLength() {
    if (transforms == null) {
        transforms =
            XMLUtils.selectDsNodes(this.constructionElement.getFirstChild(), "Transform");
    }
    return transforms.length;
}
 
Example #23
Source File: RSAKeyValue.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor RSAKeyValue
 *
 * @param doc
 * @param modulus
 * @param exponent
 */
public RSAKeyValue(Document doc, BigInteger modulus, BigInteger exponent) {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);
    this.addBigIntegerElement(modulus, Constants._TAG_MODULUS);
    this.addBigIntegerElement(exponent, Constants._TAG_EXPONENT);
}
 
Example #24
Source File: XMLSignature.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the KeyInfo child. If we are in signing mode and the KeyInfo
 * does not exist yet, it is created on demand and added to the Signature.
 * <br>
 * This allows to add arbitrary content to the KeyInfo during signing.
 *
 * @return the KeyInfo object
 */
public KeyInfo getKeyInfo() {
    // check to see if we are signing and if we have to create a keyinfo
    if (this.state == MODE_SIGN && this.keyInfo == null) {

        // create the KeyInfo
        this.keyInfo = new KeyInfo(this.doc);

        // get the Element from KeyInfo
        Element keyInfoElement = this.keyInfo.getElement();
        Element firstObject =
            XMLUtils.selectDsNode(
                this.constructionElement.getFirstChild(), Constants._TAG_OBJECT, 0
            );

        if (firstObject != null) {
            // add it before the object
            this.constructionElement.insertBefore(keyInfoElement, firstObject);
            XMLUtils.addReturnBeforeChild(this.constructionElement, firstObject);
        } else {
            // add it as the last element to the signature
            this.constructionElement.appendChild(keyInfoElement);
            XMLUtils.addReturnToElement(this.constructionElement);
        }
    }

    return this.keyInfo;
}
 
Example #25
Source File: DSAKeyValue.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param P
 * @param Q
 * @param G
 * @param Y
 */
public DSAKeyValue(Document doc, BigInteger P, BigInteger Q, BigInteger G, BigInteger Y) {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);
    this.addBigIntegerElement(P, Constants._TAG_P);
    this.addBigIntegerElement(Q, Constants._TAG_Q);
    this.addBigIntegerElement(G, Constants._TAG_G);
    this.addBigIntegerElement(Y, Constants._TAG_Y);
}
 
Example #26
Source File: KeyInfo.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method itemPGPData
 *
 * @param i
 * @return the asked PGPData element, null if the index is too big
 * @throws XMLSecurityException
 */
public PGPData itemPGPData(int i) throws XMLSecurityException {
    Element e =
        XMLUtils.selectDsNode(
            this.constructionElement.getFirstChild(), Constants._TAG_PGPDATA, i);

    if (e != null) {
        return new PGPData(e, this.baseURI);
    }
    return null;
}
 
Example #27
Source File: TransformXPath2Filter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Method rooted
 * @param currentNode
 * @param nodeList
 *
 * @return if rooted bye the rootnodes
 */
static boolean rooted(Node currentNode, Set<Node> nodeList) {
    if (nodeList.isEmpty()) {
        return false;
    }
    if (nodeList.contains(currentNode)) {
        return true;
    }
    for (Node rootNode : nodeList) {
        if (XMLUtils.isDescendantOrSelf(rootNode, currentNode)) {
            return true;
        }
    }
    return false;
}
 
Example #28
Source File: Canonicalizer11.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
protected void circumventBugIfNeeded(XMLSignatureInput input)
    throws CanonicalizationException, ParserConfigurationException,
    IOException, SAXException {
    if (!input.isNeedsToBeExpanded()) {
        return;
    }
    Document doc = null;
    if (input.getSubNode() != null) {
        doc = XMLUtils.getOwnerDocument(input.getSubNode());
    } else {
        doc = XMLUtils.getOwnerDocument(input.getNodeSet());
    }
    XMLUtils.circumventBug2650(doc);
}
 
Example #29
Source File: Canonicalizer20010315.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void circumventBugIfNeeded(XMLSignatureInput input)
    throws CanonicalizationException, ParserConfigurationException, IOException, SAXException {
    if (!input.isNeedsToBeExpanded()) {
        return;
    }
    Document doc = null;
    if (input.getSubNode() != null) {
        doc = XMLUtils.getOwnerDocument(input.getSubNode());
    } else {
        doc = XMLUtils.getOwnerDocument(input.getNodeSet());
    }
    XMLUtils.circumventBug2650(doc);
}
 
Example #30
Source File: XMLSignature.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the <code>i<code>th <code>ds:Object</code> child of the signature
 * or null if no such <code>ds:Object</code> element exists.
 *
 * @param i
 * @return the <code>i<code>th <code>ds:Object</code> child of the signature
 * or null if no such <code>ds:Object</code> element exists.
 */
public ObjectContainer getObjectItem(int i) {
    Element objElem =
        XMLUtils.selectDsNode(
            this.constructionElement.getFirstChild(), Constants._TAG_OBJECT, i
        );

    try {
        return new ObjectContainer(objElem, this.baseURI);
    } catch (XMLSecurityException ex) {
        return null;
    }
}