org.springframework.security.oauth2.provider.token.DefaultTokenServices Java Examples
The following examples show how to use
org.springframework.security.oauth2.provider.token.DefaultTokenServices.
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: AuthorizationServerConfig.java From lion with Apache License 2.0 | 6 votes |
@Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { // 配置tokenServices参数 DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); /** * jwt 无状态方式 */ //tokenServices.setTokenEnhancer(jwtAccessTokenConverter()); tokenServices.setSupportRefreshToken(true); tokenServices.setClientDetailsService(clientDetails()); // 设置access_token有效时长12小时,默认12小时 tokenServices.setAccessTokenValiditySeconds(60 * 60 * 12); // 设置refresh_token有效时长7天,默认30天 tokenServices.setRefreshTokenValiditySeconds(60 * 60 * 24 * 7); endpoints .userDetailsService(userDetailsService) .authenticationManager(authenticationManager) .tokenServices(tokenServices) // 自定义认证异常处理类 .exceptionTranslator(webResponseExceptionTranslator()); }
Example #2
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 #3
Source File: OAuth2Config.java From konker-platform with Apache License 2.0 | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(mongoTokenStore); defaultTokenServices.setClientDetailsService(clientDetailsService); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example #4
Source File: OAuth2AutoConfigurationTests.java From spring-security-oauth2-boot with Apache License 2.0 | 5 votes |
@Test public void testDisablingAuthorizationServer() { this.context = new AnnotationConfigServletWebServerApplicationContext(); this.context.register(ResourceServerConfiguration.class, MinimalSecureWebApplication.class); TestPropertyValues.of("security.oauth2.resource.jwt.keyValue:DEADBEEF").applyTo(this.context); ConfigurationPropertySources.attach(this.context.getEnvironment()); this.context.refresh(); assertThat(countBeans(RESOURCE_SERVER_CONFIG)).isEqualTo(1); assertThat(countBeans(AUTHORIZATION_SERVER_CONFIG)).isEqualTo(0); assertThat(countBeans(UserApprovalHandler.class)).isEqualTo(0); assertThat(countBeans(DefaultTokenServices.class)).isEqualTo(1); }
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: 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 #7
Source File: AuthorizationConfig.java From Using-Spring-Oauth2-to-secure-REST with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { MyTokenService tokenService = new MyTokenService(blackListService); tokenService.setTokenStore(tokenStore()); tokenService.setSupportRefreshToken(true); tokenService.setTokenEnhancer(accessTokenConverter()); return tokenService; }
Example #8
Source File: AuthorizationServerConfig.java From Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); defaultTokenServices.setTokenEnhancer(accessTokenConverter()); return defaultTokenServices; }
Example #9
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 #10
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 #11
Source File: JdbcOAuth2Config.java From microservice-skeleton with MIT License | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example #12
Source File: SecurityConfig.java From incubator-wikift with Apache License 2.0 | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example #13
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 #14
Source File: OAuth2Config.java From konker-platform with Apache License 2.0 | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(mongoTokenStore); defaultTokenServices.setClientDetailsService(clientDetailsService); defaultTokenServices.setSupportRefreshToken(true); defaultTokenServices.setTokenEnhancer(new CustomTokenEnhancer()); return defaultTokenServices; }
Example #15
Source File: OAuth2AuthorizationServerConfig.java From gemini with Apache License 2.0 | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(tokenStore()); return defaultTokenServices; }
Example #16
Source File: OAuth2Config.java From konker-platform with Apache License 2.0 | 5 votes |
@Bean @Primary public DefaultTokenServices tokenServices() { DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); defaultTokenServices.setTokenStore(mongoTokenStore); defaultTokenServices.setClientDetailsService(clientDetailsService); defaultTokenServices.setSupportRefreshToken(true); return defaultTokenServices; }
Example #17
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 #18
Source File: OAuth2ResourceServerConfigJwt.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: OAuth2AuthorizationServerConfigInMemory.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 #20
Source File: OAuth2AuthorizationServerConfig.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 #21
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 #22
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 #23
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 #24
Source File: OAuth2AuthorizationServerConfig.java From NFVO with Apache License 2.0 | 5 votes |
@PostConstruct public void init() { serviceTokenServices = new DefaultTokenServices(); serviceTokenServices.setSupportRefreshToken(true); serviceTokenServices.setTokenStore(tokenStore); serviceTokenServices.setAccessTokenValiditySeconds(serviceTokenValidityDuration); imageTokenServices = new DefaultTokenServices(); imageTokenServices.setSupportRefreshToken(false); imageTokenServices.setTokenStore(tokenStore); imageTokenServices.setAccessTokenValiditySeconds(imageTokenValidityDuration); }
Example #25
Source File: OAuthPublicKeyTestConfiguration.java From edison-microservice with Apache License 2.0 | 5 votes |
@Bean @Profile("test") public AuthorizationServerTokenServices testAuthorizationServerTokenServices(final KeyExchangeJwtAccessTokenConverter keyExchangeJwtAccessTokenConverter, final KeyPair keyPair) { final DefaultTokenServices defaultTokenServices = new DefaultTokenServices(); keyExchangeJwtAccessTokenConverter.setKeyPair(keyPair); defaultTokenServices.setTokenStore(new JwtTokenStore(keyExchangeJwtAccessTokenConverter)); return defaultTokenServices; }
Example #26
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 #27
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 #28
Source File: FebsAuthorizationServerConfigure.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@Bean public ResourceOwnerPasswordTokenGranter resourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager, OAuth2RequestFactory oAuth2RequestFactory) { DefaultTokenServices defaultTokenServices = defaultTokenServices(); if (properties.getEnableJwt()) { defaultTokenServices.setTokenEnhancer(jwtAccessTokenConverter()); } return new ResourceOwnerPasswordTokenGranter(authenticationManager, defaultTokenServices, redisClientDetailsService, oAuth2RequestFactory); }
Example #29
Source File: AuthorizationServerConfiguration.java From open-cloud with MIT License | 5 votes |
private DefaultTokenServices createDefaultTokenServices() { DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); tokenServices.setTokenEnhancer(tokenEnhancer()); tokenServices.setSupportRefreshToken(true); tokenServices.setReuseRefreshToken(true); tokenServices.setClientDetailsService(customClientDetailsService); return tokenServices; }
Example #30
Source File: AuthorizationServerConfiguration.java From open-cloud with MIT License | 5 votes |
private DefaultTokenServices createDefaultTokenServices() { DefaultTokenServices tokenServices = new DefaultTokenServices(); tokenServices.setTokenStore(tokenStore()); tokenServices.setTokenEnhancer(tokenEnhancer()); tokenServices.setSupportRefreshToken(true); tokenServices.setReuseRefreshToken(true); tokenServices.setClientDetailsService(customClientDetailsService); return tokenServices; }