Example usage for org.springframework.security.oauth2.common.exceptions InvalidTokenException InvalidTokenException

List of usage examples for org.springframework.security.oauth2.common.exceptions InvalidTokenException InvalidTokenException

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.common.exceptions InvalidTokenException InvalidTokenException.

Prototype

public InvalidTokenException(String msg) 

Source Link

Usage

From source file:org.springframework.security.oauth2.provider.token.RemoteTokenServices.java

@Override
public OAuth2Authentication loadAuthentication(String accessToken) throws AuthenticationException {

    MultiValueMap<String, String> formData = new LinkedMultiValueMap<String, String>();
    formData.add("token", accessToken);
    HttpHeaders headers = new HttpHeaders();
    headers.set("Authorization", getAuthorizationHeader(clientId, clientSecret));
    Map<String, Object> map = postForMap(checkTokenEndpointUrl, formData, headers);

    if (map.containsKey("error")) {
        logger.debug("check_token returned error: " + map.get("error"));
        throw new InvalidTokenException(accessToken);
    }//from w  ww .  j ava 2  s.  c  o m

    Assert.state(map.containsKey("client_id"), "Client id must be present in response from auth server");
    return tokenConverter.extractAuthentication(map);
}