Search in sources :

Example 1 with KeyStoreKeyFactory

use of org.springframework.security.rsa.crypto.KeyStoreKeyFactory in project new-cloud by xie-summer.

the class OAuth2JWTAuthorizationConfig method jwtAccessTokenConverter.

/**
 * 使用JWT对称加密
 * @return
 */
// @Bean
// public JwtAccessTokenConverter jwtAccessTokenConverter() {
// JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
// jwtAccessTokenConverter.setSigningKey(CommonConstant.SIGN_KEY);
// return jwtAccessTokenConverter;
// }
/**
 * 使用JWT不对称加密  ,认证中加密,资源服务器验签解密
 * @return
 */
@Bean
public JwtAccessTokenConverter jwtAccessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("mytest.jks"), "mypass".toCharArray());
    converter.setKeyPair(keyStoreKeyFactory.getKeyPair("mytest"));
    converter.setAccessTokenConverter(new CustomerAccessTokenConverter());
    return converter;
}
Also used : CustomerAccessTokenConverter(com.framework.auth.config.support.CustomerAccessTokenConverter) JwtAccessTokenConverter(org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter) ClassPathResource(org.springframework.core.io.ClassPathResource) KeyStoreKeyFactory(org.springframework.security.rsa.crypto.KeyStoreKeyFactory) Bean(org.springframework.context.annotation.Bean)

Aggregations

CustomerAccessTokenConverter (com.framework.auth.config.support.CustomerAccessTokenConverter)1 Bean (org.springframework.context.annotation.Bean)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 JwtAccessTokenConverter (org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter)1 KeyStoreKeyFactory (org.springframework.security.rsa.crypto.KeyStoreKeyFactory)1