Example usage for org.apache.shiro.authc AccountException AccountException

List of usage examples for org.apache.shiro.authc AccountException AccountException

Introduction

In this page you can find the example usage for org.apache.shiro.authc AccountException AccountException.

Prototype

public AccountException() 

Source Link

Document

Creates a new AccountException.

Usage

From source file:cn.ligoo.part.service.shiro.CustomAuthorizingRealm.java

License:Apache License

/**
 * ?,./*from w  w  w  .  ja  va2 s  .c o  m*/
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken)
        throws AuthenticationException {
    logger.debug("...CustomAuthorizingRealm.doGetAuthenticationInfo()");
    CustomToken token = (CustomToken) authcToken;

    String username = token.getUsername();
    if (username == null) {
        throw new AccountException();
    }

    UserInfo user = userInfoService.findByEmail(username);
    if (user == null) {
        throw new UnknownAccountException();
    }

    if (user.getIs_del() == Constants.BYTE_1) {
        throw new DisabledAccountException();
    }
    return new SimpleAuthenticationInfo(new ShiroUser(user.getId(), user.getEmail()), user.getPassword(),
            getName());

}

From source file:ssh.demo.service.shiro.CustomAuthorizingRealm.java

License:Apache License

/**
 * ?,.//from ww  w.jav  a2 s .co m
 */
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken)
        throws AuthenticationException {
    logger.trace("----->CustomAuthorizingRealm.doGetAuthenticationInfo()");
    CustomToken token = (CustomToken) authcToken;

    String username = token.getUsername();
    if (username == null) {
        throw new AccountException();
    }

    User user = userService.findByLoginName(username);
    if (user == null) {
        throw new UnknownAccountException();
    }

    if (user.getState() == 1) {
        throw new DisabledAccountException();
    }
    return new SimpleAuthenticationInfo(new ShiroUser(user.getId(), user.getEmail()), user.getPassword(),
            getName());

}