Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.

Commit

Permalink
Custom token name in RemoteTokenServices
Browse files Browse the repository at this point in the history
  • Loading branch information
presidentio authored and Dave Syer committed Nov 10, 2014
1 parent f6e0acf commit 79dd8cb
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
*******************************************************************************/
package org.springframework.security.oauth2.provider.token;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpEntity;
Expand All @@ -35,6 +31,10 @@
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;

/**
* Queries the /check_token endpoint to obtain the contents of an access token.
*
Expand All @@ -56,6 +56,8 @@ public class RemoteTokenServices implements ResourceServerTokenServices {

private String clientSecret;

private String tokenName;

private AccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();

public RemoteTokenServices() {
Expand Down Expand Up @@ -91,11 +93,15 @@ public void setAccessTokenConverter(AccessTokenConverter accessTokenConverter) {
this.tokenConverter = accessTokenConverter;
}

@Override
public void setTokenName(String tokenName) {
this.tokenName = tokenName;
}

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

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

0 comments on commit 79dd8cb

Please sign in to comment.