Search in sources :

Example 31 with CertificateParsingException

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

the class CertificateParsingExceptionTest method testCertificateParsingException09.

/**
 * Test for <code>CertificateParsingException(String, Throwable)</code>
 * constructor Assertion: constructs CertificateParsingException when
 * <code>cause</code> is not null <code>msg</code> is not null
 */
public void testCertificateParsingException09() {
    CertificateParsingException tE;
    for (int i = 0; i < msgs.length; i++) {
        tE = new CertificateParsingException(msgs[i], tCause);
        String getM = tE.getMessage();
        String toS = tCause.toString();
        if (msgs[i].length() > 0) {
            assertTrue("getMessage() must contain ".concat(msgs[i]), getM.indexOf(msgs[i]) != -1);
            if (!getM.equals(msgs[i])) {
                assertTrue("getMessage() should contain ".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 32 with CertificateParsingException

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

the class CertificateParsingExceptionTest method testCertificateParsingException03.

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

Example 33 with CertificateParsingException

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

the class CertificateParsingExceptionTest method testCertificateParsingException05.

/**
 * Test for <code>CertificateParsingException(Throwable)</code>
 * constructor Assertion: constructs CertificateParsingException when
 * <code>cause</code> is not null
 */
public void testCertificateParsingException05() {
    CertificateParsingException tE = new CertificateParsingException(tCause);
    if (tE.getMessage() != null) {
        String toS = tCause.toString();
        String getM = tE.getMessage();
        assertTrue("getMessage() should contain ".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 34 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project cas by apereo.

the class X509SubjectAlternativeNameUPNPrincipalResolverTests method verifyAlternate.

@Test
public void verifyAlternate() throws Exception {
    val context = PrincipalResolutionContext.builder().attributeMerger(CoreAuthenticationUtils.getAttributeMerger(PrincipalAttributesCoreProperties.MergingStrategyTypes.REPLACE)).attributeRepository(CoreAuthenticationTestUtils.getAttributeRepository()).principalFactory(PrincipalFactoryUtils.newPrincipalFactory()).returnNullIfNoAttributes(false).principalNameTransformer(formUserId -> formUserId).useCurrentPrincipalId(false).resolveAttributes(true).activeAttributeRepositoryIdentifiers(CollectionUtils.wrapSet(IPersonAttributeDao.WILDCARD)).build();
    val resolver = new X509SubjectAlternativeNameUPNPrincipalResolver(context);
    resolver.setX509AttributeExtractor(new DefaultX509AttributeExtractor());
    val certificate = mock(X509Certificate.class);
    when(certificate.getSubjectAlternativeNames()).thenThrow(new CertificateParsingException());
    assertNull(resolver.resolvePrincipalInternal(certificate));
}
Also used : lombok.val(lombok.val) CertificateParsingException(java.security.cert.CertificateParsingException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with CertificateParsingException

use of java.security.cert.CertificateParsingException in project cas by apereo.

the class X509SubjectAlternativeNameRFC822EmailPrincipalResolverTests method verifyAlternate.

@Test
public void verifyAlternate() throws Exception {
    val context = PrincipalResolutionContext.builder().attributeMerger(CoreAuthenticationUtils.getAttributeMerger(PrincipalAttributesCoreProperties.MergingStrategyTypes.REPLACE)).attributeRepository(CoreAuthenticationTestUtils.getAttributeRepository()).principalFactory(PrincipalFactoryUtils.newPrincipalFactory()).returnNullIfNoAttributes(false).principalNameTransformer(formUserId -> formUserId).useCurrentPrincipalId(false).resolveAttributes(true).activeAttributeRepositoryIdentifiers(CollectionUtils.wrapSet(IPersonAttributeDao.WILDCARD)).build();
    val resolver = new X509SubjectAlternativeNameRFC822EmailPrincipalResolver(context);
    resolver.setX509AttributeExtractor(new DefaultX509AttributeExtractor());
    val certificate = mock(X509Certificate.class);
    when(certificate.getSubjectAlternativeNames()).thenThrow(new CertificateParsingException());
    assertNull(resolver.resolvePrincipalInternal(certificate));
}
Also used : lombok.val(lombok.val) CertificateParsingException(java.security.cert.CertificateParsingException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CertificateParsingException (java.security.cert.CertificateParsingException)72 List (java.util.List)25 IOException (java.io.IOException)18 ArrayList (java.util.ArrayList)18 X509Certificate (java.security.cert.X509Certificate)15 CertificateException (java.security.cert.CertificateException)13 Collection (java.util.Collection)12 X500Principal (javax.security.auth.x500.X500Principal)11 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