org.springframework.security.oauth2.provider.token.store.JwtTokenStore Java Examples

The following examples show how to use org.springframework.security.oauth2.provider.token.store.JwtTokenStore. 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: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #2
Source File: OAuthTokenConfiguration.java    From Spring-5.0-By-Example with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #3
Source File: FebsAuthorizationServerConfigure.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    if (properties.getEnableJwt()) {
        return new JwtTokenStore(jwtAccessTokenConverter());
    } else {
        RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);
        // 解决每次生成的 token都一样的问题
        redisTokenStore.setAuthenticationKeyGenerator(oAuth2Authentication -> UUID.randomUUID().toString());
        return redisTokenStore;
    }
}
 
Example #4
Source File: AuthorizationServerConfig.java    From cloud-service with MIT License 5 votes vote down vote up
/**
 * 令牌存储
 */
@Bean
public TokenStore tokenStore() {
    if (storeWithJwt) {
        return new JwtTokenStore(accessTokenConverter());
    }
    RedisTokenStore redisTokenStore = new RedisTokenStore(redisConnectionFactory);
    // 解决同一username每次登陆access_token都相同的问题
    redisTokenStore.setAuthenticationKeyGenerator(new RandomAuthenticationKeyGenerator());

    return redisTokenStore;
}
 
Example #5
Source File: ResourceServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void jwtTokenStoreShouldBeConditionalOnMissingBean() throws Exception {
	TestPropertyValues.of("security.oauth2.resource.jwt.keyValue=" + PUBLIC_KEY).applyTo(this.environment);
	this.context = new SpringApplicationBuilder(JwtTokenStoreConfiguration.class, ResourceConfiguration.class)
			.environment(this.environment).web(WebApplicationType.NONE).run();
	assertThat(this.context.getBeansOfType(JwtTokenStore.class)).hasSize(1);
}
 
Example #6
Source File: OAuth2ServerConfiguration.java    From spring-boot-oauth2-password-flow with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
    endpoints
            .tokenStore(new JwtTokenStore(jwtAccessTokenConverter))
            .authenticationManager(authenticationManager)
            .accessTokenConverter(jwtAccessTokenConverter);
}
 
Example #7
Source File: OpenHelper.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 构建资源服务器JwtToken服务类
 *
 * @param properties
 * @return
 */
public static ResourceServerTokenServices buildJwtTokenServices(OpenCommonProperties properties) throws Exception {
    // 使用自定义系统用户凭证转换器
    DefaultAccessTokenConverter accessTokenConverter = buildAccessTokenConverter();
    OpenJwtTokenService tokenServices = new OpenJwtTokenService();
    // 这里的签名key 保持和认证中心一致
    JwtAccessTokenConverter converter = buildJwtTokenEnhancer(properties);
    JwtTokenStore jwtTokenStore = new JwtTokenStore(converter);
    tokenServices.setTokenStore(jwtTokenStore);
    tokenServices.setJwtAccessTokenConverter(converter);
    tokenServices.setDefaultAccessTokenConverter(accessTokenConverter);
    log.info("buildJwtTokenServices[{}]", tokenServices);
    return tokenServices;
}
 
Example #8
Source File: OAuthTokenConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #9
Source File: OAuthTokenConfiguration.java    From Spring-5.0-By-Example with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #10
Source File: OAuthTokenConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #11
Source File: OAuthTokenConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #12
Source File: OAuthTokenConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #13
Source File: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #14
Source File: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #15
Source File: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #16
Source File: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #17
Source File: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #18
Source File: OAuthTokenConfiguration.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #19
Source File: AuthorizationServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Test
public void configureWhenKeyStoreIsProvidedThenExposesJwtTokenStore() {
	this.contextRunner.withPropertyValues(
			"security.oauth2.authorization.jwt.key-store=classpath:"
					+ "org/springframework/boot/autoconfigure/security/oauth2/authserver/keystore.jks",
			"security.oauth2.authorization.jwt.key-store-password=changeme",
			"security.oauth2.authorization.jwt.key-alias=jwt").run(context -> {
				assertThat(context.getBeansOfType(TokenStore.class)).hasSize(1);
				assertThat(context.getBean(TokenStore.class)).isInstanceOf(JwtTokenStore.class);
			});
}
 
Example #20
Source File: AuthorizationServerConfiguration.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
	if (this.jwtEnabled) {
		return new JwtTokenStore(accessTokenConverter());
	} else {
		return new InMemoryTokenStore();
	}
}
 
Example #21
Source File: OAuthTokenConfiguration.java    From Spring-5.0-By-Example with MIT License 5 votes vote down vote up
@Bean
public JwtTokenStore tokenStore() throws Exception {
  JwtAccessTokenConverter enhancer = new JwtAccessTokenConverter();
  enhancer.setSigningKey(privateKey);
  enhancer.setVerifierKey(publicKey);
  enhancer.afterPropertiesSet();
  return new JwtTokenStore(enhancer);
}
 
Example #22
Source File: ResourceServerConfig.java    From codeway_service with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
}
 
Example #23
Source File: ResourceServerConfig.java    From SpringCloud with Apache License 2.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}
 
Example #24
Source File: OAuth2AuthorizationServer.java    From oauth2lab with MIT License 4 votes vote down vote up
@Bean
public JwtTokenStore jwtTokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}
 
Example #25
Source File: JWTokenConfig.java    From SpringAll with MIT License 4 votes vote down vote up
@Bean
public TokenStore jwtTokenStore() {
    return new JwtTokenStore(jwtAccessTokenConverter());
}
 
Example #26
Source File: ResourceServerConfig.java    From java8-spring-cloud-microservice-demo with MIT License 4 votes vote down vote up
@Bean
public TokenStore jwtTokenStore() {
    return new JwtTokenStore(this.jwtTokenConverter());
}
 
Example #27
Source File: AuthorizationSeverConfig.java    From springboot-vue.js-bbs with Apache License 2.0 4 votes vote down vote up
/**
 * BEGIN: 인증 서버와 리소스 서버가 분리되어 있어야 하나 Toy project 상황상 결합되어 있음
 * 아래 3개의 Bean들은 서버에 각각 존재해야 함: 특히 TokenConverter의 keyPair(인증서버), VerifierKey(리소스서버)
 */

@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}
 
Example #28
Source File: AuthorizationConfig.java    From Using-Spring-Oauth2-to-secure-REST with MIT License 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());

}
 
Example #29
Source File: AuthorizationServerConfig.java    From cloud-project with Apache License 2.0 4 votes vote down vote up
/**
 * 令牌存储
 * @return redis令牌存储对象
 */
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}
 
Example #30
Source File: ZuulServerApplication.java    From Spring5Tutorial with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    return new JwtTokenStore(accessTokenConverter());
}