Java Code Examples for org.springframework.security.oauth2.provider.token.store.jwk.JwkTokenStore

The following examples show how to use org.springframework.security.oauth2.provider.token.store.jwk.JwkTokenStore. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: entref-spring-boot   Source File: OauthConfig.java    License: MIT License 5 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
    // setup the resource id
    resources.resourceId(this.env.getProperty(Constants.ENV_OAUTH_RES_ID));

    // setup the token store
    resources.tokenStore(new JwkTokenStore(this.env.getProperty(Constants.ENV_OAUTH_KEYSET_URI)));
}
 
Example 2
@Test
public void jwkTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
	TestPropertyValues.of("security.oauth2.resource.jwk.key-set-uri=https://idp.example.com/token_keys")
			.applyTo(this.environment);
	this.context = new SpringApplicationBuilder(JwkTokenStoreConfiguration.class, ResourceConfiguration.class)
			.environment(this.environment).web(WebApplicationType.NONE).run();
	assertThat(this.context.getBeansOfType(JwkTokenStore.class)).hasSize(1);
}
 
Example 3
@Bean
public TokenStore jwkTokenStore() throws MalformedURLException {
    ProviderDiscoveryClient discoveryClient = new ProviderDiscoveryClient(ssoServiceUrl);
    ProviderConfiguration providerConfiguration = discoveryClient.discover();

    IssuerClaimVerifier issuerClaimVerifier = new IssuerClaimVerifier(providerConfiguration.getIssuer());

    return new JwkTokenStore(
        keySetUri,
        issuerClaimVerifier
    );
}
 
Example 4
Source Project: codenjoy   Source File: SecurityConfig.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
    DefaultAccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();
    tokenConverter.setUserTokenConverter(oAuth2UserAuthenticationConverter);
    accessTokenConverter.setAccessTokenConverter(tokenConverter);

    return new JwkTokenStore(clientProperties.getProvider().get("dojo").getJwkSetUri(),
            accessTokenConverter);
}
 
Example 5
/**
 * Configures the JWKS bases TokenStore.
 */
@Bean
public TokenStore tokenStore() {
	return new JwkTokenStore(configProps.getJwkSetUrl());
}
 
Example 6
@Bean
@ConditionalOnMissingBean(TokenStore.class)
public TokenStore jwkTokenStore() {
	return new JwkTokenStore(this.resource.getJwk().getKeySetUri());
}
 
Example 7
@Bean
public TokenStore tokenStore() {
	return new JwkTokenStore("https://idp.example.com/token_keys");
}