Skip to content

Commit

Permalink
CFID-383: add jti to encoded token value
Browse files Browse the repository at this point in the history
Change-Id: I5944ba4a096a6f584045459fb2827ce2c50a95d5
  • Loading branch information
dsyer committed Aug 16, 2012
1 parent 92d1e85 commit 11639d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -122,7 +122,7 @@ public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentica
DefaultOAuth2AccessToken result = new DefaultOAuth2AccessToken(accessToken);
String tokenId = result.getValue();
result.setAdditionalInformation(Collections.<String, Object> singletonMap(TOKEN_ID, tokenId));
return result.setValue(createAccessTokenValue(accessToken, authentication));
return result.setValue(createAccessTokenValue(result, authentication));
}

protected String createAccessTokenValue(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
Expand Down
Expand Up @@ -11,9 +11,11 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import org.cloudfoundry.identity.uaa.authentication.UaaAuthentication;
import org.cloudfoundry.identity.uaa.authentication.UaaAuthenticationTestFactory;
import org.cloudfoundry.identity.uaa.openid.UserInfo;
import org.junit.Before;
import org.junit.Test;
import org.springframework.security.jwt.JwtHelper;
Expand Down Expand Up @@ -45,6 +47,10 @@ public void testEnhanceAccessToken() {
new DefaultAuthorizationRequest("foo", null), userAuthentication);
OAuth2AccessToken token = tokenEnhancer.enhance(new DefaultOAuth2AccessToken("FOO"), authentication);
assertNotNull(token.getValue());
assertEquals("FOO", token.getAdditionalInformation().get(JwtTokenEnhancer.TOKEN_ID));
String claims = JwtHelper.decode(token.getValue()).getClaims();
assertTrue("Wrong claims: " + claims, claims.contains("\""+UserInfo.USER_ID+"\""));
assertTrue("Wrong claims: " + claims, claims.contains("\""+JwtTokenEnhancer.TOKEN_ID+"\""));
}


Expand Down

0 comments on commit 11639d1

Please sign in to comment.