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.
logger
Constructor and Description |
---|
TokenEndpoint() |
Modifier and Type | Method and Description |
---|---|
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) |
org.springframework.http.ResponseEntity<OAuth2Exception> |
handleException(OAuth2Exception e) |
org.springframework.http.ResponseEntity<OAuth2Exception> |
handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) |
org.springframework.http.ResponseEntity<OAuth2AccessToken> |
postAccessToken(Principal principal,
Map<String,String> parameters) |
void |
setAllowedRequestMethods(Set<org.springframework.http.HttpMethod> allowedRequestMethods) |
void |
setOAuth2RequestValidator(OAuth2RequestValidator oAuth2RequestValidator) |
afterPropertiesSet, getClientDetailsService, getDefaultOAuth2RequestFactory, getExceptionTranslator, getOAuth2RequestFactory, getTokenGranter, setClientDetailsService, setOAuth2RequestFactory, setProviderExceptionHandler, setTokenGranter
@RequestMapping(value="/oauth/token", method=GET) public org.springframework.http.ResponseEntity<OAuth2AccessToken> getAccessToken(Principal principal, @RequestParam Map<String,String> parameters) throws HttpRequestMethodNotSupportedException
@RequestMapping(value="/oauth/token", method=POST) public org.springframework.http.ResponseEntity<OAuth2AccessToken> postAccessToken(Principal principal, @RequestParam Map<String,String> parameters) throws HttpRequestMethodNotSupportedException
protected String getClientId(Principal principal)
principal
- the currently authentication principal@ExceptionHandler(value=org.springframework.web.HttpRequestMethodNotSupportedException.class) public org.springframework.http.ResponseEntity<OAuth2Exception> handleHttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) throws Exception
Exception
@ExceptionHandler(value=java.lang.Exception.class) public org.springframework.http.ResponseEntity<OAuth2Exception> handleException(Exception e) throws Exception
Exception
@ExceptionHandler(value=ClientRegistrationException.class) public org.springframework.http.ResponseEntity<OAuth2Exception> handleClientRegistrationException(Exception e) throws Exception
Exception
@ExceptionHandler(value=OAuth2Exception.class) public org.springframework.http.ResponseEntity<OAuth2Exception> handleException(OAuth2Exception e) throws Exception
Exception
public void setOAuth2RequestValidator(OAuth2RequestValidator oAuth2RequestValidator)
public void setAllowedRequestMethods(Set<org.springframework.http.HttpMethod> allowedRequestMethods)
Copyright © 2019. All rights reserved.