public AuthenticationInfo authenticate( AuthenticationToken token ) throws AuthenticationException { try { return this.getSecurityManager().authenticate( token ); } catch ( org.apache.shiro.authc.AuthenticationException e ) { throw new AuthenticationException( e.getMessage(), e ); } }
@Override public void changePassword(String userId, String oldPassword, String newPassword) throws UserNotFoundException, InvalidCredentialsException { // first authenticate the user try { UsernamePasswordToken authenticationToken = new UsernamePasswordToken(userId, oldPassword); if (realmSecurityManager.authenticate(authenticationToken) == null) { throw new InvalidCredentialsException(); } } catch (AuthenticationException e) { log.debug("User failed to change password reason: " + e.getMessage(), e); throw new InvalidCredentialsException(); } // if that was good just change the password changePassword(userId, newPassword); }
sm.authenticate(new UsernamePasswordToken(username, password));
public void changePassword( String userId, String oldPassword, String newPassword ) throws UserNotFoundException, InvalidCredentialsException, InvalidConfigurationException { // first authenticate the user try { UsernamePasswordToken authenticationToken = new UsernamePasswordToken( userId, oldPassword ); if ( this.getSecurityManager().authenticate( authenticationToken ) == null ) { throw new InvalidCredentialsException(); } } catch ( org.apache.shiro.authc.AuthenticationException e ) { this.logger.debug( "User failed to change password reason: " + e.getMessage(), e ); throw new InvalidCredentialsException(); } // if that was good just change the password this.changePassword( userId, newPassword ); }