use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class Application method tokenStore.
@Bean
public JwtTokenStore tokenStore() throws Exception {
JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
// N.B. in a real system you would have to configure the verifierKey (or use JdbcTokenStore)
enhancer.afterPropertiesSet();
return new JwtTokenStore(enhancer);
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project spring-security-oauth by spring-projects.
the class JwkTokenStoreTest method readAuthenticationUsingCustomAccessTokenConverterThenAuthenticationDetailsContainsClaims.
// gh-1015
@Test
public void readAuthenticationUsingCustomAccessTokenConverterThenAuthenticationDetailsContainsClaims() throws Exception {
AccessTokenConverter customAccessTokenConverter = mock(AccessTokenConverter.class);
when(customAccessTokenConverter.extractAuthentication(anyMapOf(String.class, String.class))).thenAnswer(new Answer<OAuth2Authentication>() {
@Override
public OAuth2Authentication answer(InvocationOnMock invocation) throws Throwable {
Map<String, String> claims = (Map<String, String>) invocation.getArguments()[0];
OAuth2Authentication authentication = new OAuth2Authentication(mock(OAuth2Request.class), null);
authentication.setDetails(claims);
return authentication;
}
});
JwkVerifyingJwtAccessTokenConverter jwtVerifyingAccessTokenConverter = new JwkVerifyingJwtAccessTokenConverter(mock(JwkDefinitionSource.class));
jwtVerifyingAccessTokenConverter = spy(jwtVerifyingAccessTokenConverter);
jwtVerifyingAccessTokenConverter.setAccessTokenConverter(customAccessTokenConverter);
Map<String, String> claims = new LinkedHashMap<String, String>();
claims.put("claim1", "value1");
claims.put("claim2", "value2");
claims.put("claim3", "value3");
doReturn(claims).when(jwtVerifyingAccessTokenConverter).decode((anyString()));
JwkTokenStore spy = spy(this.jwkTokenStore);
JwtTokenStore delegate = new JwtTokenStore(jwtVerifyingAccessTokenConverter);
Field field = ReflectionUtils.findField(spy.getClass(), "delegate");
field.setAccessible(true);
ReflectionUtils.setField(field, spy, delegate);
OAuth2Authentication authentication = spy.readAuthentication(anyString());
assertEquals(claims, authentication.getDetails());
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project Spring-5.0-By-Example by PacktPublishing.
the class OAuthTokenConfiguration method tokenStore.
@Bean
public JwtTokenStore tokenStore() throws Exception {
JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
enhancer.setSigningKey(privateKey);
enhancer.setVerifierKey(publicKey);
enhancer.afterPropertiesSet();
return new JwtTokenStore(enhancer);
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project Spring-5.0-By-Example by PacktPublishing.
the class OAuthTokenConfiguration method tokenStore.
@Bean
public JwtTokenStore tokenStore() throws Exception {
JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
enhancer.setSigningKey(privateKey);
enhancer.setVerifierKey(publicKey);
enhancer.afterPropertiesSet();
return new JwtTokenStore(enhancer);
}
use of org.springframework.security.oauth2.provider.token.store.JwtTokenStore in project Spring-5.0-By-Example by PacktPublishing.
the class OAuthTokenConfiguration method tokenStore.
@Bean
public JwtTokenStore tokenStore() throws Exception {
JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
enhancer.setSigningKey(privateKey);
enhancer.setVerifierKey(publicKey);
enhancer.afterPropertiesSet();
return new JwtTokenStore(enhancer);
}
Aggregations