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

The following examples show how to use com.sun.org.apache.xml.internal.security.utils.I18n. 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 openjdk-jdk8u with GNU General Public License v2.0 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: DSAKeyValue.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #3
Source File: DSAKeyValue.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #4
Source File: DSAKeyValue.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #5
Source File: RSAKeyValue.java    From dragonwell8_jdk with GNU General Public License v2.0 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 #6
Source File: DSAKeyValue.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #7
Source File: DSAKeyValue.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #8
Source File: DSAKeyValue.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #9
Source File: RSAKeyValue.java    From TencentKona-8 with GNU General Public License v2.0 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 #10
Source File: DSAKeyValue.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #11
Source File: DSAKeyValue.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #12
Source File: RSAKeyValue.java    From openjdk-8 with GNU General Public License v2.0 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 #13
Source File: RSAKeyValue.java    From jdk8u-jdk with GNU General Public License v2.0 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 #14
Source File: RSAKeyValue.java    From jdk8u_jdk with GNU General Public License v2.0 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 #15
Source File: Manifest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * After verifying a {@link Manifest} or a {@link SignedInfo} using the
 * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods,
 * the individual results can be retrieved with this method.
 *
 * @param index an index of into a {@link Manifest} or a {@link SignedInfo}
 * @return the results of reference validation at the specified index
 * @throws XMLSecurityException
 */
public boolean getVerificationResult(int index) throws XMLSecurityException {
    if ((index < 0) || (index > this.getLength() - 1)) {
        Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
        Exception e =
            new IndexOutOfBoundsException(
                I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
            );

        throw new XMLSecurityException("generic.EmptyMessage", e);
    }

    if (this.verificationResults == null) {
        try {
            this.verifyReferences();
        } catch (Exception ex) {
            throw new XMLSecurityException("generic.EmptyMessage", ex);
        }
    }

    return this.verificationResults[index];
}
 
Example #16
Source File: RSAKeyValue.java    From jdk8u-jdk with GNU General Public License v2.0 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 #17
Source File: Manifest.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * After verifying a {@link Manifest} or a {@link SignedInfo} using the
 * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods,
 * the individual results can be retrieved with this method.
 *
 * @param index an index of into a {@link Manifest} or a {@link SignedInfo}
 * @return the results of reference validation at the specified index
 * @throws XMLSecurityException
 */
public boolean getVerificationResult(int index) throws XMLSecurityException {
    if ((index < 0) || (index > this.getLength() - 1)) {
        Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
        Exception e =
            new IndexOutOfBoundsException(
                I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
            );

        throw new XMLSecurityException("generic.EmptyMessage", e);
    }

    if (this.verificationResults == null) {
        try {
            this.verifyReferences();
        } catch (Exception ex) {
            throw new XMLSecurityException("generic.EmptyMessage", ex);
        }
    }

    return this.verificationResults[index];
}
 
Example #18
Source File: Manifest.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * After verifying a {@link Manifest} or a {@link SignedInfo} using the
 * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods,
 * the individual results can be retrieved with this method.
 *
 * @param index an index of into a {@link Manifest} or a {@link SignedInfo}
 * @return the results of reference validation at the specified index
 * @throws XMLSecurityException
 */
public boolean getVerificationResult(int index) throws XMLSecurityException {
    if ((index < 0) || (index > this.getLength() - 1)) {
        Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
        Exception e =
            new IndexOutOfBoundsException(
                I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
            );

        throw new XMLSecurityException("generic.EmptyMessage", e);
    }

    if (this.verificationResults == null) {
        try {
            this.verifyReferences();
        } catch (Exception ex) {
            throw new XMLSecurityException("generic.EmptyMessage", ex);
        }
    }

    return this.verificationResults[index];
}
 
Example #19
Source File: DSAKeyValue.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #20
Source File: RSAKeyValue.java    From hottub with GNU General Public License v2.0 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 #21
Source File: DSAKeyValue.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor DSAKeyValue
 *
 * @param doc
 * @param key
 * @throws IllegalArgumentException
 */
public DSAKeyValue(Document doc, Key key) throws IllegalArgumentException {
    super(doc);

    XMLUtils.addReturnToElement(this.constructionElement);

    if (key instanceof java.security.interfaces.DSAPublicKey) {
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getP(), Constants._TAG_P);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getQ(), Constants._TAG_Q);
        this.addBigIntegerElement(((DSAPublicKey) key).getParams().getG(), Constants._TAG_G);
        this.addBigIntegerElement(((DSAPublicKey) key).getY(), Constants._TAG_Y);
    } else {
        Object exArgs[] = { Constants._TAG_DSAKEYVALUE, key.getClass().getName() };

        throw new IllegalArgumentException(I18n.translate("KeyValue.IllegalArgument", exArgs));
    }
}
 
Example #22
Source File: Manifest.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * After verifying a {@link Manifest} or a {@link SignedInfo} using the
 * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods,
 * the individual results can be retrieved with this method.
 *
 * @param index an index of into a {@link Manifest} or a {@link SignedInfo}
 * @return the results of reference validation at the specified index
 * @throws XMLSecurityException
 */
public boolean getVerificationResult(int index) throws XMLSecurityException {
    if ((index < 0) || (index > this.getLength() - 1)) {
        Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
        Exception e =
            new IndexOutOfBoundsException(
                I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
            );

        throw new XMLSecurityException("generic.EmptyMessage", e);
    }

    if (this.verificationResults == null) {
        try {
            this.verifyReferences();
        } catch (Exception ex) {
            throw new XMLSecurityException("generic.EmptyMessage", ex);
        }
    }

    return this.verificationResults[index];
}
 
Example #23
Source File: Manifest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * After verifying a {@link Manifest} or a {@link SignedInfo} using the
 * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods,
 * the individual results can be retrieved with this method.
 *
 * @param index an index of into a {@link Manifest} or a {@link SignedInfo}
 * @return the results of reference validation at the specified index
 * @throws XMLSecurityException
 */
public boolean getVerificationResult(int index) throws XMLSecurityException {
    if ((index < 0) || (index > this.getLength() - 1)) {
        Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
        Exception e =
            new IndexOutOfBoundsException(
                I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
            );

        throw new XMLSecurityException("generic.EmptyMessage", e);
    }

    if (this.verificationResults == null) {
        try {
            this.verifyReferences();
        } catch (Exception ex) {
            throw new XMLSecurityException("generic.EmptyMessage", ex);
        }
    }

    return this.verificationResults[index];
}
 
Example #24
Source File: Manifest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * After verifying a {@link Manifest} or a {@link SignedInfo} using the
 * {@link Manifest#verifyReferences()} or {@link SignedInfo#verify()} methods,
 * the individual results can be retrieved with this method.
 *
 * @param index an index of into a {@link Manifest} or a {@link SignedInfo}
 * @return the results of reference validation at the specified index
 * @throws XMLSecurityException
 */
public boolean getVerificationResult(int index) throws XMLSecurityException {
    if ((index < 0) || (index > this.getLength() - 1)) {
        Object exArgs[] = { Integer.toString(index), Integer.toString(this.getLength()) };
        Exception e =
            new IndexOutOfBoundsException(
                I18n.translate("signature.Verification.IndexOutOfBounds", exArgs)
            );

        throw new XMLSecurityException("generic.EmptyMessage", e);
    }

    if (this.verificationResults == null) {
        try {
            this.verifyReferences();
        } catch (Exception ex) {
            throw new XMLSecurityException("generic.EmptyMessage", ex);
        }
    }

    return this.verificationResults[index];
}
 
Example #25
Source File: FuncHere.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The here function returns a node-set containing the attribute or
 * processing instruction node or the parent element of the text node
 * that directly bears the XPath expression.  This expression results
 * in an error if the containing XPath expression does not appear in the
 * same XML document against which the XPath expression is being evaluated.
 *
 * @param xctxt
 * @return the xobject
 * @throws javax.xml.transform.TransformerException
 */
@Override
public XObject execute(XPathContext xctxt)
    throws javax.xml.transform.TransformerException {

    Node xpathOwnerNode = (Node) xctxt.getOwnerObject();

    if (xpathOwnerNode == null) {
        return null;
    }

    int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);

    int currentNode = xctxt.getCurrentNode();
    DTM dtm = xctxt.getDTM(currentNode);
    int docContext = dtm.getDocument();

    if (DTM.NULL == docContext) {
        error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
    }

    {
        // check whether currentNode and the node containing the XPath expression
        // are in the same document
        Document currentDoc =
            XMLUtils.getOwnerDocument(dtm.getNode(currentNode));
        Document xpathOwnerDoc = XMLUtils.getOwnerDocument(xpathOwnerNode);

        if (currentDoc != xpathOwnerDoc) {
            throw new TransformerException(I18n.translate("xpath.funcHere.documentsDiffer"));
        }
    }

    XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
    NodeSetDTM nodeSet = nodes.mutableNodeset();

    {
        int hereNode = DTM.NULL;

        switch (dtm.getNodeType(xpathOwnerNodeDTM)) {

        case Node.ATTRIBUTE_NODE :
        case Node.PROCESSING_INSTRUCTION_NODE : {
            // returns a node-set containing the attribute /  processing instruction node
            hereNode = xpathOwnerNodeDTM;

            nodeSet.addNode(hereNode);

            break;
        }
        case Node.TEXT_NODE : {
            // returns a node-set containing the parent element of the
            // text node that directly bears the XPath expression
            hereNode = dtm.getParent(xpathOwnerNodeDTM);

            nodeSet.addNode(hereNode);

            break;
        }
        default :
            break;
        }
    }

    /** $todo$ Do I have to do this detach() call? */
    nodeSet.detach();

    return nodes;
}
 
Example #26
Source File: XMLSecurityException.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor XMLSecurityException
 *
 * @param msgID
 */
public XMLSecurityException(String msgID) {
    super(I18n.getExceptionMessage(msgID));

    this.msgID = msgID;
}
 
Example #27
Source File: Init.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Dynamically initialise the library by registering the default algorithms/implementations
 */
private static void dynamicInit() {
    //
    // Load the Resource Bundle - the default is the English resource bundle.
    // To load another resource bundle, call I18n.init(...) before calling this
    // method.
    //
    I18n.init("en", "US");

    if (log.isLoggable(java.util.logging.Level.FINE)) {
        log.log(java.util.logging.Level.FINE, "Registering default algorithms");
    }
    try {
        AccessController.doPrivileged(new PrivilegedExceptionAction<Void>(){
            @Override public Void run() throws XMLSecurityException {
                //
                // Bind the default prefixes
                //
                ElementProxy.registerDefaultPrefixes();

                //
                // Set the default Transforms
                //
                Transform.registerDefaultAlgorithms();

                //
                // Set the default signature algorithms
                //
                SignatureAlgorithm.registerDefaultAlgorithms();

                //
                // Set the default JCE algorithms
                //
                JCEMapper.registerDefaultAlgorithms();

                //
                // Set the default c14n algorithms
                //
                Canonicalizer.registerDefaultAlgorithms();

                //
                // Register the default resolvers
                //
                ResourceResolver.registerDefaultResolvers();

                //
                // Register the default key resolvers
                //
                KeyResolver.registerDefaultResolvers();

                return null;
            }
       });
    } catch (PrivilegedActionException ex) {
        XMLSecurityException xse = (XMLSecurityException)ex.getException();
        log.log(java.util.logging.Level.SEVERE, xse.getMessage(), xse);
        xse.printStackTrace();
    }
}
 
Example #28
Source File: XMLSecurityException.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor XMLSecurityException
 *
 * @param msgID
 */
public XMLSecurityException(String msgID) {
    super(I18n.getExceptionMessage(msgID));

    this.msgID = msgID;
}
 
Example #29
Source File: XMLSecurityRuntimeException.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructor XMLSecurityRuntimeException
 *
 * @param msgID
 */
public XMLSecurityRuntimeException(String msgID) {
    super(I18n.getExceptionMessage(msgID));

    this.msgID = msgID;
}
 
Example #30
Source File: XMLSecurityException.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Constructor XMLSecurityException
 *
 * @param msgID
 */
public XMLSecurityException(String msgID) {
    super(I18n.getExceptionMessage(msgID));

    this.msgID = msgID;
}