List of usage examples for org.apache.shiro.authc IncorrectCredentialsException IncorrectCredentialsException
public IncorrectCredentialsException(String message, Throwable cause)
From source file:com.teemo.core.security.ShiroSecurityRealm.java
License:GNU General Public License
/** * //from www . j av a2 s .com * @param authcToken token * @return SimpleAuthenticationInfo * @throws AuthenticationException */ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException { UsernamePasswordToken token = (UsernamePasswordToken) authcToken; String username = token.getUsername(); String password = ""; if (token.getPassword() != null) { password = new String(token.getPassword()); } User user; try { user = userService.login(username, password); } catch (UserNotExistsException e) { throw new UnknownAccountException(e.getMessage(), e); } catch (UserPasswordIncorrectnessException e) { throw new IncorrectCredentialsException(e.getMessage(), e); } catch (UserBlockedException e) { throw new LockedAccountException(e.getMessage(), e); } setSession(Constants.CURRENT_USER, user); return new SimpleAuthenticationInfo(user.getId(), user.getPassword(), this.getName()); }
From source file:org.apache.camel.component.shiro.security.ShiroSecurityProcessor.java
License:Apache License
private void authenticateUser(Subject currentUser, ShiroSecurityToken securityToken) { boolean authenticated = currentUser.isAuthenticated(); boolean sameUser = securityToken.getUsername().equals(currentUser.getPrincipal()); LOG.trace("Authenticated: {}, same Username: {}", authenticated, sameUser); if (!authenticated || !sameUser) { UsernamePasswordToken token = new UsernamePasswordToken(securityToken.getUsername(), securityToken.getPassword()); if (policy.isAlwaysReauthenticate()) { token.setRememberMe(false);/* www . j av a 2 s. c o m*/ } else { token.setRememberMe(true); } try { currentUser.login(token); LOG.debug("Current user {} successfully authenticated", currentUser.getPrincipal()); } catch (UnknownAccountException uae) { throw new UnknownAccountException( "Authentication Failed. There is no user with username of " + token.getPrincipal(), uae.getCause()); } catch (IncorrectCredentialsException ice) { throw new IncorrectCredentialsException( "Authentication Failed. Password for account " + token.getPrincipal() + " was incorrect!", ice.getCause()); } catch (LockedAccountException lae) { throw new LockedAccountException("Authentication Failed. The account for username " + token.getPrincipal() + " is locked." + "Please contact your administrator to unlock it.", lae.getCause()); } catch (AuthenticationException ae) { throw new AuthenticationException("Authentication Failed.", ae.getCause()); } } }