Search in sources :

Example 1 with GeodeAuthenticationToken

use of org.apache.geode.internal.security.shiro.GeodeAuthenticationToken in project geode by apache.

the class IntegratedSecurityService method login.

/**
   * @return null if security is not enabled, otherwise return a shiro subject
   */
public Subject login(Properties credentials) {
    if (!isIntegratedSecurity()) {
        return null;
    }
    if (credentials == null)
        return null;
    // this makes sure it starts with a clean user object
    ThreadContext.remove();
    Subject currentUser = SecurityUtils.getSubject();
    GeodeAuthenticationToken token = new GeodeAuthenticationToken(credentials);
    try {
        logger.debug("Logging in " + token.getPrincipal());
        currentUser.login(token);
    } catch (ShiroException e) {
        logger.info(e.getMessage(), e);
        throw new AuthenticationFailedException("Authentication error. Please check your credentials.", e);
    }
    return currentUser;
}
Also used : AuthenticationFailedException(org.apache.geode.security.AuthenticationFailedException) GeodeAuthenticationToken(org.apache.geode.internal.security.shiro.GeodeAuthenticationToken) Subject(org.apache.shiro.subject.Subject) ShiroException(org.apache.shiro.ShiroException)

Aggregations

GeodeAuthenticationToken (org.apache.geode.internal.security.shiro.GeodeAuthenticationToken)1 AuthenticationFailedException (org.apache.geode.security.AuthenticationFailedException)1 ShiroException (org.apache.shiro.ShiroException)1 Subject (org.apache.shiro.subject.Subject)1