Java Code Examples for org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter#getAccessTokenConverter()
The following examples show how to use
org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter#getAccessTokenConverter() .
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 cloud-service with MIT License | 7 votes |
/** * Jwt资源令牌转换器<br> * 参数access_token.store-jwt为true时用到 * * @return accessTokenConverter */ @Bean public JwtAccessTokenConverter accessTokenConverter() { JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter() { @Override public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) { OAuth2AccessToken oAuth2AccessToken = super.enhance(accessToken, authentication); addLoginUserInfo(oAuth2AccessToken, authentication); // 2019.07.13 将当前用户信息追加到登陆后返回数据里 return oAuth2AccessToken; } }; DefaultAccessTokenConverter defaultAccessTokenConverter = (DefaultAccessTokenConverter) jwtAccessTokenConverter .getAccessTokenConverter(); DefaultUserAuthenticationConverter userAuthenticationConverter = new DefaultUserAuthenticationConverter(); userAuthenticationConverter.setUserDetailsService(userDetailsService); defaultAccessTokenConverter.setUserTokenConverter(userAuthenticationConverter); // 2019.06.29 这里务必设置一个,否则多台认证中心的话,一旦使用jwt方式,access_token将解析错误 jwtAccessTokenConverter.setSigningKey(signingKey); return jwtAccessTokenConverter; }
Example 2
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 3
Source File: FebsAuthorizationServerConfigure.java From FEBS-Cloud with Apache License 2.0 | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter(); DefaultAccessTokenConverter defaultAccessTokenConverter = (DefaultAccessTokenConverter) accessTokenConverter.getAccessTokenConverter(); DefaultUserAuthenticationConverter userAuthenticationConverter = new DefaultUserAuthenticationConverter(); userAuthenticationConverter.setUserDetailsService(userDetailService); defaultAccessTokenConverter.setUserTokenConverter(userAuthenticationConverter); accessTokenConverter.setSigningKey(properties.getJwtAccessKey()); return accessTokenConverter; }
Example 4
Source File: ResJwtTokenStore.java From microservices-platform with Apache License 2.0 | 5 votes |
@Bean public JwtAccessTokenConverter jwtAccessTokenConverter() { JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); converter.setVerifierKey(getPubKey()); DefaultAccessTokenConverter tokenConverter = (DefaultAccessTokenConverter)converter.getAccessTokenConverter(); tokenConverter.setUserTokenConverter(new CustomUserAuthenticationConverter()); return converter; }
Example 5
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 6
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 7
Source File: ResourceServerConfiguration.java From spring-cloud-contract-samples with Apache License 2.0 | 5 votes |
/** * <p> * Configures jwt related access token converter to allow enhanced user details to be * converted. * </p> * @param jwtAccessTokenConverter the converter to configure */ @Autowired public void configure(JwtAccessTokenConverter jwtAccessTokenConverter) { notNull(jwtAccessTokenConverter, "jwtAccessTokenConverter"); DefaultAccessTokenConverter defaultAccessTokenConverter = (DefaultAccessTokenConverter) jwtAccessTokenConverter .getAccessTokenConverter(); defaultAccessTokenConverter .setUserTokenConverter(new UserAuthenticationConverter()); }