Search in sources :

Example 1 with FirstSuccessfulStrategy

use of org.apache.shiro.authc.pam.FirstSuccessfulStrategy in project graylog2-server by Graylog2.

the class SessionCreatorTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    SimpleAccountRealm realm = new SimpleAccountRealm();
    realm.addAccount(validToken.getUsername(), String.valueOf(validToken.getPassword()));
    // Set up a security manager like in DefaultSecurityManagerProvider
    securityManager = new DefaultSecurityManager(realm);
    FirstSuccessfulStrategy strategy = new ThrowingFirstSuccessfulStrategy();
    strategy.setStopAfterFirstSuccess(true);
    ((ModularRealmAuthenticator) securityManager.getAuthenticator()).setAuthenticationStrategy(strategy);
    SecurityUtils.setSecurityManager(securityManager);
}
Also used : ModularRealmAuthenticator(org.apache.shiro.authc.pam.ModularRealmAuthenticator) SimpleAccountRealm(org.apache.shiro.realm.SimpleAccountRealm) DefaultSecurityManager(org.apache.shiro.mgt.DefaultSecurityManager) FirstSuccessfulStrategy(org.apache.shiro.authc.pam.FirstSuccessfulStrategy) Before(org.junit.Before)

Aggregations

FirstSuccessfulStrategy (org.apache.shiro.authc.pam.FirstSuccessfulStrategy)1 ModularRealmAuthenticator (org.apache.shiro.authc.pam.ModularRealmAuthenticator)1 DefaultSecurityManager (org.apache.shiro.mgt.DefaultSecurityManager)1 SimpleAccountRealm (org.apache.shiro.realm.SimpleAccountRealm)1 Before (org.junit.Before)1