Example usage for org.apache.shiro.authc SimpleAccount isCredentialsExpired

List of usage examples for org.apache.shiro.authc SimpleAccount isCredentialsExpired

Introduction

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

Prototype

public boolean isCredentialsExpired() 

Source Link

Document

Returns whether or not the Account's credentials are expired.

Usage

From source file:graphene.security.tomcat.preaa.PreAASecurityRealm.java

License:Apache License

@Override
protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken authToken)
        throws AuthenticationException {

    logger.debug("doGetAuthenticationInfo " + authToken.getPrincipal());
    // return null;
    final UsernamePasswordToken upToken = (UsernamePasswordToken) authToken;
    G_User g_User = null;//  w  w w  .  j a  v a2 s.co m
    SimpleAccount account = null;
    try {
        g_User = userDataAccess.getByUsername(upToken.getUsername());
        final Set<String> roleNames = CollectionUtils.asSet((String[]) null);
        account = new SimpleAccount(g_User.getUsername(), "password", getName(), roleNames, null);
    } catch (final AvroRemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (account != null) {

        if (account.isLocked()) {
            throw new LockedAccountException("Account [" + account + "] is locked.");
        }
        if (account.isCredentialsExpired()) {
            final String msg = "The credentials for account [" + account + "] are expired";
            throw new ExpiredCredentialsException(msg);
        }

    } else {
        logger.error("user was null");
    }

    return account;
}

From source file:org.ms123.common.permission.MyRealm.java

License:Open Source License

protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    UsernamePasswordToken upToken = (UsernamePasswordToken) token;
    SimpleAccount account = getUser(upToken.getUsername());
    if (account != null) {
        if (account.isLocked()) {
            throw new LockedAccountException("Account [" + account + "] is locked.");
        }/*from   w ww  .  j  a v  a2  s  .  com*/
        if (account.isCredentialsExpired()) {
            String msg = "The credentials for account [" + account + "] are expired";
            throw new ExpiredCredentialsException(msg);
        }
    }
    return account;
}