@Override
  protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken)
      throws AuthenticationException {
    if (!(authenticationToken instanceof UsernamePasswordToken)) {
      throw new UnsupportedTokenException(
          "Token of type "
              + authenticationToken.getClass().getName()
              + " is not supported.  A "
              + UsernamePasswordToken.class.getName()
              + " is required.");
    }
    UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;

    String password = new String(token.getPassword());

    try {
      crowdClientHolder.getAuthenticationManager().authenticate(token.getUsername(), password);
      return new SimpleAuthenticationInfo(token.getPrincipal(), token.getCredentials(), getName());
    } catch (RemoteException e) {
      throw new AuthenticationException(DEFAULT_MESSAGE, e);
    } catch (com.atlassian.crowd.exception.InactiveAccountException e) {
      throw new AuthenticationException(DEFAULT_MESSAGE, e);
    } catch (com.atlassian.crowd.exception.ExpiredCredentialException e) {
      throw new AuthenticationException(DEFAULT_MESSAGE, e);
    } catch (com.atlassian.crowd.exception.InvalidAuthenticationException e) {
      throw new AuthenticationException(DEFAULT_MESSAGE, e);
    } catch (com.atlassian.crowd.exception.InvalidAuthorizationTokenException e) {
      throw new AuthenticationException(DEFAULT_MESSAGE, e);
    } catch (com.atlassian.crowd.exception.ApplicationAccessDeniedException e) {
      throw new AuthenticationException(DEFAULT_MESSAGE, e);
    }
  }
Beispiel #2
0
 private AuthenticationInfo buildAuthenticationInfo(final UsernamePasswordToken token) {
   return new SimpleAuthenticationInfo(token.getPrincipal(), token.getCredentials(), getName());
 }