List of usage examples for org.apache.shiro.authc SimpleAccount isLocked
public boolean isLocked()
true if this Account is locked and thus cannot be used to login, false otherwise. 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 ava 2 s . c o 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 w w. j a va2s . c o m*/ if (account.isCredentialsExpired()) { String msg = "The credentials for account [" + account + "] are expired"; throw new ExpiredCredentialsException(msg); } } return account; }