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

The following examples show how to use org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter#setAccessTokenConverter() . 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: OAuth2ResourceServerConfigJwt.java    From spring-security-oauth with MIT License 6 votes vote down vote up
@Bean
public JwtAccessTokenConverter accessTokenConverter() {
    final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
    converter.setAccessTokenConverter(customAccessTokenConverter);

    converter.setSigningKey("123");
    // 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 2
Source File: OAuth2ResourceServerConfig.java    From spring-boot-demo with MIT License 5 votes vote down vote up
@Bean
public JwtAccessTokenConverter accessTokenConverter(){
  JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
  Resource resource =  new ClassPathResource("public.txt");
  String publicKey;
  try {
    publicKey = inputStream2String(resource.getInputStream());
  } catch (final IOException e) {
    throw new RuntimeException(e);
  }
  converter.setVerifierKey(publicKey);
  converter.setAccessTokenConverter(new CustomerAccessTokenConverter());
  return converter;
}
 
Example 3
Source File: AuthorizationServerConfiguration.java    From spring-boot-demo with MIT License 5 votes vote down vote up
@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: JwtTokenConfigration.java    From Taroco with Apache License 2.0 5 votes vote down vote up
/**
 * 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 5
Source File: SecurityConfig.java    From codenjoy with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public TokenStore tokenStore() {
    JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
    DefaultAccessTokenConverter tokenConverter = new DefaultAccessTokenConverter();
    tokenConverter.setUserTokenConverter(oAuth2UserAuthenticationConverter);
    accessTokenConverter.setAccessTokenConverter(tokenConverter);

    return new JwkTokenStore(clientProperties.getProvider().get("dojo").getJwkSetUri(),
            accessTokenConverter);
}
 
Example 6
Source File: CustomAccessTokenConverter.java    From microservices-oauth with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(JwtAccessTokenConverter converter) {
	converter.setAccessTokenConverter(this);
}
 
Example 7
Source File: JwtAccessTokenCustomizer.java    From spring-oauth2-keycloak-connector with Apache License 2.0 4 votes vote down vote up
@Override
public void configure(JwtAccessTokenConverter converter) {
  converter.setAccessTokenConverter(this);
  LOG.info("Configured {}", JwtAccessTokenConverter.class.getSimpleName());
}
 
Example 8
Source File: CustomAccessTokenConverter.java    From spring-boot-2-oauth2-resource-jwt with MIT License 4 votes vote down vote up
@Override
public void configure(JwtAccessTokenConverter converter) {
	converter.setAccessTokenConverter(this);
}
 
Example 9
Source File: AuthorizationServerTokenServicesConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 4 votes vote down vote up
@Bean
JwtAccessTokenConverter accessTokenConverter() {
	JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
	converter.setAccessTokenConverter(new CustomAccessTokenConverter());
	return converter;
}