List of usage examples for org.apache.shiro.authc ExcessiveAttemptsException ExcessiveAttemptsException
public ExcessiveAttemptsException(String message, Throwable cause)
From source file:com.digitalplay.network.ireader.shiro.ShiroDbRealm.java
License:Apache License
/** * ?,./*from ww w .jav a 2 s. co m*/ */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException { UsernamePasswordToken upToken = (UsernamePasswordToken) authcToken; String username = upToken.getUsername().trim(); String password = ""; if (upToken.getPassword() != null) { password = new String(upToken.getPassword()); } User user = null; try { user = userService.login(username, password); } catch (UserNotExistsException e) { throw new UnknownAccountException(e.getMessage(), e); } catch (UserPasswordNotMatchException e) { throw new AuthenticationException(e.getMessage(), e); } catch (UserPasswordRetryLimitExceedException e) { throw new ExcessiveAttemptsException(e.getMessage(), e); } catch (UserBlockedException e) { throw new LockedAccountException(e.getMessage(), e); } catch (Exception e) { throw new AuthenticationException(new UserException("user.unknown.error", null)); } SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user.getUsername(), password.toCharArray(), getName()); return info; }
From source file:com.huntering.security.UserRealm.java
License:Apache License
@Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { UsernamePasswordToken upToken = (UsernamePasswordToken) token; String username = upToken.getUsername().trim(); String password = ""; if (upToken.getPassword() != null) { password = new String(upToken.getPassword()); }//from www . j ava 2 s . c o m Account account = null; try { account = accountService.login(username, password); } catch (UserNotExistsException e) { throw new UnknownAccountException(e.getMessage(), e); } catch (UserPasswordNotMatchException e) { throw new AuthenticationException(e.getMessage(), e); } catch (UserPasswordRetryLimitExceedException e) { throw new ExcessiveAttemptsException(e.getMessage(), e); } catch (UserBlockedException e) { throw new LockedAccountException(e.getMessage(), e); } catch (Exception e) { log.error("login error", e); throw new AuthenticationException(new UserException("user.unknown.error", null)); } String name = username; for (Email email : account.getEmails()) { if (Boolean.TRUE.equals(email.getMain())) { name = email.getEmail(); break; } } SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(name, password.toCharArray(), getName()); return info; }
From source file:com.playersun.jbf.common.shiro.realm.UserRealm.java
License:Apache License
/** * ?/* w w w .j ava 2 s. c om*/ */ @Override protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { UsernamePasswordToken upToken = (UsernamePasswordToken) token; String username = upToken.getUsername().trim(); String password = ""; if (upToken.getPassword() != null) { password = new String(upToken.getPassword()); } User user = null; try { user = userService.login(username, password); } catch (UserNotExistsException e) { throw new UnknownAccountException(e.getMessage(), e); } catch (UserPasswordNotMatchException e) { throw new AuthenticationException(e.getMessage(), e); } catch (UserPasswordRetryLimitExceedException e) { throw new ExcessiveAttemptsException(e.getMessage(), e); } catch (UserBlockedException e) { throw new LockedAccountException(e.getMessage(), e); } catch (Exception e) { LogUtils.logError("login error", e); throw new AuthenticationException(new UserException("user.unknown.error", null)); } SimpleAuthenticationInfo info = new SimpleAuthenticationInfo(user.getUsername(), password.toCharArray(), getName()); return info; }