use of org.apereo.cas.authentication.UsernamePasswordCredential in project cas by apereo.
the class CentralAuthenticationServiceImplTests method verifyValidateServiceTicketAnonymous.
@Test
public void verifyValidateServiceTicketAnonymous() {
final Service service = getService("testAnonymous");
final UsernamePasswordCredential cred = CoreAuthenticationTestUtils.getCredentialsWithSameUsernameAndPassword();
final AuthenticationResult ctx = CoreAuthenticationTestUtils.getAuthenticationResult(getAuthenticationSystemSupport(), service);
final TicketGrantingTicket ticketGrantingTicket = getCentralAuthenticationService().createTicketGrantingTicket(ctx);
final ServiceTicket serviceTicket = getCentralAuthenticationService().grantServiceTicket(ticketGrantingTicket.getId(), service, ctx);
final Assertion assertion = getCentralAuthenticationService().validateServiceTicket(serviceTicket.getId(), service);
final Authentication auth = assertion.getPrimaryAuthentication();
assertNotEquals(cred.getUsername(), auth.getPrincipal().getId());
}
use of org.apereo.cas.authentication.UsernamePasswordCredential 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.UsernamePasswordCredential in project cas by apereo.
the class UsernamePasswordRestHttpRequestCredentialFactory method fromRequestBody.
@Override
public List<Credential> fromRequestBody(final MultiValueMap<String, String> requestBody) {
final String username = requestBody.getFirst(USERNAME);
final String password = requestBody.getFirst(PASSWORD);
if (username == null || password == null) {
LOGGER.debug("Invalid payload. 'username' and 'password' form fields are required.");
return new ArrayList<>(0);
}
final Credential c = new UsernamePasswordCredential(username, password);
return CollectionUtils.wrap(c);
}
use of org.apereo.cas.authentication.UsernamePasswordCredential 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.UsernamePasswordCredential in project cas by apereo.
the class PersonDirectoryPrincipalResolverLdaptiveTests method verifyResolver.
@Test
public void verifyResolver() {
final PersonDirectoryPrincipalResolver resolver = new PersonDirectoryPrincipalResolver(this.attributeRepository);
final Principal p = resolver.resolve(new UsernamePasswordCredential("castest1", "castest1"), CoreAuthenticationTestUtils.getPrincipal(), new SimpleTestUsernamePasswordAuthenticationHandler());
assertNotNull(p);
assertTrue(p.getAttributes().containsKey("givenName"));
}
Aggregations