org.springframework.security.oauth2.provider.endpoint
Class TokenEndpoint

java.lang.Object
  extended by org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint
      extended by org.springframework.security.oauth2.provider.endpoint.TokenEndpoint
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

@RequestMapping(value="/oauth/token")
public class TokenEndpoint
extends AbstractEndpoint

Endpoint for token requests as described in the OAuth2 spec. Clients post requests with a grant_type parameter (e.g. "authorization_code") and other parameters as determined by the grant type. Supported grant types are handled by the provided token granter.

Clients must be authenticated using a Spring Security Authentication to access this endpoint, and the client id is extracted from the authentication token. The best way to arrange this (as per the OAuth2 spec) is to use HTTP basic authentication for this endpoint with standard Spring Security support.

Author:
Dave Syer

Field Summary
 
Fields inherited from class org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint
logger
 
Constructor Summary
TokenEndpoint()
           
 
Method Summary
 org.springframework.http.ResponseEntity<OAuth2AccessToken> getAccessToken(Principal principal, Map<String,String> parameters)
           
protected  String getClientId(Principal principal)
           
 org.springframework.http.ResponseEntity<OAuth2Exception> handleClientRegistrationException(Exception e)
           
 org.springframework.http.ResponseEntity<OAuth2Exception> handleException(Exception e)
           
 void setoAuth2RequestValidator(OAuth2RequestValidator oAuth2RequestValidator)
           
 
Methods inherited from class org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint
afterPropertiesSet, getClientDetailsService, getDefaultOAuth2RequestFactory, getExceptionTranslator, getOAuth2RequestFactory, getTokenGranter, setClientDetailsService, setOAuth2RequestFactory, setProviderExceptionHandler, setTokenGranter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenEndpoint

public TokenEndpoint()
Method Detail

getAccessToken

@RequestMapping
public org.springframework.http.ResponseEntity<OAuth2AccessToken> getAccessToken(Principal principal,
                                                                                                @RequestParam
                                                                                                Map<String,String> parameters)

getClientId

protected String getClientId(Principal principal)
Parameters:
principal - the currently authentication principal
Returns:
a client id if there is one in the principal

handleClientRegistrationException

@ExceptionHandler(value=ClientRegistrationException.class)
public org.springframework.http.ResponseEntity<OAuth2Exception> handleClientRegistrationException(Exception e)
                                                                                           throws Exception
Throws:
Exception

handleException

@ExceptionHandler(value=OAuth2Exception.class)
public org.springframework.http.ResponseEntity<OAuth2Exception> handleException(Exception e)
                                                                         throws Exception
Throws:
Exception

setoAuth2RequestValidator

public void setoAuth2RequestValidator(OAuth2RequestValidator oAuth2RequestValidator)


Copyright © 2013. All rights reserved.