org.springframework.security.oauth2.client.http.OAuth2ErrorResponseErrorHandler Java Examples

The following examples show how to use org.springframework.security.oauth2.client.http.OAuth2ErrorResponseErrorHandler. 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: UaaConfiguration.java    From jhipster-registry with Apache License 2.0 6 votes vote down vote up
@Bean
@LoadBalanced
public RestTemplate uaaRestTemplate() {
    ClientRegistration clientRegistration = clientRegistrationRepository.findByRegistrationId(CLIENT_REGISTRATION_ID);
    if (null == clientRegistration) {
        throw new IllegalArgumentException("Invalid Client Registration with Id: " + CLIENT_REGISTRATION_ID);
    }

    return restTemplateBuilder
        .messageConverters(
            new FormHttpMessageConverter(),
            new OAuth2AccessTokenResponseHttpMessageConverter())
        .errorHandler(new OAuth2ErrorResponseErrorHandler())
        .basicAuthentication(clientRegistration.getClientId(), clientRegistration.getClientSecret())
        .build();
}
 
Example #2
Source File: SecurityConfig.java    From messaging-app with Apache License 2.0 5 votes vote down vote up
private OAuth2AccessTokenResponseClient<OAuth2AuthorizationCodeGrantRequest> authorizationCodeTokenResponseClient() {
	OAuth2AccessTokenResponseHttpMessageConverter tokenResponseHttpMessageConverter =
			new OAuth2AccessTokenResponseHttpMessageConverter();
	tokenResponseHttpMessageConverter.setTokenResponseConverter(new CustomAccessTokenResponseConverter());

	RestTemplate restTemplate = new RestTemplate(Arrays.asList(
			new FormHttpMessageConverter(), tokenResponseHttpMessageConverter));
	restTemplate.setErrorHandler(new OAuth2ErrorResponseErrorHandler());

	DefaultAuthorizationCodeTokenResponseClient tokenResponseClient = new DefaultAuthorizationCodeTokenResponseClient();
	tokenResponseClient.setRestOperations(restTemplate);

	return tokenResponseClient;
}
 
Example #3
Source File: CredHubRestTemplateFactory.java    From spring-credhub with Apache License 2.0 5 votes vote down vote up
private static RestTemplate createTokenServerRestTemplate(ClientHttpRequestFactory clientHttpRequestFactory) {
	RestTemplate restOperations = new RestTemplate(
			Arrays.asList(new FormHttpMessageConverter(), new OAuth2AccessTokenResponseHttpMessageConverter()));
	restOperations.setErrorHandler(new OAuth2ErrorResponseErrorHandler());
	restOperations.setRequestFactory(clientHttpRequestFactory);
	return restOperations;
}
 
Example #4
Source File: AuthorizationHeaderUtil.java    From jhipster-registry with Apache License 2.0 5 votes vote down vote up
private RestTemplate restTemplate(String clientId, String clientSecret) {
    return restTemplateBuilder
        .additionalMessageConverters(
            new FormHttpMessageConverter(),
            new OAuth2AccessTokenResponseHttpMessageConverter())
        .errorHandler(new OAuth2ErrorResponseErrorHandler())
        .basicAuthentication(clientId, clientSecret)
        .build();
}
 
Example #5
Source File: DefaultJwtBearerTokenResponseClient.java    From oauth2-protocol-patterns with Apache License 2.0 4 votes vote down vote up
public DefaultJwtBearerTokenResponseClient() {
	RestTemplate restTemplate = new RestTemplate(Arrays.asList(
			new FormHttpMessageConverter(), new OAuth2AccessTokenResponseHttpMessageConverter()));
	restTemplate.setErrorHandler(new OAuth2ErrorResponseErrorHandler());
	this.restOperations = restTemplate;
}