use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method newBuilder.
private AuthenticationBuilder newBuilder(final Credential credential) {
final CredentialMetaData meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
final AuthenticationHandler handler = new SimpleTestUsernamePasswordAuthenticationHandler();
final AuthenticationBuilder builder = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal()).addCredential(meta).addSuccess("test", new DefaultHandlerResult(handler, meta));
if (this.p.supports(credential)) {
this.p.populateAttributes(builder, credential);
}
return builder;
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class X509SubjectDNPrincipalResolverTests method verifyResolvePrincipalInternal.
@Test
public void verifyResolvePrincipalInternal() {
final X509CertificateCredential c = new X509CertificateCredential(new X509Certificate[] { VALID_CERTIFICATE });
c.setCertificate(VALID_CERTIFICATE);
assertEquals(VALID_CERTIFICATE.getSubjectDN().getName(), this.resolver.resolve(c, CoreAuthenticationTestUtils.getPrincipal(), new SimpleTestUsernamePasswordAuthenticationHandler()).getId());
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class PersonDirectoryPrincipalResolverLdaptiveTests method verifyChainedResolver.
@Test
public void verifyChainedResolver() {
this.getEntries().forEach(entry -> {
final String username = entry.getAttribute("sAMAccountName").getStringValue();
final String psw = entry.getAttribute(ATTR_NAME_PASSWORD).getStringValue();
final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
resolver.setAttributeRepository(this.attributeRepository);
final ChainingPrincipalResolver chain = new ChainingPrincipalResolver();
chain.setChain(Arrays.asList(resolver, new EchoingPrincipalResolver()));
final Map<String, Object> attributes = new HashMap<>(2);
attributes.put("a1", "v1");
attributes.put("a2", "v2");
final Principal p = chain.resolve(new UsernamePasswordCredential(username, psw), CoreAuthenticationTestUtils.getPrincipal(username, attributes), new SimpleTestUsernamePasswordAuthenticationHandler());
assertNotNull(p);
assertTrue(p.getAttributes().containsKey("displayName"));
assertTrue(p.getAttributes().containsKey("a1"));
assertTrue(p.getAttributes().containsKey("a2"));
});
}
use of org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler in project cas by apereo.
the class PersonDirectoryPrincipalResolverLdaptiveTests method verifyResolver.
@Test
public void verifyResolver() {
this.getEntries().forEach(entry -> {
final String username = entry.getAttribute("sAMAccountName").getStringValue();
final String psw = entry.getAttribute(ATTR_NAME_PASSWORD).getStringValue();
final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver();
resolver.setAttributeRepository(this.attributeRepository);
final Principal p = resolver.resolve(new UsernamePasswordCredential(username, psw), CoreAuthenticationTestUtils.getPrincipal(), new SimpleTestUsernamePasswordAuthenticationHandler());
assertNotNull(p);
assertTrue(p.getAttributes().containsKey("displayName"));
});
}
Aggregations