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);
}
}
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());
}
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);
}
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));
}
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));
}
Aggregations