use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.
the class DefaultAuthenticationEventExecutionPlanTests method verifyOperation.
@Test
public void verifyOperation() {
val context = PrincipalResolutionContext.builder().attributeRepository(CoreAuthenticationTestUtils.getAttributeRepository()).principalFactory(PrincipalFactoryUtils.newPrincipalFactory()).returnNullIfNoAttributes(false).principalNameTransformer(formUserId -> formUserId).useCurrentPrincipalId(false).resolveAttributes(true).attributeMerger(CoreAuthenticationUtils.getAttributeMerger(PrincipalAttributesCoreProperties.MergingStrategyTypes.REPLACE)).activeAttributeRepositoryIdentifiers(CollectionUtils.wrapSet(IPersonAttributeDao.WILDCARD)).build();
val plan = new DefaultAuthenticationEventExecutionPlan();
plan.registerAuthenticationPreProcessor(transaction -> false);
plan.registerAuthenticationMetadataPopulators(Set.of(new RememberMeAuthenticationMetaDataPopulator(new RememberMeAuthenticationProperties())));
plan.registerAuthenticationHandlerWithPrincipalResolvers(Set.of(new SimpleTestUsernamePasswordAuthenticationHandler()), new PersonDirectoryPrincipalResolver(context));
plan.registerAuthenticationPolicy(new AllCredentialsValidatedAuthenticationPolicy());
plan.registerAuthenticationPolicyResolver(transaction -> Set.of(new AllCredentialsValidatedAuthenticationPolicy()));
assertFalse(plan.getAuthenticationPolicies(new DefaultAuthenticationTransactionFactory().newTransaction(CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword())).isEmpty());
}
use of org.apereo.cas.configuration.model.core.ticket.RememberMeAuthenticationProperties in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeUserAgent.
@Test
public void verifyRememberMeUserAgent() {
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Chrome");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
val builder = newBuilder(c, new RememberMeAuthenticationProperties().setSupportedUserAgents("Chrome"));
val auth = builder.build();
assertEquals(true, auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME).get(0));
}
Aggregations