Search in sources :

Example 6 with UsernamePasswordAuthenticationToken

use of io.vertigo.account.impl.authentication.UsernamePasswordAuthenticationToken in project vertigo by KleeGroup.

the class AuthenticationManagerTest method loginSuccess.

private Optional<Account> loginSuccess() {
    final AuthenticationToken token = new UsernamePasswordAuthenticationToken("admin", "v3rt1g0");
    final Optional<Account> account = authenticationManager.login(token);
    Assert.assertTrue("Authent fail", account.isPresent());
    final Optional<UserSession> userSession = securityManager.getCurrentUserSession();
    Assert.assertTrue("No UserSession", userSession.isPresent());
    Assert.assertTrue("Not authenticated", userSession.get().isAuthenticated());
    return account;
}
Also used : Account(io.vertigo.account.account.Account) UsernamePasswordAuthenticationToken(io.vertigo.account.impl.authentication.UsernamePasswordAuthenticationToken) AuthenticationToken(io.vertigo.account.authentication.AuthenticationToken) UserSession(io.vertigo.persona.security.UserSession) UsernamePasswordAuthenticationToken(io.vertigo.account.impl.authentication.UsernamePasswordAuthenticationToken)

Aggregations

UsernamePasswordAuthenticationToken (io.vertigo.account.impl.authentication.UsernamePasswordAuthenticationToken)6 AuthenticationToken (io.vertigo.account.authentication.AuthenticationToken)4 Account (io.vertigo.account.account.Account)2 UsernameAuthenticationToken (io.vertigo.account.impl.authentication.UsernameAuthenticationToken)2 UserSession (io.vertigo.persona.security.UserSession)2 Criteria (io.vertigo.dynamo.criteria.Criteria)1 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)1 DtObject (io.vertigo.dynamo.domain.model.DtObject)1 Matcher (java.util.regex.Matcher)1 NamingException (javax.naming.NamingException)1 InitialLdapContext (javax.naming.ldap.InitialLdapContext)1 LdapContext (javax.naming.ldap.LdapContext)1 Test (org.junit.Test)1