Search in sources :

Example 16 with XMLSignatureException

use of com.sun.org.apache.xml.internal.security.signature.XMLSignatureException in project jdk8u_jdk by JetBrains.

the class IntegrityHmac method engineInitSign.

/**
     * Method engineInitSign
     *
     * @param secretKey
     * @param algorithmParameterSpec
     * @throws XMLSignatureException
     */
protected void engineInitSign(Key secretKey, AlgorithmParameterSpec algorithmParameterSpec) throws XMLSignatureException {
    if (!(secretKey instanceof SecretKey)) {
        String supplied = secretKey.getClass().getName();
        String needed = SecretKey.class.getName();
        Object[] exArgs = { supplied, needed };
        throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
    }
    try {
        this.macAlgorithm.init(secretKey, algorithmParameterSpec);
    } catch (InvalidKeyException ex) {
        throw new XMLSignatureException("empty", ex);
    } catch (InvalidAlgorithmParameterException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
Also used : SecretKey(javax.crypto.SecretKey) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) InvalidKeyException(java.security.InvalidKeyException) XMLSignatureException(com.sun.org.apache.xml.internal.security.signature.XMLSignatureException)

Example 17 with XMLSignatureException

use of com.sun.org.apache.xml.internal.security.signature.XMLSignatureException in project jdk8u_jdk by JetBrains.

the class SignatureECDSA method engineInitSign.

/** @inheritDoc */
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
    if (!(privateKey instanceof PrivateKey)) {
        String supplied = privateKey.getClass().getName();
        String needed = PrivateKey.class.getName();
        Object[] exArgs = { supplied, needed };
        throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
    }
    try {
        this.signatureAlgorithm.initSign((PrivateKey) privateKey);
    } catch (InvalidKeyException ex) {
        throw new XMLSignatureException("empty", ex);
    }
}
Also used : PrivateKey(java.security.PrivateKey) InvalidKeyException(java.security.InvalidKeyException) XMLSignatureException(com.sun.org.apache.xml.internal.security.signature.XMLSignatureException)

Aggregations

XMLSignatureException (com.sun.org.apache.xml.internal.security.signature.XMLSignatureException)17 InvalidKeyException (java.security.InvalidKeyException)12 PrivateKey (java.security.PrivateKey)6 XMLSignature (com.sun.org.apache.xml.internal.security.signature.XMLSignature)5 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)5 SecretKey (javax.crypto.SecretKey)4 NoSuchProviderException (java.security.NoSuchProviderException)3 PublicKey (java.security.PublicKey)3 Signature (java.security.Signature)3 SignatureException (java.security.SignatureException)3 IOException (java.io.IOException)2 Document (org.w3c.dom.Document)2 AlgorithmAlreadyRegisteredException (com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException)1 XMLSecurityException (com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException)1 X509Data (com.sun.org.apache.xml.internal.security.keys.content.X509Data)1 XMLX509IssuerSerial (com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509IssuerSerial)1 KeyResolverException (com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException)1 File (java.io.File)1 MessageDigest (java.security.MessageDigest)1 Certificate (java.security.cert.Certificate)1