Search in sources :

Example 1 with ShiroException

use of org.apache.shiro.ShiroException in project geode by apache.

the class IntegratedSecurityService method logout.

public void logout() {
    Subject currentUser = getSubject();
    if (currentUser == null) {
        return;
    }
    try {
        logger.debug("Logging out " + currentUser.getPrincipal());
        currentUser.logout();
    } catch (ShiroException e) {
        logger.info(e.getMessage(), e);
        throw new GemFireSecurityException(e.getMessage(), e);
    }
    // clean out Shiro's thread local content
    ThreadContext.remove();
}
Also used : GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) Subject(org.apache.shiro.subject.Subject) ShiroException(org.apache.shiro.ShiroException)

Example 2 with ShiroException

use of org.apache.shiro.ShiroException 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

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