Search in sources :

Example 6 with CertificateEncodingException

use of javax.security.cert.CertificateEncodingException in project robovm by robovm.

the class X509CertificateTest method testGetInstance1.

/**
     * getInstance(InputStream inStream) method testing.
     */
public void testGetInstance1() {
    if (this.cert == null) {
        // Test can not be applied.
        return;
    }
    try {
        ByteArrayInputStream bais = new ByteArrayInputStream(cert.getEncoded());
        X509Certificate.getInstance(bais);
    } catch (java.security.cert.CertificateEncodingException e) {
        fail("Unexpected CertificateEncodingException was thrown.");
    } catch (CertificateEncodingException e) {
        fail("Unexpected CertificateEncodingException was thrown.");
    } catch (CertificateException e) {
    // The requested certificate type is not available.
    // Test pass..
    }
    // Regression for HARMONY-756
    try {
        X509Certificate.getInstance((InputStream) null);
        fail("No expected CertificateException");
    } catch (CertificateException e) {
    // expected;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CertificateEncodingException(javax.security.cert.CertificateEncodingException) CertificateException(javax.security.cert.CertificateException)

Example 7 with CertificateEncodingException

use of javax.security.cert.CertificateEncodingException in project robovm by robovm.

the class CertificateEncodingExceptionTest method testCertificateEncodingException03.

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

Example 8 with CertificateEncodingException

use of javax.security.cert.CertificateEncodingException in project robovm by robovm.

the class CertificateEncodingExceptionTest method testCertificateEncodingException01.

/**
     * Test for <code>CertificateEncodingException()</code> constructor
     * Assertion: constructs CertificateEncodingException with no detail message
     */
public void testCertificateEncodingException01() {
    CertificateEncodingException tE = new CertificateEncodingException();
    assertNull("getMessage() must return null.", tE.getMessage());
    assertNull("getCause() must return null", tE.getCause());
}
Also used : CertificateEncodingException(javax.security.cert.CertificateEncodingException)

Example 9 with CertificateEncodingException

use of javax.security.cert.CertificateEncodingException in project undertow by undertow-io.

the class SslClientCertAttribute method readAttribute.

@Override
public String readAttribute(HttpServerExchange exchange) {
    SSLSessionInfo ssl = exchange.getConnection().getSslSessionInfo();
    if (ssl == null) {
        return null;
    }
    X509Certificate[] certificates;
    try {
        certificates = ssl.getPeerCertificateChain();
        if (certificates.length > 0) {
            return Certificates.toPem(certificates[0]);
        }
        return null;
    } catch (SSLPeerUnverifiedException e) {
        return null;
    } catch (CertificateEncodingException e) {
        return null;
    } catch (RenegotiationRequiredException e) {
        return null;
    }
}
Also used : SSLSessionInfo(io.undertow.server.SSLSessionInfo) SSLPeerUnverifiedException(javax.net.ssl.SSLPeerUnverifiedException) CertificateEncodingException(javax.security.cert.CertificateEncodingException) X509Certificate(javax.security.cert.X509Certificate) RenegotiationRequiredException(io.undertow.server.RenegotiationRequiredException)

Aggregations

CertificateEncodingException (javax.security.cert.CertificateEncodingException)9 ByteArrayInputStream (java.io.ByteArrayInputStream)2 CertificateException (javax.security.cert.CertificateException)2 RenegotiationRequiredException (io.undertow.server.RenegotiationRequiredException)1 SSLSessionInfo (io.undertow.server.SSLSessionInfo)1 SSLPeerUnverifiedException (javax.net.ssl.SSLPeerUnverifiedException)1 X509Certificate (javax.security.cert.X509Certificate)1