use of org.apereo.cas.authentication.metadata.RememberMeAuthenticationMetaDataPopulator 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.authentication.metadata.RememberMeAuthenticationMetaDataPopulator in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method newBuilder.
private static AuthenticationBuilder newBuilder(final Credential credential, final RememberMeAuthenticationProperties properties) {
val populator = new RememberMeAuthenticationMetaDataPopulator(properties);
val meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
val handler = new SimpleTestUsernamePasswordAuthenticationHandler();
val builder = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal()).addCredential(meta).addSuccess("test", new DefaultAuthenticationHandlerExecutionResult(handler, meta));
if (populator.supports(credential)) {
populator.populateAttributes(builder, new DefaultAuthenticationTransactionFactory().newTransaction(credential));
}
return builder;
}
Aggregations