use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeIp.
@Test
public void verifyRememberMeIp() {
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
val builder = newBuilder(c, new RememberMeAuthenticationProperties().setSupportedIpAddresses("192.+"));
val auth = builder.build();
assertFalse(auth.getAttributes().containsKey(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeUserAgentAndIp.
@Test
public void verifyRememberMeUserAgentAndIp() {
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Chrome");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
val builder = newBuilder(c, new RememberMeAuthenticationProperties().setSupportedUserAgents("Chrome").setSupportedIpAddresses("123.+"));
val auth = builder.build();
assertFalse(auth.getAttributes().containsKey(RememberMeCredential.AUTHENTICATION_ATTRIBUTE_REMEMBER_ME));
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class RememberMePasswordCredentialTests method verifyGettersAndSetters.
@Test
public void verifyGettersAndSetters() {
val c = new RememberMeUsernamePasswordCredential();
c.setPassword("password");
c.setUsername("username");
c.setRememberMe(true);
assertEquals("username", c.getUsername());
assertEquals("password", c.getPassword());
assertTrue(c.isRememberMe());
}
use of org.apereo.cas.authentication.credential.RememberMeUsernamePasswordCredential in project cas by apereo.
the class RememberMeAuthenticationMetaDataPopulatorTests method verifyRememberMeUserAgent.
@Test
public void verifyRememberMeUserAgent() {
val request = new MockHttpServletRequest();
request.setRemoteAddr("185.86.151.11");
request.setLocalAddr("185.88.151.11");
request.addHeader(HttpRequestUtils.USER_AGENT_HEADER, "Chrome");
ClientInfoHolder.setClientInfo(new ClientInfo(request));
val c = new RememberMeUsernamePasswordCredential();
c.setRememberMe(true);
val builder = newBuilder(c, new RememberMeAuthenticationProperties().setSupportedUserAgents("Chrome"));
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 ShiroAuthenticationHandlerTests method checkAuthenticationSuccessful.
@Test
public void checkAuthenticationSuccessful() throws Exception {
val shiro = new ShiroAuthenticationHandler(StringUtils.EMPTY, null, PrincipalFactoryUtils.newPrincipalFactory(), new HashSet<>(0), new HashSet<>(0));
shiro.loadShiroConfiguration(new ClassPathResource("shiro.ini"));
val creds = new RememberMeUsernamePasswordCredential();
creds.setRememberMe(true);
creds.setUsername("casuser");
creds.setPassword("Mellon");
assertNotNull(shiro.authenticate(creds));
}
Aggregations