use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class SurrogateInitialAuthenticationAction method convertToUsernamePasswordCredential.
private static void convertToUsernamePasswordCredential(final RequestContext context, final UsernamePasswordCredential up) throws Exception {
if (up instanceof SurrogateUsernamePasswordCredential) {
val sc = new UsernamePasswordCredential();
BeanUtils.copyProperties(sc, up);
WebUtils.putCredential(context, sc);
}
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class UsernamePasswordCredentialTests method verifySetGetPassword.
@Test
public void verifySetGetPassword() {
val c = new UsernamePasswordCredential();
val password = "test";
c.setPassword(password);
assertEquals(password, c.getPassword());
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class ScimAccountRegistrationProvisioner method provision.
@Override
public AccountRegistrationResponse provision(final AccountRegistrationRequest request) throws Exception {
val attributes = new LinkedHashMap<String, List<Object>>();
request.asMap().forEach((key, value) -> attributes.put(key, CollectionUtils.wrapList(value)));
val principal = principalFactory.createPrincipal(request.getUsername(), attributes);
val credential = new UsernamePasswordCredential(request.getUsername(), request.getPassword());
val result = principalProvisioner.provision(principal, credential);
LOGGER.debug("Provisioned account registration request for [{}]: [{}]", request.getUsername(), BooleanUtils.toString(result, "success", "failure"));
return result ? AccountRegistrationResponse.success() : new AccountRegistrationResponse();
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class FileAuthenticationHandlerTests method verifyFailsNullUserNameAndPassword.
@Test
public void verifyFailsNullUserNameAndPassword() {
val c = new UsernamePasswordCredential();
c.setUsername(null);
c.setPassword(null);
assertThrows(AccountNotFoundException.class, () -> this.authenticationHandler.authenticate(c));
}
use of org.apereo.cas.authentication.credential.UsernamePasswordCredential in project cas by apereo.
the class FileAuthenticationHandlerTests method verifyFailsGoodUsernameBadPassword.
@Test
public void verifyFailsGoodUsernameBadPassword() {
val c = new UsernamePasswordCredential();
this.authenticationHandler = new FileAuthenticationHandler(StringUtils.EMPTY, null, null, new ClassPathResource("authentication2.txt"), ",");
c.setUsername("scott");
c.setPassword("rutgers1");
assertThrows(FailedLoginException.class, () -> this.authenticationHandler.authenticate(c));
}
Aggregations