Example usage for org.apache.shiro.mgt DefaultSecurityManager login

List of usage examples for org.apache.shiro.mgt DefaultSecurityManager login

Introduction

In this page you can find the example usage for org.apache.shiro.mgt DefaultSecurityManager login.

Prototype

public Subject login(Subject subject, AuthenticationToken token) throws AuthenticationException 

Source Link

Document

First authenticates the AuthenticationToken argument, and if successful, constructs a Subject instance representing the authenticated account's identity.

Usage

From source file:org.openengsb.core.security.internal.RootSubjectHolder.java

License:Apache License

public static void init() {
    DefaultSecurityManager defaultSecurityManager = new DefaultSecurityManager();
    defaultSecurityManager.setAuthenticator(new Authenticator() {
        @Override/*from  www  .j a  v  a  2 s. co m*/
        public AuthenticationInfo authenticate(AuthenticationToken authenticationToken)
                throws AuthenticationException {
            return new SimpleAuthenticationInfo(new Object(), null, "openengsb");
        }
    });
    Subject subject = defaultSecurityManager.createSubject(new DefaultSubjectContext());
    synchronized (rootSubject) {
        rootSubject.set(defaultSecurityManager.login(subject, null));
        rootSubject.notifyAll();
    }
}