use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class SSOSamlIdPPostProfileHandlerEndpoint method getAssertion.
private AuthenticatedAssertionContext getAssertion(final String username, final String password, final String entityId) {
val selectedService = serviceFactory.createService(entityId);
val registeredService = servicesManager.findServiceBy(selectedService, SamlRegisteredService.class);
val credential = new UsernamePasswordCredential(username, password);
val result = this.authenticationSystemSupport.finalizeAuthenticationTransaction(selectedService, credential);
val authentication = result.getAuthentication();
val principal = authentication.getPrincipal();
val context = RegisteredServiceAttributeReleasePolicyContext.builder().registeredService(registeredService).service(selectedService).principal(principal).build();
val attributesToRelease = registeredService.getAttributeReleasePolicy().getAttributes(context);
val builder = DefaultAuthenticationBuilder.of(principal, this.principalFactory, attributesToRelease, selectedService, registeredService, authentication);
val finalAuthentication = builder.build();
val authnPrincipal = finalAuthentication.getPrincipal();
return AuthenticatedAssertionContext.builder().name(authnPrincipal.getId()).attributes(CollectionUtils.merge(authnPrincipal.getAttributes(), finalAuthentication.getAttributes())).build();
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class RegisteredServiceTestUtils method getCredentialsWithSameUsernameAndPassword.
public static UsernamePasswordCredential getCredentialsWithSameUsernameAndPassword(final String username) {
val usernamePasswordCredentials = new UsernamePasswordCredential();
usernamePasswordCredentials.setUsername(username);
usernamePasswordCredentials.setPassword(username);
return usernamePasswordCredentials;
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class RegisteredServiceTestUtils method getCredentialsWithDifferentUsernameAndPassword.
public static UsernamePasswordCredential getCredentialsWithDifferentUsernameAndPassword(final String username, final String password) {
val usernamePasswordCredentials = new UsernamePasswordCredential();
usernamePasswordCredentials.setUsername(username);
usernamePasswordCredentials.setPassword(password);
return usernamePasswordCredentials;
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class RegisteredServiceTestUtils method getAuthentication.
public static Authentication getAuthentication(final Principal principal, final Map<String, List<Object>> attributes) {
val handler = new SimpleTestUsernamePasswordAuthenticationHandler();
val 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.credential.UsernamePasswordCredential in project cas by apereo.
the class MultifactorAuthenticationTests method newUserPassCredentials.
private static UsernamePasswordCredential newUserPassCredentials(final String user, final String pass) {
val userpass = new UsernamePasswordCredential();
userpass.setUsername(user);
userpass.setPassword(pass);
return userpass;
}
Aggregations