Java Code Examples for org.springframework.security.oauth2.provider.token.DefaultTokenServices#setTokenStore()
The following examples show how to use
org.springframework.security.oauth2.provider.token.DefaultTokenServices#setTokenStore() .
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 File: SophiaAuthorizationServerConfig.java From sophia_scaffolding with Apache License 2.0 | 6 votes |
/** * 注意,自定义TokenServices的时候,需要设置@Primary,否则报错 */ @Primary @Bean public DefaultTokenServices defaultTokenServices() { DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); tokenServices.setSupportRefreshToken(true); // 这里如果设置为false则不能更新refresh_token,如果需要刷新token的功能需要设置成true tokenServices.setSupportRefreshToken(true); // 设置上次RefreshToken是否还可以使用 默认为true tokenServices.setReuseRefreshToken(false); // token有效期自定义设置,默认12小时 tokenServices.setAccessTokenValiditySeconds(60 * 60 * 6); // refresh_token默认30天 tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 8); tokenServices.setTokenEnhancer(tokenEnhancer()); return tokenServices; }
Example 2
Source File: CustomAuthorizationConfig.java From Spring-5.0-Projects with MIT License | 5 votes |
@Bean("resourceServerTokenServices") @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(false); defaultTokenServices.setAccessTokenValiditySeconds(120); defaultTokenServices.setTokenEnhancer(accessTokenConverter()); return defaultTokenServices; }
Example 3
Source File: ResourceServerTokenServicesConfiguration.java From spring-security-oauth2-boot with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(ResourceServerTokenServices.class) public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) { DefaultTokenServices services = new DefaultTokenServices(); services.setTokenStore(jwtTokenStore); return services; }
Example 4
Source File: ResourceServerTokenServicesConfiguration.java From spring-security-oauth2-boot with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(ResourceServerTokenServices.class) public DefaultTokenServices jwtTokenServices(TokenStore jwtTokenStore) { DefaultTokenServices services = new DefaultTokenServices(); services.setTokenStore(jwtTokenStore); return services; }
Example 5
Source File: ResourceServerConfig.java From java8-spring-cloud-microservice-demo with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices getTokenService() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(this.jwtTokenStore()); return defaultTokenServices; }
Example 6
Source File: JWTTokenStoreConfig.java From spring-microservices-in-action with Apache License 2.0 | 5 votes |
/** * Generate token services. * * <p>This method will use the Spring security’s default token services * implementation which tokens will be generated as random UUID values. * * @return The {@code DefaultTokenServices} object. */ @Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 7
Source File: OAuth2JwtConfig.java From java8-spring-cloud-microservice-demo with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 8
Source File: TokenStoreConfig.java From oauth2-blog with MIT License | 5 votes |
@Bean public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 9
Source File: AuthorizationServerConfig.java From java-tutorial with MIT License | 5 votes |
/** * 注意,自定义TokenServices的时候,需要设置@Primary,否则报错 * * @return */ @Primary @Bean public DefaultTokenServices defaultTokenServices() { DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(jdbcTokenStore); tokenServices.setSupportRefreshToken(true); tokenServices.setClientDetailsService(clientDetails()); // token有效期自定义设置24小时,默认12小时 tokenServices.setAccessTokenValiditySeconds(60 * 60 * 24); //默认30天,这里修改 tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 7); return tokenServices; }
Example 10
Source File: OAuth2ResourceServerConfig.java From spring-security-oauth with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); return defaultTokenServices; }
Example 11
Source File: AuthorizationSeverConfig.java From springboot-vue.js-bbs with Apache License 2.0 | 5 votes |
@Bean @Primary public DefaultTokenServices tokenService() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 12
Source File: CustomAuthorizationServerConfiguration.java From spring-microservice-boilerplate with MIT License | 5 votes |
@Bean(name = "customTokenServices") @Primary public DefaultTokenServices customTokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(customTokenStore.customTokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 13
Source File: AuthorizationServerConfig.java From syhthems-platform with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(jwtTokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 14
Source File: SecurityConfig.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Primary @Bean public AuthorizationServerTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore( new JdbcTokenStore( dataSource ) ); defaultTokenServices.setSupportRefreshToken( true ); return defaultTokenServices; }
Example 15
Source File: AuthServerOAuth2Config.java From Building-Web-Apps-with-Spring-5-and-Angular with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 16
Source File: AuthorizationServerConfiguration.java From spring-boot-demo with MIT License | 5 votes |
/** * 用来配置授权(authorization)以及令牌(token)的访问端点和令牌服务(token services) * * @param endpoints * @throws Exception */ @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // 配置tokenStore // endpoints.authenticationManager(authenticationManager).tokenStore(tokenStore()) // .accessTokenConverter(accessTokenConverter()).userDetailsService(userDetailsService); //指定认证管理器 endpoints.authenticationManager(authenticationManager); //指定token存储位置 endpoints.tokenStore(tokenStore()); endpoints.accessTokenConverter(accessTokenConverter()); endpoints.userDetailsService(userDetailsService); //自定义token生成方式 TokenEnhancerChain tokenEnhancerChain = new TokenEnhancerChain(); tokenEnhancerChain.setTokenEnhancers(Arrays.asList(customerEnhancer(), accessTokenConverter())); endpoints.tokenEnhancer(tokenEnhancerChain); // 配置TokenServices参数 DefaultTokenServices tokenServices = (DefaultTokenServices) endpoints.getDefaultAuthorizationServerTokenServices(); tokenServices.setTokenStore(endpoints.getTokenStore()); tokenServices.setSupportRefreshToken(true); tokenServices.setClientDetailsService(endpoints.getClientDetailsService()); tokenServices.setTokenEnhancer(endpoints.getTokenEnhancer()); tokenServices.setAccessTokenValiditySeconds((int) TimeUnit.DAYS.toSeconds(1));//一天 endpoints.tokenServices(tokenServices); }
Example 17
Source File: OAuth2AuthorizationServerConfigJwt.java From spring-security-oauth with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example 18
Source File: OAuth2ResourceServerConfig.java From spring-security-oauth with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); return defaultTokenServices; }
Example 19
Source File: ResourceServerOAuth2Config.java From Building-Web-Apps-with-Spring-5-and-Angular with MIT License | 4 votes |
@Override public void configure(final ResourceServerSecurityConfigurer config) { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(this.tokenStore); config.tokenServices(defaultTokenServices); }
Example 20
Source File: ResourceServerConfiguration.java From edison-microservice with Apache License 2.0 | 4 votes |
private DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); return defaultTokenServices; }