use of org.apereo.cas.authentication.DefaultAuthenticationBuilder in project cas by apereo.
the class AtLeastOneCredentialValidatedAuthenticationPolicyTests method verifyHandlerCountMismatch.
@Test
public void verifyHandlerCountMismatch() throws Exception {
val input = new AtLeastOneCredentialValidatedAuthenticationPolicy(true);
val builder = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal());
val authn = builder.addFailure("Prevented", new PreventedException("error")).build();
assertFalse(input.isSatisfiedBy(authn, Set.of(), mock(ConfigurableApplicationContext.class), Optional.empty()).isSuccess());
}
use of org.apereo.cas.authentication.DefaultAuthenticationBuilder 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 DefaultAuthenticationHandlerExecutionResult(handler, meta));
if (this.p.supports(credential)) {
this.p.populateAttributes(builder, AuthenticationTransaction.of(credential));
}
return builder;
}
use of org.apereo.cas.authentication.DefaultAuthenticationBuilder in project cas by apereo.
the class RegisteredServiceTestUtils method getAuthentication.
public static Authentication getAuthentication(final Principal principal, final Map<String, Object> attributes) {
final AuthenticationHandler handler = new SimpleTestUsernamePasswordAuthenticationHandler();
final CredentialMetaData meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
return new DefaultAuthenticationBuilder(principal).addCredential(meta).addSuccess("testHandler", new DefaultAuthenticationHandlerExecutionResult(handler, meta)).setAttributes(attributes).build();
}
use of org.apereo.cas.authentication.DefaultAuthenticationBuilder in project cas by apereo.
the class NotPreventedAuthenticationPolicyTests method verifyOperationNotPrevented.
@Test
public void verifyOperationNotPrevented() throws Exception {
val input = new NotPreventedAuthenticationPolicy();
val authn = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal()).build();
assertFalse(input.isSatisfiedBy(authn, Set.of(), mock(ConfigurableApplicationContext.class), Optional.empty()).isSuccess());
}
use of org.apereo.cas.authentication.DefaultAuthenticationBuilder in project cas by apereo.
the class NotPreventedAuthenticationPolicyTests method verifyOperationPrevented.
@Test
public void verifyOperationPrevented() throws Exception {
val input = new NotPreventedAuthenticationPolicy();
val builder = new DefaultAuthenticationBuilder(CoreAuthenticationTestUtils.getPrincipal());
val authn = builder.addFailure("Prevented", new PreventedException("error")).build();
assertFalse(input.isSatisfiedBy(authn, Set.of(), mock(ConfigurableApplicationContext.class), Optional.empty()).isSuccess());
}
Aggregations