use of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler in project tomee by apache.
the class ServiceProviderLoginModuleTest method testBadUseridLogin.
public void testBadUseridLogin() throws Exception {
final LoginContext context = new LoginContext("ServiceProviderLogin", new UsernamePasswordCallbackHandler("nobody", "secret"));
try {
context.login();
fail("Should have thrown a FailedLoginException");
} catch (final FailedLoginException doNothing) {
}
}
use of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler in project tomee by apache.
the class CDILoginModuleTest method testLogin.
@Test
public void testLogin() throws LoginException {
final LoginContext context = new LoginContext("CDI", new UsernamePasswordCallbackHandler("foo", ""));
context.login();
final Subject subject = context.getSubject();
assertEquals(1, subject.getPrincipals().size());
assertEquals("foo", subject.getPrincipals(AbstractSecurityService.User.class).iterator().next().getName());
context.logout();
assertEquals(0, subject.getPrincipals().size());
}
use of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler in project tomee by apache.
the class SQLLoginModuleTest method testBadUseridLogin.
@Test(expected = FailedLoginException.class)
public void testBadUseridLogin() throws LoginException {
final LoginContext context = new LoginContext("SQLLogin", new UsernamePasswordCallbackHandler("nobody", "secret"));
context.login();
}
use of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler in project tomee by apache.
the class SQLLoginModuleTest method testBadPWLogin.
@Test(expected = FailedLoginException.class)
public void testBadPWLogin() throws LoginException {
final LoginContext context = new LoginContext("SQLLogin", new UsernamePasswordCallbackHandler("jonathan", "badpass"));
context.login();
}
use of org.apache.openejb.core.security.jaas.UsernamePasswordCallbackHandler in project tomee by apache.
the class SecurityServiceImpl method login.
@Override
public UUID login(String realmName, final String username, final String password) throws LoginException {
if (realmName == null) {
realmName = getRealmName();
}
final LoginContext context = new LoginContext(realmName, new UsernamePasswordCallbackHandler(username, password));
context.login();
final Subject subject = context.getSubject();
final UUID token = registerSubject(subject);
contexts.put(token, context);
return token;
}
Aggregations