use of org.apereo.cas.authentication.AcceptUsersAuthenticationHandler in project cas by apereo.
the class CasCoreAuthenticationHandlersConfiguration method acceptUsersAuthenticationHandler.
@RefreshScope
@Bean
public AuthenticationHandler acceptUsersAuthenticationHandler() {
final AcceptAuthenticationProperties acceptAuthenticationProperties = casProperties.getAuthn().getAccept();
final HashMap<String, String> users = new HashMap<>();
final AcceptUsersAuthenticationHandler h = new AcceptUsersAuthenticationHandler(acceptAuthenticationProperties.getName(), servicesManager, acceptUsersPrincipalFactory(), null, users);
h.setUsers(getParsedUsers());
h.setPasswordEncoder(Beans.newPasswordEncoder(acceptAuthenticationProperties.getPasswordEncoder()));
if (acceptPasswordPolicyConfiguration != null) {
h.setPasswordPolicyConfiguration(acceptPasswordPolicyConfiguration);
}
h.setPrincipalNameTransformer(Beans.newPrincipalNameTransformer(acceptAuthenticationProperties.getPrincipalTransformation()));
return h;
}
use of org.apereo.cas.authentication.AcceptUsersAuthenticationHandler in project cas by apereo.
the class KryoTranscoderTests method verifyEncodeDecodeTGTImpl.
@Test
public void verifyEncodeDecodeTGTImpl() throws Exception {
final Credential userPassCredential = new UsernamePasswordCredential(USERNAME, PASSWORD);
final AuthenticationBuilder bldr = new DefaultAuthenticationBuilder(new DefaultPrincipalFactory().createPrincipal("user", new HashMap<>(this.principalAttributes)));
bldr.setAttributes(new HashMap<>(this.principalAttributes));
bldr.setAuthenticationDate(ZonedDateTime.now());
bldr.addCredential(new BasicCredentialMetaData(userPassCredential));
bldr.addFailure("error", AccountNotFoundException.class);
bldr.addSuccess("authn", new DefaultHandlerResult(new AcceptUsersAuthenticationHandler(""), new BasicCredentialMetaData(userPassCredential)));
final TicketGrantingTicket expectedTGT = new TicketGrantingTicketImpl(TGT_ID, RegisteredServiceTestUtils.getService(), null, bldr.build(), new NeverExpiresExpirationPolicy());
final ServiceTicket ticket = expectedTGT.grantServiceTicket(ST_ID, RegisteredServiceTestUtils.getService(), new NeverExpiresExpirationPolicy(), false, true);
CachedData result = transcoder.encode(expectedTGT);
final TicketGrantingTicket resultTicket = (TicketGrantingTicket) transcoder.decode(result);
assertEquals(expectedTGT, resultTicket);
result = transcoder.encode(ticket);
final ServiceTicket resultStTicket = (ServiceTicket) transcoder.decode(result);
assertEquals(ticket, resultStTicket);
}
use of org.apereo.cas.authentication.AcceptUsersAuthenticationHandler in project cas by apereo.
the class RegisteredServiceAuthenticationHandlerResolverTests method setUp.
@Before
public void setUp() throws Exception {
final InMemoryServiceRegistry dao = new InMemoryServiceRegistry();
final List<RegisteredService> list = new ArrayList<>();
AbstractRegisteredService svc = RegisteredServiceTestUtils.getRegisteredService("serviceid1");
svc.setRequiredHandlers(Stream.of("handler1", "handler3").collect(Collectors.toSet()));
list.add(svc);
svc = RegisteredServiceTestUtils.getRegisteredService("serviceid2");
svc.setRequiredHandlers(Collections.emptySet());
list.add(svc);
dao.setRegisteredServices(list);
this.defaultServicesManager = new DefaultServicesManager(dao);
this.defaultServicesManager.load();
final AcceptUsersAuthenticationHandler handler1 = new AcceptUsersAuthenticationHandler("handler1");
final AcceptUsersAuthenticationHandler handler2 = new AcceptUsersAuthenticationHandler("handler2");
final AcceptUsersAuthenticationHandler handler3 = new AcceptUsersAuthenticationHandler("handler3");
this.handlers = Stream.of(handler1, handler2, handler3).collect(Collectors.toSet());
}
use of org.apereo.cas.authentication.AcceptUsersAuthenticationHandler in project cas by apereo.
the class CasMultifactorTestAuthenticationEventExecutionPlanConfiguration method configureAuthenticationExecutionPlan.
@Override
public void configureAuthenticationExecutionPlan(final AuthenticationEventExecutionPlan plan) {
final HashMap<String, String> users = new HashMap<>();
users.put("alice", "alice");
users.put("bob", "bob");
users.put("mallory", "mallory");
final HashMap<String, String> credentials = new HashMap<>();
credentials.put("alice", "31415");
credentials.put("bob", "62831");
credentials.put("mallory", "14142");
plan.registerAuthenticationHandler(new AcceptUsersAuthenticationHandler("", null, null, null, users));
plan.registerAuthenticationHandler(new TestOneTimePasswordAuthenticationHandler(credentials));
}
Aggregations