use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class ShiroAuthenticationHandlerTests method checkAuthenticationSuccessfulMissingPermission.
@Test
public void checkAuthenticationSuccessfulMissingPermission() {
val shiro = new ShiroAuthenticationHandler(StringUtils.EMPTY, null, PrincipalFactoryUtils.newPrincipalFactory(), new HashSet<>(0), Collections.singleton("dosomething"));
shiro.loadShiroConfiguration(new ClassPathResource("shiro.ini"));
val creds = new RememberMeUsernamePasswordCredential();
creds.setRememberMe(true);
creds.setUsername("casuser");
creds.setPassword("Mellon");
assertThrows(FailedLoginException.class, () -> shiro.authenticate(creds));
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class ShiroAuthenticationHandlerTests method checkAuthenticationAccountStatusHandling.
@Test
public void checkAuthenticationAccountStatusHandling() {
val creds = new RememberMeUsernamePasswordCredential();
creds.setUsername("casuser");
creds.setPassword("Mellon");
assertThrows(AccountNotFoundException.class, () -> buildShiroHandlerWithAccountStatus(UnknownAccountException.class).authenticate(creds));
assertThrows(AccountLockedException.class, () -> buildShiroHandlerWithAccountStatus(LockedAccountException.class).authenticate(creds));
assertThrows(CredentialExpiredException.class, () -> buildShiroHandlerWithAccountStatus(ExpiredCredentialsException.class).authenticate(creds));
assertThrows(AccountDisabledException.class, () -> buildShiroHandlerWithAccountStatus(DisabledAccountException.class).authenticate(creds));
assertThrows(FailedLoginException.class, () -> buildShiroHandlerWithAccountStatus(AuthenticationException.class).authenticate(creds));
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class ShiroAuthenticationHandlerTests method checkAuthenticationSuccessfulMissingRole.
@Test
public void checkAuthenticationSuccessfulMissingRole() {
val shiro = new ShiroAuthenticationHandler(StringUtils.EMPTY, null, PrincipalFactoryUtils.newPrincipalFactory(), Collections.singleton("student"), new HashSet<>(0));
shiro.loadShiroConfiguration(new ClassPathResource("shiro.ini"));
val creds = new RememberMeUsernamePasswordCredential();
creds.setRememberMe(true);
creds.setUsername("casuser");
creds.setPassword("Mellon");
assertThrows(FailedLoginException.class, () -> shiro.authenticate(creds));
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyWithTrueRememberMeCredentials.
@Test
public void verifyWithTrueRememberMeCredentials() {
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
val builder = newBuilder(c, new RememberMeAuthenticationProperties());
val auth = builder.build();
assertEquals(true, auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME).get(0));
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyWithFalseRememberMeCredentials.
@Test
public void verifyWithFalseRememberMeCredentials() {
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(false);
val builder = newBuilder(c, new RememberMeAuthenticationProperties());
val auth = builder.build();
assertNull(auth.getAttributes().get(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
Aggregations