Java Code Examples for org.springframework.security.oauth2.provider.token.TokenStore

The following are top voted examples for showing how to use org.springframework.security.oauth2.provider.token.TokenStore. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: spring-oauth2-samples   File: AbstractIntegrationTests.java   View source code 8 votes vote down vote up
private void clear(TokenStore tokenStore) throws Exception {
	if (tokenStore instanceof Advised) {
		Advised advised = (Advised) tokenStore;
		TokenStore target = (TokenStore) advised.getTargetSource().getTarget();
		clear(target);
		return;
	}
	if (tokenStore instanceof InMemoryTokenStore) {
		((InMemoryTokenStore) tokenStore).clear();
	}
	if (tokenStore instanceof JdbcTokenStore) {
		JdbcTemplate template = new JdbcTemplate(dataSource);
		template.execute("delete from oauth_access_token");
		template.execute("delete from oauth_refresh_token");
		template.execute("delete from oauth_client_token");
		template.execute("delete from oauth_code");
	}
}
 
Example 2
Project: credhub   File: AuditOAuth2AccessDeniedHandler.java   View source code 6 votes vote down vote up
@Autowired
public AuditOAuth2AccessDeniedHandler(
    TokenStore tokenStore,
    RequestAuditRecordDataService requestAuditRecordDataService,
    SecurityEventsLogService securityEventsLogService,
    UserContextFactory userContextFactory,
    WebResponseExceptionTranslator exceptionTranslator,
    AuditLogFactory auditLogFactory,
    MessageSourceAccessor messageSourceAccessor
) {
  this.userContextFactory = userContextFactory;
  this.tokenStore = tokenStore;
  this.requestAuditRecordDataService = requestAuditRecordDataService;
  this.securityEventsLogService = securityEventsLogService;
  this.exceptionTranslator = exceptionTranslator;
  this.auditLogFactory = auditLogFactory;
  this.messageSourceAccessor = messageSourceAccessor;
}
 
Example 3
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java   View source code 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
public DefaultTokenServices jwkTokenServices(TokenStore jwkTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwkTokenStore);
	return services;
}
 
Example 4
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java   View source code 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ResourceServerTokenServices.class)
public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) {
	DefaultTokenServices services = new DefaultTokenServices();
	services.setTokenStore(jwtTokenStore);
	return services;
}
 
Example 5
Project: spring-security-oauth2-boot   File: OAuth2AuthorizationServerConfiguration.java   View source code 5 votes vote down vote up
public OAuth2AuthorizationServerConfiguration(BaseClientDetails details,
		AuthenticationConfiguration authenticationConfiguration,
		ObjectProvider<TokenStore> tokenStore,
		ObjectProvider<AccessTokenConverter> tokenConverter,
		AuthorizationServerProperties properties) throws Exception {
	this.details = details;
	this.authenticationManager = authenticationConfiguration.getAuthenticationManager();
	this.tokenStore = tokenStore.getIfAvailable();
	this.tokenConverter = tokenConverter.getIfAvailable();
	this.properties = properties;
}
 
Example 6
Project: microservices-tcc-alfa   File: JwtConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Qualifier("tokenStore")
public TokenStore tokenStore() {

    System.out.println("Created JwtTokenStore");
    return new JwtTokenStore(jwtAccessTokenConverter);
}
 
Example 7
Project: microservices-tcc-alfa   File: JwtConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Qualifier("tokenStore")
public TokenStore tokenStore() {

    System.out.println("Created JwtTokenStore");
    return new JwtTokenStore(jwtTokenEnhancer());
}
 
Example 8
Project: microservices-tcc-alfa   File: JwtConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Qualifier("tokenStore")
public TokenStore tokenStore() {

    System.out.println("Created JwtTokenStore");
    return new JwtTokenStore(jwtTokenEnhancer());
}
 
Example 9
Project: theskeleton   File: OAuth2AuthorizationServerConfig.java   View source code 5 votes vote down vote up
public OAuth2AuthorizationServerConfig(AccessTokenConverter accessTokenConverter, ApprovalStore approvalStore, AuthenticationManager authenticationManager, OAuth2ClientService clientService, TokenEnhancer tokenEnhancer, TokenStore tokenStore) {
	this.accessTokenConverter = accessTokenConverter;
	this.approvalStore = approvalStore;
	this.authenticationManager = authenticationManager;
	this.clientService = clientService;
	this.tokenEnhancer = tokenEnhancer;
	this.tokenStore = tokenStore;
}
 
Example 10
Project: OAuth-2.0-Cookbook   File: JweTokenStore.java   View source code 5 votes vote down vote up
public JweTokenStore(String encodedSigningKey, TokenStore delegate,
                     JwtAccessTokenConverter converter, JweTokenSerializer crypto) {
    this.encodedSigningKey = encodedSigningKey;
    this.delegate = delegate;
    this.converter = converter;
    this.crypto = crypto;
}
 
Example 11
Project: speakTogether   File: OAuth2ServerConfiguration.java   View source code 5 votes vote down vote up
public ResourceServerConfiguration(TokenStore tokenStore, Http401UnauthorizedEntryPoint http401UnauthorizedEntryPoint,
    AjaxLogoutSuccessHandler ajaxLogoutSuccessHandler, CorsFilter corsFilter) {

    this.tokenStore = tokenStore;
    this.http401UnauthorizedEntryPoint = http401UnauthorizedEntryPoint;
    this.ajaxLogoutSuccessHandler = ajaxLogoutSuccessHandler;
    this.corsFilter = corsFilter;
}
 
Example 12
Project: speakTogether   File: OAuth2ServerConfiguration.java   View source code 5 votes vote down vote up
public AuthorizationServerConfiguration(@Qualifier("authenticationManagerBean") AuthenticationManager authenticationManager,
        TokenStore tokenStore, DataSource dataSource) {

    this.authenticationManager = authenticationManager;
    this.tokenStore = tokenStore;
    this.dataSource = dataSource;
}
 
Example 13
Project: urlshortener   File: SecurityConfig.java   View source code 5 votes vote down vote up
@Bean
@Autowired
public TokenStoreUserApprovalHandler userApprovalHandler(TokenStore tokenStore) {
    TokenStoreUserApprovalHandler handler = new TokenStoreUserApprovalHandler();
    handler.setTokenStore(tokenStore);
    handler.setRequestFactory(new DefaultOAuth2RequestFactory(clientDetailsService));
    handler.setClientDetailsService(clientDetailsService);
    return handler;
}
 
Example 14
Project: urlshortener   File: AuthorizationServerConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Autowired
public ApprovalStore approvalStore(TokenStore tokenStore) throws Exception {
    TokenApprovalStore store = new TokenApprovalStore();
    store.setTokenStore(tokenStore);
    return store;
}
 
Example 15
Project: Spring-cloud-gather   File: AuthorizationServerConfiguration.java   View source code 5 votes vote down vote up
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
	TokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
	// @formatter:off
       endpoints.tokenStore(tokenStore)
           .authenticationManager(authenticationManager)
           .userDetailsService(userDetailsService);
       // @formatter:on
}
 
Example 16
Project: seldon-core   File: SeldonGrpcServer.java   View source code 5 votes vote down vote up
public SeldonGrpcServer(AppProperties appProperties,DeploymentStore deploymentStore,TokenStore tokenStore,ServerBuilder<?> serverBuilder,DeploymentsHandler deploymentsHandler, int port) 
{
    this.appProperties = appProperties;
    this.deploymentStore = deploymentStore;
    this.tokenStore = tokenStore;
    this.grpcDeploymentsListener = new grpcDeploymentsListener(this);
    this.deploymentsHandler = deploymentsHandler;
    deploymentsHandler.addListener(this.grpcDeploymentsListener);
    this.port = port;
    server = serverBuilder
          .addService(ServerInterceptors.intercept(new SeldonService(this), new HeaderServerInterceptor(this)))
      .build();
}
 
Example 17
Project: spring-boot-oauth2-demo   File: OAuth2ServerConfiguration.java   View source code 5 votes vote down vote up
public ResourceServerConfiguration(TokenStore tokenStore, Http401UnauthorizedEntryPoint http401UnauthorizedEntryPoint,
                                   AjaxLogoutSuccessHandler ajaxLogoutSuccessHandler) {
    
    this.tokenStore = tokenStore;
    this.http401UnauthorizedEntryPoint = http401UnauthorizedEntryPoint;
    this.ajaxLogoutSuccessHandler = ajaxLogoutSuccessHandler;
}
 
Example 18
Project: spring-boot-oauth2-demo   File: OAuth2ServerConfiguration.java   View source code 5 votes vote down vote up
public AuthorizationServerConfiguration(@Qualifier("authenticationManagerBean") AuthenticationManager authenticationManager,
                                        TokenStore tokenStore, DataSource dataSource) {
    
    this.authenticationManager = authenticationManager;
    this.tokenStore = tokenStore;
    this.dataSource = dataSource;
}
 
Example 19
Project: weazbootgradle   File: AuthorizationServerConfiguration.java   View source code 5 votes vote down vote up
@Autowired
public AuthorizationServerConfiguration(AuthenticationManager authenticationManager,
                                        CustomClientDetailsService customClientDetailsService,
                                        AuthorizationServerTokenServices tokenServices, TokenStore tokenStore,
                                        OAuth2RequestFactory requestFactory, UserDetailsService userDetailsService, AccessTokenConverter accessTokenConverter) {
    super();
    this.authenticationManager = authenticationManager;
    this.customClientDetailsService = customClientDetailsService;
    this.tokenServices = tokenServices;
    this.tokenStore = tokenStore;
    this.requestFactory = requestFactory;
    this.userDetailsService = userDetailsService;
    this.accessTokenConverter = accessTokenConverter;
}
 
Example 20
Project: graviteeio-access-management   File: OAuth2SecurityConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Autowired
public TokenStoreUserApprovalHandler userApprovalHandler(TokenStore tokenStore){
    TokenStoreUserApprovalHandler handler = new TokenStoreUserApprovalHandler();
    handler.setTokenStore(tokenStore);
    handler.setRequestFactory(new CustomOAuth2RequestFactory(clientDetailsService));
    handler.setClientDetailsService(clientDetailsService);
    return handler;
}
 
Example 21
Project: graviteeio-access-management   File: OAuth2SecurityConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Autowired
public ApprovalStore approvalStore(TokenStore tokenStore) throws Exception {
    TokenApprovalStore store = new TokenApprovalStore();
    store.setTokenStore(tokenStore);
    return store;
}
 
Example 22
Project: GameNation   File: OAuth2Configuration.java   View source code 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    TokenStore store = new InMemoryTokenStore();

    // add new token to store, this is an unlimited token to use during testing
    UnlimitedToken token = new UnlimitedToken();
    UnlimitedAuthentication unlimitedAuthentication = new UnlimitedAuthentication();
    OAuth2Request request = new OAuth2Request(new HashMap<String, String>(), "web-gamenation", unlimitedAuthentication.getAuthorities(), true, token.getScope(), null, "", new HashSet<String>(), new HashMap<String, Serializable>());
    OAuth2Authentication oAuth2Authentication = new OAuth2Authentication(request, unlimitedAuthentication);
    store.storeAccessToken(token, oAuth2Authentication);

    return store;
}
 
Example 23
Project: pimp   File: OAuthConfig.java   View source code 5 votes vote down vote up
@Bean
@Primary
@Autowired
AuthorizationServerTokenServices authorizationServerTokenServices(TokenStore tokenStore, TokenEnhancer tokenEnhancer) {
    DefaultTokenServices tokenServices = new DefaultTokenServices();
    tokenServices.setTokenStore(tokenStore);
    tokenServices.setSupportRefreshToken(true);
    tokenServices.setTokenEnhancer(tokenEnhancer);
    return tokenServices;
}
 
Example 24
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: OAuth2AuthorizationServerConfiguration.java   View source code 5 votes vote down vote up
public OAuth2AuthorizationServerConfiguration(BaseClientDetails details,
		AuthenticationManager authenticationManager,
		ObjectProvider<TokenStore> tokenStoreProvider,
		AuthorizationServerProperties properties) {
	this.details = details;
	this.authenticationManager = authenticationManager;
	this.tokenStore = tokenStoreProvider.getIfAvailable();
	this.properties = properties;
}
 
Example 25
Project: jwt-oauth2   File: OAuth2Application.java   View source code 5 votes vote down vote up
@Bean
@Qualifier("tokenStore")
public TokenStore tokenStore() {

  log.info("Created JwtTokenStore");
  return new JWTMongoTokenStore(jwtTokenEnhancer());
}
 
Example 26
Project: spring-boot-concourse   File: OAuth2AuthorizationServerConfiguration.java   View source code 5 votes vote down vote up
public OAuth2AuthorizationServerConfiguration(BaseClientDetails details,
		AuthenticationManager authenticationManager,
		ObjectProvider<TokenStore> tokenStoreProvider,
		AuthorizationServerProperties properties) {
	this.details = details;
	this.authenticationManager = authenticationManager;
	this.tokenStore = tokenStoreProvider.getIfAvailable();
	this.properties = properties;
}
 
Example 27
Project: credhub   File: OAuth2ExtraValidationFilter.java   View source code 5 votes vote down vote up
@Autowired
OAuth2ExtraValidationFilter(
    OAuth2IssuerService oAuth2IssuerService,
    TokenStore tokenStore,
    AuditOAuth2AuthenticationExceptionHandler oAuth2AuthenticationExceptionHandler,
    MessageSourceAccessor messageSourceAccessor,
    AuthenticationEventPublisher eventPublisher
) {
  this.oAuth2IssuerService = oAuth2IssuerService;
  this.tokenStore = tokenStore;
  this.oAuth2AuthenticationExceptionHandler = oAuth2AuthenticationExceptionHandler;
  this.eventPublisher = eventPublisher;
  this.tokenExtractor = new BearerTokenExtractor();
  this.messageSourceAccessor = messageSourceAccessor;
}
 
Example 28
Project: wso2is-springoauth   File: OAuth2ServerConfiguration.java   View source code 5 votes vote down vote up
@Override
public void configure(ResourceServerSecurityConfigurer resources) {
    //JDBC
    //TokenStore wso2TokenStore = new JdbcWso2TokenStore(wso2OauthDataSource());
    //WS
    TokenStore wso2TokenStore = new WSWso2TokenStore(oAuthAdminServiceClient(marshaller()), oAuth2TokenValidationService(marshaller()));
    //EXAMPLE: DO NOT DO THIS
    System.setProperty("javax.net.ssl.trustStore", "C:/dev/wso2is-5.0.0/repository/resources/security/wso2carbon.jks");
    System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
    System.setProperty("javax.net.ssl.trustStoreType", "JKS");
    resources.tokenStore(wso2TokenStore);
}
 
Example 29
Project: jsonwebtoken   File: JwtOAuth2AutoConfiguration.java   View source code 5 votes vote down vote up
@Bean
@ConditionalOnBean(JwtDecodingProcessor.class)
@ConditionalOnMissingBean(TokenStore.class)
public JwtTokenStore jwtTokenStore(JwtDecodingProcessor jwtProcessor,
                                   ObjectProvider<ApprovalStore> approvalStore) {
    if (clock != null) {
        return new JwtTokenStore(jwtProcessor, approvalStore.getIfAvailable(), clock);
    } else {
        return new JwtTokenStore(jwtProcessor, approvalStore.getIfAvailable());
    }
}
 
Example 30
Project: jsonwebtoken   File: JwtOAuth2AutoConfiguration.java   View source code 5 votes vote down vote up
public AuthorizationServerConfiguration(BaseClientDetails details, AuthenticationManager authenticationManager,
                                        ObjectProvider<TokenStore> tokenStore,
                                        ObjectProvider<AccessTokenConverter> tokenConverter,
                                        ObjectProvider<TokenEnhancer> tokenEnhancer,
                                        AuthorizationServerProperties properties) {
    super(details, authenticationManager, tokenStore, tokenConverter, properties);
    this.tokenEnhancer = tokenEnhancer.getIfAvailable();
}
 
Example 31
Project: jsonwebtoken   File: OAuth2ResourceServerConfiguration.java   View source code 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean({ AuthorizationServerSecurityConfiguration.class, ResourceServerTokenServices.class })
public ResourceServerTokenServices resourceServerTokenServices(TokenStore tokenStore) {
    DefaultTokenServices tokenServices = new DefaultTokenServices();
    tokenServices.setTokenStore(tokenStore);
    return tokenServices;
}
 
Example 32
Project: osiam   File: TokenService.java   View source code 5 votes vote down vote up
@Autowired
public TokenService(TokenStore tokenStore,
                    SCIMUserProvisioning userProvisioning,
                    ClientRepository clientRepository) {
    this.tokenStore = tokenStore;
    this.userProvisioning = userProvisioning;
    this.clientRepository = clientRepository;
}
 
Example 33
Project: spring-cloud-sso-connector   File: IssuerCheckConfiguration.java   View source code 5 votes vote down vote up
@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 34
Project: spring-cloud-sso-connector   File: IssuerCheckConfigurationLocalTest.java   View source code 5 votes vote down vote up
@Test
public void testJwkTokenStoreNotFoundInContext() {
    thrown.expect(NoSuchBeanDefinitionException.class);
    thrown.expectMessage("No qualifying bean of type 'org.springframework.security.oauth2.provider.token.TokenStore' available");

    applicationContext.getBean( TokenStore.class );

}
 
Example 35
Project: oauth2-provider   File: UserServiceTest.java   View source code 5 votes vote down vote up
@Before
public void setup() {
    reset(userRepository);
    tokenStore = mock(TokenStore.class);
    tokenServices = new DefaultTokenServices();
    tokenServices.setTokenStore(tokenStore);
    userService = new UserServiceImpl(userRepository, validator, new StandardPasswordEncoder());
    final User user = new User(getApiUser(), password, Role.ROLE_USER);
    Mockito.when(userRepository.save(Mockito.any(User.class))).thenAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return user;
        }
    });
}
 
Example 36
Project: xm-uaa   File: SecurityBeanOverrideConfiguration.java   View source code 4 votes vote down vote up
@Bean
@Primary
public TokenStore tokenStore() {
    return null;
}
 
Example 37
Project: oauth2-with-jdbc   File: AppConfig.java   View source code 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JdbcTokenStore(dataSource());
}
 
Example 38
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java   View source code 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(TokenStore.class)
public TokenStore jwkTokenStore() {
	return new JwkTokenStore(this.resource.getJwk().getKeySetUri());
}
 
Example 39
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java   View source code 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(TokenStore.class)
public TokenStore jwtTokenStore() {
	return new JwtTokenStore(jwtTokenEnhancer());
}
 
Example 40
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfigurationTests.java   View source code 4 votes vote down vote up
@Bean
public TokenStore tokenStore(JwtAccessTokenConverter jwtTokenEnhancer) {
	return new JwtTokenStore(jwtTokenEnhancer);
}