Search in sources :

Example 1 with RemoteTokenServices

use of org.springframework.security.oauth2.provider.token.RemoteTokenServices in project spring-boot by spring-projects.

the class ResourceServerTokenServicesConfigurationTests method useRemoteTokenServices.

@Test
public void useRemoteTokenServices() {
    EnvironmentTestUtils.addEnvironment(this.environment, "security.oauth2.resource.tokenInfoUri:http://example.com", "security.oauth2.resource.clientId=acme");
    this.context = new SpringApplicationBuilder(ResourceConfiguration.class).environment(this.environment).web(WebApplicationType.NONE).run();
    RemoteTokenServices services = this.context.getBean(RemoteTokenServices.class);
    assertThat(services).isNotNull();
}
Also used : SpringApplicationBuilder(org.springframework.boot.builder.SpringApplicationBuilder) RemoteTokenServices(org.springframework.security.oauth2.provider.token.RemoteTokenServices) Test(org.junit.Test)

Example 2 with RemoteTokenServices

use of org.springframework.security.oauth2.provider.token.RemoteTokenServices in project openlmis-stockmanagement by OpenLMIS.

the class ResourceServerSecurityConfiguration method remoteTokenServices.

/**
 * RemoteTokenServices bean initializer.
 *
 * @param checkTokenUrl url to check tokens against
 * @param clientId      client's id
 * @param clientSecret  client's secret
 * @return token services
 */
@Bean
@Autowired
public RemoteTokenServices remoteTokenServices(@Value("${auth.server.url}") String checkTokenUrl, @Value("${auth.server.clientId}") String clientId, @Value("${auth.server.clientSecret}") String clientSecret) {
    final RemoteTokenServices remoteTokenServices = new RemoteTokenServices();
    remoteTokenServices.setCheckTokenEndpointUrl(checkTokenUrl);
    remoteTokenServices.setClientId(clientId);
    remoteTokenServices.setClientSecret(clientSecret);
    remoteTokenServices.setAccessTokenConverter(accessTokenConverter());
    return remoteTokenServices;
}
Also used : RemoteTokenServices(org.springframework.security.oauth2.provider.token.RemoteTokenServices) Autowired(org.springframework.beans.factory.annotation.Autowired) Bean(org.springframework.context.annotation.Bean)

Example 3 with RemoteTokenServices

use of org.springframework.security.oauth2.provider.token.RemoteTokenServices in project cloud-sea-towerman by huadahuang1983.

the class WebSecurityConfig method remoteTokenServices.

@Bean
public RemoteTokenServices remoteTokenServices() {
    RemoteTokenServices services = new RemoteTokenServices();
    services.setCheckTokenEndpointUrl(this.resource.getTokenInfoUri());
    services.setClientId(this.resource.getClientId());
    services.setClientSecret(this.resource.getClientSecret());
    DefaultUserAuthenticationConverter userTokenConverter = new DefaultUserAuthenticationConverter();
    userTokenConverter.setUserDetailsService(userDetailsService());
    DefaultAccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();
    tokenConverter.setUserTokenConverter(userTokenConverter);
    services.setAccessTokenConverter(tokenConverter);
    return services;
}
Also used : DefaultAccessTokenConverter(org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter) DefaultUserAuthenticationConverter(org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter) RemoteTokenServices(org.springframework.security.oauth2.provider.token.RemoteTokenServices) Bean(org.springframework.context.annotation.Bean)

Aggregations

RemoteTokenServices (org.springframework.security.oauth2.provider.token.RemoteTokenServices)3 Bean (org.springframework.context.annotation.Bean)2 Test (org.junit.Test)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)1 DefaultAccessTokenConverter (org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter)1 DefaultUserAuthenticationConverter (org.springframework.security.oauth2.provider.token.DefaultUserAuthenticationConverter)1