com.atlassian.crowd.plugin.rest.service.controller
Class TokenController

java.lang.Object
  extended by com.atlassian.crowd.plugin.rest.service.controller.TokenController

public class TokenController
extends Object

Performs token authentication for the user.


Constructor Summary
TokenController(TokenAuthenticationManager tokenAuthenticationManager)
           
 
Method Summary
 SessionEntity authenticateUser(String applicationName, String username, String password, Collection<ValidationFactorEntity> validationFactorEntities, URI baseUri)
          Authenticates a user for the given application.
 SessionEntity authenticateUserWithoutValidatingPassword(String applicationName, String username, Collection<ValidationFactorEntity> validationFactorEntities, URI baseUri)
          Feigns the authentication process for a user and creates a token for the authentication without validating the password.
 UserEntity getUserFromToken(String token, String applicationName, URI baseUri)
          Returns the user associated with the Crowd SSO token.
 void invalidateToken(String token)
          Invalidates a token.
 SessionEntity validateToken(String applicationName, String token, Collection<ValidationFactorEntity> validationFactorEntities, URI baseUri)
          Validates a Crowd SSO token and creates a new token with an updated last accessed date (for the internal token representation).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenController

public TokenController(TokenAuthenticationManager tokenAuthenticationManager)
Method Detail

authenticateUser

public SessionEntity authenticateUser(String applicationName,
                                      String username,
                                      String password,
                                      Collection<ValidationFactorEntity> validationFactorEntities,
                                      URI baseUri)
                               throws InvalidAuthenticationException,
                                      InactiveAccountException,
                                      ExpiredCredentialException,
                                      ApplicationAccessDeniedException,
                                      OperationFailedException
Authenticates a user for the given application.

Parameters:
applicationName - name of the application
username - name of the user
password - password of the user
validationFactorEntities - validation factors
baseUri - base URI of the REST service
Returns:
Crowd SSO Token if the user successfully authenticated.
Throws:
InvalidAuthenticationException - if the authentication was not successful
InactiveAccountException - if the user account is marked as inactive
ExpiredCredentialException - if the user credential has expired and the user needs to set a new password
ApplicationAccessDeniedException - if the user does not have access to authenticate with the application
OperationFailedException - if the operation failed for any other reason

authenticateUserWithoutValidatingPassword

public SessionEntity authenticateUserWithoutValidatingPassword(String applicationName,
                                                               String username,
                                                               Collection<ValidationFactorEntity> validationFactorEntities,
                                                               URI baseUri)
                                                        throws InvalidAuthenticationException,
                                                               InactiveAccountException,
                                                               ExpiredCredentialException,
                                                               ApplicationAccessDeniedException,
                                                               OperationFailedException
Feigns the authentication process for a user and creates a token for the authentication without validating the password.

This method only be used to generate a token for a user that has already authenticated credentials via some other means (eg. SharePoint NTLM connector) as this method bypasses any password checks.

If you want actual password authentication, use the authenticateUser(String, String, String, java.util.Collection, java.net.URI) method.

Parameters:
applicationName - name of the application
username - name of the user
validationFactorEntities - validation factors
baseUri - base URI of the REST service
Returns:
Crowd SSO Token if the user successfully authenticated.
Throws:
InvalidAuthenticationException - if the authentication was not successful
InactiveAccountException - if the user account is marked as inactive
ExpiredCredentialException - if the user credential has expired and the user needs to set a new password
ApplicationAccessDeniedException - if the user does not have access to authenticate with the application
OperationFailedException - if the operation failed for any other reason

invalidateToken

public void invalidateToken(String token)
Invalidates a token. If the token does not exist, the method will silently return.

Parameters:
token - Token to invalidate

validateToken

public SessionEntity validateToken(String applicationName,
                                   String token,
                                   Collection<ValidationFactorEntity> validationFactorEntities,
                                   URI baseUri)
                            throws InvalidTokenException,
                                   ApplicationAccessDeniedException,
                                   OperationFailedException
Validates a Crowd SSO token and creates a new token with an updated last accessed date (for the internal token representation).

Parameters:
applicationName - Name of the application
token - Crowd SSO token
validationFactorEntities - validation factors
baseUri - base URI of the REST service
Returns:
new token.
Throws:
InvalidTokenException - if the token or validation factors are not valid.
ApplicationAccessDeniedException - if the user is not allowed to authenticate with the application.
OperationFailedException - if the application failed for any other reason.

getUserFromToken

public UserEntity getUserFromToken(String token,
                                   String applicationName,
                                   URI baseUri)
                            throws InvalidTokenException,
                                   OperationFailedException,
                                   ApplicationAccessDeniedException
Returns the user associated with the Crowd SSO token.

Parameters:
token - Crowd SSO token
applicationName - name of the current application
baseUri - base URI of the REST service
Returns:
User associated with the Crowd SSO token.
Throws:
InvalidTokenException - if the token could not be found
OperationFailedException - if the operation failed for any other reason.
ApplicationAccessDeniedException - if the user does not have access to authenticate with the application


Copyright © 2012 Atlassian. All Rights Reserved.