Search in sources :

Example 66 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project j2objc by google.

the class CertificateParsingExceptionTest method testCertificateParsingException08.

/**
 * Test for <code>CertificateParsingException(String, Throwable)</code>
 * constructor Assertion: constructs CertificateParsingException when
 * <code>cause</code> is not null <code>msg</code> is null
 */
public void testCertificateParsingException08() {
    CertificateParsingException tE = new CertificateParsingException(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 : CertificateParsingException(java.security.cert.CertificateParsingException)

Example 67 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project j2objc by google.

the class CertificateParsingExceptionTest method testCertificateParsingException06.

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

Example 68 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project j2objc by google.

the class CertificateParsingExceptionTest method testCertificateParsingException02.

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

Example 69 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project j2objc by google.

the class CertificateParsingExceptionTest method testCertificateParsingException07.

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

Example 70 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project webofneeds by researchstudio-sat.

the class CertificateService method getWebIdFromSubjectAlternativeNames.

public static List<URI> getWebIdFromSubjectAlternativeNames(final X509Certificate cert) throws CertificateParsingException {
    List<URI> webIDs = new ArrayList<>();
    Collection<List<?>> alternativeNames = cert.getSubjectAlternativeNames();
    if (alternativeNames != null) {
        for (List<?> alternativeName : alternativeNames) {
            Integer id = (Integer) alternativeName.get(0);
            // This is how subject's webID is represented in the certificate.
            if (id == 6) {
                try {
                    URI webID = new URI((String) alternativeName.get(1));
                    webIDs.add(webID);
                } catch (URISyntaxException e) {
                    throw new CertificateParsingException("Could not retrieve webID from SAN", e);
                }
            }
        }
    }
    return webIDs;
}
Also used : BigInteger(java.math.BigInteger) CertificateParsingException(java.security.cert.CertificateParsingException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

CertificateParsingException (java.security.cert.CertificateParsingException)75 List (java.util.List)27 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)18 X509Certificate (java.security.cert.X509Certificate)16 CertificateException (java.security.cert.CertificateException)14 Collection (java.util.Collection)13 X500Principal (javax.security.auth.x500.X500Principal)13 BigInteger (java.math.BigInteger)8 InvalidKeyException (java.security.InvalidKeyException)7 HashMap (java.util.HashMap)7 DERIA5String (org.bouncycastle.asn1.DERIA5String)7 DEROctetString (org.bouncycastle.asn1.DEROctetString)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 NoSuchProviderException (java.security.NoSuchProviderException)6 SignatureException (java.security.SignatureException)6 CertificateEncodingException (java.security.cert.CertificateEncodingException)6 CertificateExpiredException (java.security.cert.CertificateExpiredException)6 CertificateNotYetValidException (java.security.cert.CertificateNotYetValidException)6 GeneralName (org.bouncycastle.asn1.x509.GeneralName)6