org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory Java Examples
The following examples show how to use
org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory.
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: ResourceServerTokenServicesConfiguration.java From spring-security-oauth2-boot with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(JwtAccessTokenConverter.class) public JwtAccessTokenConverter accessTokenConverter() { Assert.notNull(this.resource.getJwt().getKeyStore(), "keyStore cannot be null"); Assert.notNull(this.resource.getJwt().getKeyStorePassword(), "keyStorePassword cannot be null"); Assert.notNull(this.resource.getJwt().getKeyAlias(), "keyAlias cannot be null"); JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); Resource keyStore = this.context.getResource(this.resource.getJwt().getKeyStore()); char[] keyStorePassword = this.resource.getJwt().getKeyStorePassword().toCharArray(); KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(keyStore, keyStorePassword); String keyAlias = this.resource.getJwt().getKeyAlias(); char[] keyPassword = Optional.ofNullable(this.resource.getJwt().getKeyPassword()).map(String::toCharArray) .orElse(keyStorePassword); converter.setKeyPair(keyStoreKeyFactory.getKeyPair(keyAlias, keyPassword)); return converter; }
Example #2
Source File: AuthorizationServerTokenServicesConfiguration.java From spring-security-oauth2-boot with Apache License 2.0 | 6 votes |
@Bean @ConditionalOnMissingBean(JwtAccessTokenConverter.class) public JwtAccessTokenConverter accessTokenConverter() { Assert.notNull(this.authorization.getJwt().getKeyStore(), "keyStore cannot be null"); Assert.notNull(this.authorization.getJwt().getKeyStorePassword(), "keyStorePassword cannot be null"); Assert.notNull(this.authorization.getJwt().getKeyAlias(), "keyAlias cannot be null"); JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); Resource keyStore = this.context.getResource(this.authorization.getJwt().getKeyStore()); char[] keyStorePassword = this.authorization.getJwt().getKeyStorePassword().toCharArray(); KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(keyStore, keyStorePassword); String keyAlias = this.authorization.getJwt().getKeyAlias(); char[] keyPassword = Optional.ofNullable(this.authorization.getJwt().getKeyPassword()) .map(String::toCharArray).orElse(keyStorePassword); converter.setKeyPair(keyStoreKeyFactory.getKeyPair(keyAlias, keyPassword)); return converter; }
Example #3
Source File: AuthorizationServerConfiguration.java From spring-boot-demo with MIT License | 5 votes |
@Bean public JwtAccessTokenConverter accessTokenConverter() { final JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); // converter.setSigningKey("123"); KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("mytest.jks"), "mypass".toCharArray()); converter.setKeyPair(keyStoreKeyFactory.getKeyPair("mytest")); converter.setAccessTokenConverter(new CustomerAccessTokenConverter()); return converter; }
Example #4
Source File: UaaConfiguration.java From tutorials with MIT License | 5 votes |
/** * This bean generates an token enhancer, which manages the exchange between JWT acces tokens and Authentication * in both directions. * * @return an access token converter configured with the authorization server's public/private keys */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( new ClassPathResource(uaaProperties.getKeyStore().getName()), uaaProperties.getKeyStore().getPassword().toCharArray()) .getKeyPair(uaaProperties.getKeyStore().getAlias()); converter.setKeyPair(keyPair); return converter; }
Example #5
Source File: AuthServerConfigurer.java From tutorials with MIT License | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory( keystore, keystorePassword.toCharArray()); KeyPair keyPair = keyStoreKeyFactory.getKeyPair( keyAlias, keyPassword.toCharArray()); JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); converter.setKeyPair(keyPair); return converter; }
Example #6
Source File: OAuth2Configuration.java From spring-boot-oauth2-jwt with MIT License | 5 votes |
@Bean protected JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new CustomTokenEnhancer(); converter.setKeyPair( new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"), "password".toCharArray()).getKeyPair("jwt")); return converter; }
Example #7
Source File: AuthserverApplication.java From micro-ecommerce with Apache License 2.0 | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory(new ClassPathResource("keystore.jks"), "foobar".toCharArray()) .getKeyPair("test"); converter.setKeyPair(keyPair); return converter; }
Example #8
Source File: OAuth2AuthorizationServerConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( new ClassPathResource("keys/jwtConverterStore.jks"), keyStorePass.toCharArray() ).getKeyPair(keyPairAlias); converter.setKeyPair(keyPair); return converter; }
Example #9
Source File: OAuth2AuthorizationServerConfig.java From Spring-Security-Third-Edition with MIT License | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( new ClassPathResource(keystore), keyStorePass.toCharArray() ).getKeyPair(keyPairAlias); converter.setKeyPair(keyPair); return converter; }
Example #10
Source File: AuthorizationSeverConfig.java From springboot-vue.js-bbs with Apache License 2.0 | 5 votes |
@Bean public JwtAccessTokenConverter accessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyStoreKeyFactory keyFactory = new KeyStoreKeyFactory(new ClassPathResource("private.jks"), "storepass".toCharArray()); converter.setKeyPair(keyFactory.getKeyPair("jwtserver", "keypass".toCharArray())); converter.setVerifierKey(publicKey); return converter; }
Example #11
Source File: OAuthServerConfiguration.java From microservices-basics-spring-boot with Apache License 2.0 | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); //Keypair is the alias name -> anilkeystore.jks / password / anila KeyPair keyPair = new KeyStoreKeyFactory(new ClassPathResource("anilkeystore.jks"), "password".toCharArray()) .getKeyPair("anila"); converter.setKeyPair(keyPair); return converter; }
Example #12
Source File: JwtServerConfiguration.java From java-microservice with MIT License | 5 votes |
@Bean protected JwtAccessTokenConverter jwtTokenEnhancer() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory( new ClassPathResource("jwt.jks"), ENC_PASSWORD.toCharArray() ); JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); converter.setKeyPair(keyStoreKeyFactory.getKeyPair("jwt")); return converter; }
Example #13
Source File: AuthorizationConfig.java From Using-Spring-Oauth2-to-secure-REST with MIT License | 5 votes |
@Bean public JwtAccessTokenConverter accessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory( new ClassPathResource("mykeys.jks"), "mypass".toCharArray()); converter.setKeyPair(keyStoreKeyFactory.getKeyPair("mykeys")); return converter; }
Example #14
Source File: OAuth2Config.java From spring-auth-example with MIT License | 5 votes |
@Bean protected JwtAccessTokenConverter jwtTokenEnhancer() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory( new ClassPathResource("jwt.jks"), "mySecretKey".toCharArray()); JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); converter.setKeyPair(keyStoreKeyFactory.getKeyPair("jwt")); return converter; }
Example #15
Source File: JWTOauth2Test.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( new ClassPathResource("keystore.jks"), "password".toCharArray()) .getKeyPair("selfsigned"); converter.setKeyPair(keyPair); return converter; }
Example #16
Source File: OAuth2Config.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
/** * This bean generates an token enhancer, which manages the exchange between JWT acces tokens and Authentication * in both direction. * * @return an access token converter configured with the authorization server's public/private keys */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( new ClassPathResource("keystore.jks"), "password".toCharArray()) .getKeyPair("selfsigned"); converter.setKeyPair(keyPair); return converter; }
Example #17
Source File: OAuth2Configuration.java From spring-boot-2-oauth2-authorization-jwt with MIT License | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new CustomTokenEnhancer(); converter.setKeyPair( new KeyStoreKeyFactory(new ClassPathResource("jwt.jks"), "password".toCharArray()).getKeyPair("jwt")); return converter; }
Example #18
Source File: JwtTokenConfigration.java From Taroco with Apache License 2.0 | 5 votes |
/** * JWT Token 生成转换器(加密方式以及加密的Token中存放哪些信息) * * @return */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { final JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory (oauth2Properties.getKeyStore().getLocation(), oauth2Properties.getKeyStore().getSecret().toCharArray()) .getKeyPair(oauth2Properties.getKeyStore().getAlias()); converter.setKeyPair(keyPair); converter.setAccessTokenConverter(new CustomerAccessTokenConverter()); return converter; }
Example #19
Source File: OauthAuthorizationServerConfig.java From codeway_service with GNU General Public License v3.0 | 5 votes |
/** * 配置AccessToken加密方式 */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter(CustomUserAuthenticationConverter customUserAuthenticationConverter) { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( keyProperties.getKeyStore().getLocation(), keyProperties.getKeyStore().getSecret().toCharArray()).getKeyPair( keyProperties.getKeyStore().getAlias(), keyProperties.getKeyStore().getPassword().toCharArray()); converter.setKeyPair(keyPair); //配置自定义的CustomUserAuthenticationConverter DefaultAccessTokenConverter accessTokenConverter = (DefaultAccessTokenConverter) converter.getAccessTokenConverter(); accessTokenConverter.setUserTokenConverter(customUserAuthenticationConverter); return converter; }
Example #20
Source File: UaaConfiguration.java From cubeai with Apache License 2.0 | 5 votes |
/** * This bean generates an token enhancer, which manages the exchange between JWT acces tokens and Authentication * in both directions. * * @return an access token converter configured with the authorization server's public/private keys */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( new ClassPathResource(uaaProperties.getKeyStore().getName()), uaaProperties.getKeyStore().getPassword().toCharArray()) .getKeyPair(uaaProperties.getKeyStore().getAlias()); converter.setKeyPair(keyPair); return converter; }
Example #21
Source File: Oauth2AuthorizationServerConfig.java From spring-security-oauth2-demo with GNU General Public License v3.0 | 5 votes |
/** * 令牌转换器,(非)对称密钥加密 * * @return JwtAccessTokenConverter */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); // 对称密钥加密 // converter.setSigningKey("oauth2"); // 非对称密钥加密 KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory( new ClassPathResource("oauth2.jks"), "123456".toCharArray()); converter.setKeyPair(keyStoreKeyFactory.getKeyPair("oauth2")); return converter; }
Example #22
Source File: AuthJwtTokenStore.java From microservices-platform with Apache License 2.0 | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { final JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory (keyProperties.getKeyStore().getLocation(), keyProperties.getKeyStore().getSecret().toCharArray()) .getKeyPair(keyProperties.getKeyStore().getAlias()); converter.setKeyPair(keyPair); DefaultAccessTokenConverter tokenConverter = (DefaultAccessTokenConverter)converter.getAccessTokenConverter(); tokenConverter.setUserTokenConverter(new CustomUserAuthenticationConverter()); return converter; }
Example #23
Source File: OauthAuthorizationServerConfig.java From codeway_service with GNU General Public License v3.0 | 5 votes |
/** * 配置AccessToken加密方式 */ @Bean public JwtAccessTokenConverter jwtAccessTokenConverter(CustomUserAuthenticationConverter customUserAuthenticationConverter) { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); KeyPair keyPair = new KeyStoreKeyFactory( keyProperties.getKeyStore().getLocation(), keyProperties.getKeyStore().getSecret().toCharArray()).getKeyPair( keyProperties.getKeyStore().getAlias(), keyProperties.getKeyStore().getPassword().toCharArray()); converter.setKeyPair(keyPair); //配置自定义的CustomUserAuthenticationConverter DefaultAccessTokenConverter accessTokenConverter = (DefaultAccessTokenConverter) converter.getAccessTokenConverter(); accessTokenConverter.setUserTokenConverter(customUserAuthenticationConverter); return converter; }
Example #24
Source File: AuthorizationServerConfig.java From syhthems-platform with MIT License | 4 votes |
@Bean public KeyPair keyPair() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("syhthems.jks"), "syhthems-sunriseydy".toCharArray()); return keyStoreKeyFactory.getKeyPair("syhthems"); }
Example #25
Source File: JwkAuthorizationServerConfiguration.java From spring-security-oauth with MIT License | 4 votes |
@Bean public KeyPair keyPair() { ClassPathResource ksFile = new ClassPathResource(KEY_STORE_FILE); KeyStoreKeyFactory ksFactory = new KeyStoreKeyFactory(ksFile, KEY_STORE_PASSWORD.toCharArray()); return ksFactory.getKeyPair(KEY_ALIAS); }
Example #26
Source File: CustomAuthorizationServerConfigurer.java From spring-microservice-exam with MIT License | 4 votes |
/** * 生成KeyPair * @return KeyPair */ @Bean public KeyPair keyPair() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(keyProperties.getKeyStore().getLocation(), keyProperties.getKeyStore().getPassword().toCharArray()); return keyStoreKeyFactory.getKeyPair(keyProperties.getKeyStore().getAlias()); }
Example #27
Source File: SecurityConfig.java From platform with Apache License 2.0 | 4 votes |
@Bean public KeyPair keyPair() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("jwt/jwt.jks"), "jwttest".toCharArray()); return keyStoreKeyFactory.getKeyPair("jwttest"); }
Example #28
Source File: Oauth2AuthorizationTokenConfig.java From spring-boot-demo with MIT License | 2 votes |
/** * 密钥 keyPair. * 可用于生成 jwt / jwk. * * @return keyPair */ @Bean public KeyPair keyPair() { KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(new ClassPathResource("oauth2.jks"), "123456".toCharArray()); return keyStoreKeyFactory.getKeyPair("oauth2"); }