Java Code Examples for org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter.setSigningKey()

The following are Jave code examples for showing how to use setSigningKey() of the org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: spring-security-oauth2-boot   File: ResourceServerTokenServicesConfiguration.java   View Source Code Vote up 6 votes
@Bean
public JwtAccessTokenConverter jwtTokenEnhancer() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	String keyValue = this.resource.getJwt().getKeyValue();
	if (!StringUtils.hasText(keyValue)) {
		keyValue = getKeyFromServer();
	}
	if (StringUtils.hasText(keyValue) && !keyValue.startsWith("-----BEGIN")) {
		converter.setSigningKey(keyValue);
	}
	if (keyValue != null) {
		converter.setVerifierKey(keyValue);
	}
	if (!CollectionUtils.isEmpty(this.configurers)) {
		AnnotationAwareOrderComparator.sort(this.configurers);
		for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
			configurer.configure(converter);
		}
	}
	return converter;
}
 
Example 2
Project: hawkbit-extensions   File: UaaOAuthAutoConfiguration.java   View Source Code Vote up 6 votes
/**
 * @return The {@link JwtTokenStore} verifies access tokens and extract
 *         authentication and authorities from it.
 */
@Bean
public JwtTokenStore jwtTokenStore() {
    final DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
    accessTokenConverter.setUserTokenConverter(userPrincipalInfoTokenServices());
    final JwtAccessTokenConverter jwtTokenEnhancer = new JwtAccessTokenConverter();
    jwtTokenEnhancer.setAccessTokenConverter(accessTokenConverter);
    jwtTokenEnhancer.setSigningKey(uaaClientResources.getResource().getJwt().getKeyValue());
    jwtTokenEnhancer.setVerifierKey(uaaClientResources.getResource().getJwt().getKeyValue());
    try {
        jwtTokenEnhancer.afterPropertiesSet();
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
    return new JwtTokenStore(jwtTokenEnhancer);
}
 
Example 3
Project: spring-security-oauth   File: OAuth2ResourceServerConfig3.java   View Source Code Vote up 6 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("123");
    converter.setJwtClaimsSetVerifier(jwtClaimsSetVerifier());
    return converter;
}
 
Example 4
Project: spring-security-oauth   File: OAuth2ResourceServerConfig.java   View Source Code Vote up 6 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("123");
    converter.setJwtClaimsSetVerifier(jwtClaimsSetVerifier());

    // final Resource resource = new ClassPathResource("public.txt");
    // String publicKey = null;
    // try {
    // publicKey = IOUtils.toString(resource.getInputStream());
    // } catch (final IOException e) {
    // throw new RuntimeException(e);
    // }
    // converter.setVerifierKey(publicKey);
    return converter;
}
 
Example 5
Project: contestparser   File: ResourceServerTokenServicesConfiguration.java   View Source Code Vote up 6 votes
@Bean
public JwtAccessTokenConverter jwtTokenEnhancer() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	String keyValue = this.resource.getJwt().getKeyValue();
	if (!StringUtils.hasText(keyValue)) {
		try {
			keyValue = getKeyFromServer();
		}
		catch (ResourceAccessException ex) {
			logger.warn("Failed to fetch token key (you may need to refresh "
					+ "when the auth server is back)");
		}
	}
	if (StringUtils.hasText(keyValue) && !keyValue.startsWith("-----BEGIN")) {
		converter.setSigningKey(keyValue);
	}
	if (keyValue != null) {
		converter.setVerifierKey(keyValue);
	}
	AnnotationAwareOrderComparator.sort(this.configurers);
	for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
		configurer.configure(converter);
	}
	return converter;
}
 
Example 6
Project: OAuth-2.0-Cookbook   File: OAuth2ResourceServer.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setVerifier(verifier());
    converter.setSigningKey("non-prod");
    return converter;
}
 
Example 7
Project: spring-oauth2-jwt   File: JWTConfiguration.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter tokenEnhancer() {
    JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
    jwtAccessTokenConverter.setAccessTokenConverter(defaultAccessTokenConverter());

    jwtAccessTokenConverter.setSigningKey("123");

    return jwtAccessTokenConverter;
}
 
Example 8
Project: spring-oauth2-jwt   File: JWTConfiguration.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter tokenEnhancer(){
    JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
    jwtAccessTokenConverter.setAccessTokenConverter(defaultAccessTokenConverter());
    jwtAccessTokenConverter.setSigningKey("123");
    return jwtAccessTokenConverter;
}
 
Example 9
Project: Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token   File: AuthorizationServerConfig.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    try {
        converter.setSigningKey(keyProvider.getKey());
    } catch (URISyntaxException | KeyStoreException | NoSuchAlgorithmException | IOException | UnrecoverableKeyException | CertificateException e) {
        e.printStackTrace();
    }

    return converter;
}
 
Example 10
Project: tokamak   File: AuthorizationServerConfiguration.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	converter.setSigningKey(privateKey);
	converter.setVerifierKey(publicKey);
	converter.setAccessTokenConverter(tokenConverter);
	return converter;
}
 
Example 11
Project: tcloud-microservices   File: AuthServiceApplication.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter tokenEnhancer() {
    logger.warn("Initializing JWT with public key:\n" + publicKey);
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey(privateKey);
    converter.setVerifierKey(publicKey);
    return converter;
}
 
Example 12
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: ResourceServerTokenServicesConfiguration.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter jwtTokenEnhancer() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	String keyValue = this.resource.getJwt().getKeyValue();
	if (!StringUtils.hasText(keyValue)) {
		try {
			keyValue = getKeyFromServer();
		}
		catch (ResourceAccessException ex) {
			logger.warn("Failed to fetch token key (you may need to refresh "
					+ "when the auth server is back)");
		}
	}
	if (StringUtils.hasText(keyValue) && !keyValue.startsWith("-----BEGIN")) {
		converter.setSigningKey(keyValue);
	}
	if (keyValue != null) {
		converter.setVerifierKey(keyValue);
	}
	if (!CollectionUtils.isEmpty(this.configurers)) {
		AnnotationAwareOrderComparator.sort(this.configurers);
		for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
			configurer.configure(converter);
		}
	}
	return converter;
}
 
Example 13
Project: spring-security-oauth   File: OAuth2ResourceServerConfig2.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("123");
    converter.setVerifierKey("123");

    return converter;
}
 
Example 14
Project: spring-oauth-social-microservice-starter   File: JwtConfig.java   View Source Code Vote up 5 votes
@Override
public void configure(JwtAccessTokenConverter converter) {
    DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
    accessTokenConverter.setUserTokenConverter(userJwtTokenConverter);
    converter.setAccessTokenConverter(accessTokenConverter);
    converter.setSigningKey(jwtKey);
    converter.setVerifierKey(jwtKey);
}
 
Example 15
Project: spring-oauth-social-microservice-starter   File: SecurityConfig.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey(jwtKey);
    converter.setVerifierKey(jwtKey);

    //Customize how our jwt looks like
    DefaultAccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();
    tokenConverter.setUserTokenConverter(userJwtTokenConverter);
    converter.setAccessTokenConverter(tokenConverter);

    return converter;
}
 
Example 16
Project: spring-boot-concourse   File: ResourceServerTokenServicesConfiguration.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter jwtTokenEnhancer() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	String keyValue = this.resource.getJwt().getKeyValue();
	if (!StringUtils.hasText(keyValue)) {
		try {
			keyValue = getKeyFromServer();
		}
		catch (ResourceAccessException ex) {
			logger.warn("Failed to fetch token key (you may need to refresh "
					+ "when the auth server is back)");
		}
	}
	if (StringUtils.hasText(keyValue) && !keyValue.startsWith("-----BEGIN")) {
		converter.setSigningKey(keyValue);
	}
	if (keyValue != null) {
		converter.setVerifierKey(keyValue);
	}
	if (!CollectionUtils.isEmpty(this.configurers)) {
		AnnotationAwareOrderComparator.sort(this.configurers);
		for (JwtAccessTokenConverterConfigurer configurer : this.configurers) {
			configurer.configure(converter);
		}
	}
	return converter;
}
 
Example 17
Project: user-management   File: SecurityConfig.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter myjwtTokenEnhancer() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter();
    DefaultUserAuthenticationConverter userTokenConverter = new ScopeAuthoritiesTokenConverter();
    accessTokenConverter.setUserTokenConverter(userTokenConverter);
    converter.setAccessTokenConverter(accessTokenConverter);
    
    String keyValue = resource.getJwt().getKeyValue();
    if (!StringUtils.hasText(keyValue)) {
        try {
            keyValue = (String) new RestTemplate().getForObject(
                    resource.getJwt().getKeyUri(), Map.class).get("value");
        }
        catch (ResourceAccessException e) {
            throw new TokenFetchException("Failed to fetch token key from " + resource.getJwt().getKeyUri(), e);
        }
    }
    else {
        if (StringUtils.hasText(keyValue) && !keyValue.startsWith("-----BEGIN")) {
            converter.setSigningKey(keyValue);
        }
    }
    converter.setVerifierKey(keyValue);
    
    return converter;
}
 
Example 18
Project: onetwo   File: Oauth2TokenStoreConfiguration.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	converter.setSigningKey(jfishOauth2Properties.getJwt().getSigningKey());
	/*if (keyValue != null) {
		converter.setVerifierKey(keyValue);
	}*/
	return converter;
}
 
Example 19
Project: resource-server-testing   File: AuthorizationServerConfig.java   View Source Code Vote up 5 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() throws Exception {
	JwtAccessTokenConverter jwt = new JwtAccessTokenConverter();
	jwt.setSigningKey(signing);
	jwt.setVerifierKey(verifier);
	jwt.afterPropertiesSet();
	return jwt;
}
 
Example 20
Project: crowdsource   File: SecurityConfig.java   View Source Code Vote up 5 votes
@Bean
public AccessTokenConverter accessTokenConverter() throws IOException {
    final JwtAccessTokenConverter jwtTokenEnhancer = new JwtAccessTokenConverter();
    jwtTokenEnhancer.setSigningKey(IOUtils.toString(getClass().getResourceAsStream("/security/tokensigningkey")));
    jwtTokenEnhancer.setVerifierKey(IOUtils.toString(getClass().getResourceAsStream("/security/tokensigningkey.pub")));
    return jwtTokenEnhancer;
}
 
Example 21
Project: OAuth-2.0-Cookbook   File: OAuth2AuthorizationServer.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("non-prod-signature");
    return converter;
}
 
Example 22
Project: OAuth-2.0-Cookbook   File: OAuth2AuthorizationServer.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("non-prod");
    return converter;
}
 
Example 23
Project: OAuth-2.0-Cookbook   File: OAuth2AuthorizationServerConfiguration.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    JwtAccessTokenConverter conv = new JwtAccessTokenConverter();
    conv.setSigningKey("non-prod-signature");
    return conv;
}
 
Example 24
Project: OAuth-2.0-Cookbook   File: OAuth2ResourceServer.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter jwtTokenConverter() {
    JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey(getSignKey());
    return converter;
}
 
Example 25
Project: OAuth-2.0-Cookbook   File: OAuth2AuthorizationServer.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    JwtAccessTokenConverter tokenConverter = new JwtAccessTokenConverter();
    tokenConverter.setSigningKey(symmetricKey());
    return tokenConverter;
}
 
Example 26
Project: konker-platform   File: OAuth2Config.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	converter.setSigningKey("apikonkeroauth");
	return converter;
}
 
Example 27
Project: spring-security-oauth   File: OAuth2AuthorizationServerConfig2.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("123");
    return converter;
}
 
Example 28
Project: spring-security-oauth   File: OAuth2AuthorizationServerConfig3.java   View Source Code Vote up 4 votes
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setSigningKey("123");
    return converter;
}
 
Example 29
Project: OMIPlatform   File: JwtSecurityConfig.java   View Source Code Vote up 3 votes
@Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter(){

        JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
//      秘钥,验证Token
        accessTokenConverter.setSigningKey("TZ_GZU_XHJT_007_SIGNING_KEY");

        return accessTokenConverter;

    }