Search in sources :

Example 51 with SignatureException

use of java.security.SignatureException in project j2objc by google.

the class SignatureExceptionTest method testSignatureException03.

/**
     * Test for <code>SignatureException(String)</code> constructor Assertion:
     * constructs SignatureException when <code>msg</code> is null
     */
public void testSignatureException03() {
    String msg = null;
    SignatureException tE = new SignatureException(msg);
    assertNull("getMessage() must return null.", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : SignatureException(java.security.SignatureException)

Example 52 with SignatureException

use of java.security.SignatureException in project j2objc by google.

the class SignatureExceptionTest method testSignatureException02.

/**
     * Test for <code>SignatureException(String)</code> constructor Assertion:
     * constructs SignatureException with detail message msg. Parameter
     * <code>msg</code> is not null.
     */
public void testSignatureException02() {
    SignatureException tE;
    for (int i = 0; i < msgs.length; i++) {
        tE = new SignatureException(msgs[i]);
        assertEquals("getMessage() must return: ".concat(msgs[i]), tE.getMessage(), msgs[i]);
        assertNull("getCause() must return null", tE.getCause());
    }
}
Also used : SignatureException(java.security.SignatureException)

Example 53 with SignatureException

use of java.security.SignatureException in project j2objc by google.

the class SignatureExceptionTest method testSignatureException08.

/**
     * Test for <code>SignatureException(String, Throwable)</code> constructor
     * Assertion: constructs SignatureException when <code>cause</code> is not
     * null <code>msg</code> is null
     */
public void testSignatureException08() {
    SignatureException tE = new SignatureException(null, tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        assertTrue("getMessage() must should ".concat(toS), (getM.indexOf(toS) != -1));
    }
    assertNotNull("getCause() must not return null", tE.getCause());
    assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
}
Also used : SignatureException(java.security.SignatureException)

Example 54 with SignatureException

use of java.security.SignatureException in project j2objc by google.

the class SignatureExceptionTest method testSignatureException06.

/**
     * Test for <code>SignatureException(String, Throwable)</code> constructor
     * Assertion: constructs SignatureException when <code>cause</code> is
     * null <code>msg</code> is null
     */
public void testSignatureException06() {
    SignatureException tE = new SignatureException(null, null);
    assertNull("getMessage() must return null", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : SignatureException(java.security.SignatureException)

Example 55 with SignatureException

use of java.security.SignatureException in project j2objc by google.

the class X509CRLImpl method verify.

/**
     * Verifies that this CRL was signed using the
     * private key that corresponds to the given public key,
     * and that the signature verification was computed by
     * the given provider.
     *
     * @param key the PublicKey used to carry out the verification.
     * @param sigProvider the name of the signature provider.
     *
     * @exception NoSuchAlgorithmException on unsupported signature
     * algorithms.
     * @exception InvalidKeyException on incorrect key.
     * @exception NoSuchProviderException on incorrect provider.
     * @exception SignatureException on signature errors.
     * @exception CRLException on encoding errors.
     */
public synchronized void verify(PublicKey key, String sigProvider) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
    if (sigProvider == null) {
        sigProvider = "";
    }
    if ((verifiedPublicKey != null) && verifiedPublicKey.equals(key)) {
        // this public key. Make sure providers match, too.
        if (sigProvider.equals(verifiedProvider)) {
            return;
        }
    }
    if (signedCRL == null) {
        throw new CRLException("Uninitialized CRL");
    }
    Signature sigVerf = null;
    if (sigProvider.length() == 0) {
        sigVerf = Signature.getInstance(sigAlgId.getName());
    } else {
        sigVerf = Signature.getInstance(sigAlgId.getName(), sigProvider);
    }
    sigVerf.initVerify(key);
    if (tbsCertList == null) {
        throw new CRLException("Uninitialized CRL");
    }
    sigVerf.update(tbsCertList, 0, tbsCertList.length);
    if (!sigVerf.verify(signature)) {
        throw new SignatureException("Signature does not match.");
    }
    verifiedPublicKey = key;
    verifiedProvider = sigProvider;
}
Also used : Signature(java.security.Signature) SignatureException(java.security.SignatureException) CRLException(java.security.cert.CRLException)

Aggregations

SignatureException (java.security.SignatureException)196 InvalidKeyException (java.security.InvalidKeyException)94 Signature (java.security.Signature)80 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)66 IOException (java.io.IOException)51 PublicKey (java.security.PublicKey)34 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)26 X509Certificate (java.security.cert.X509Certificate)19 ByteArrayInputStream (java.io.ByteArrayInputStream)16 BigInteger (java.math.BigInteger)16 CertificateException (java.security.cert.CertificateException)16 ArrayList (java.util.ArrayList)14 MySignature1 (org.apache.harmony.security.tests.support.MySignature1)14 ClientException (edu.umass.cs.gnscommon.exceptions.client.ClientException)12 NoSuchProviderException (java.security.NoSuchProviderException)12 PrivateKey (java.security.PrivateKey)12 KeyStoreException (android.security.KeyStoreException)10 KeyFactory (java.security.KeyFactory)10 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 CertificateEncodingException (java.security.cert.CertificateEncodingException)9