Class KeycloakRestTemplate
- java.lang.Object
-
- org.springframework.http.client.support.HttpAccessor
-
- org.springframework.http.client.support.InterceptingHttpAccessor
-
- org.springframework.web.client.RestTemplate
-
- org.keycloak.adapters.springsecurity.client.KeycloakRestTemplate
-
- All Implemented Interfaces:
org.springframework.web.client.RestOperations
public class KeycloakRestTemplate extends org.springframework.web.client.RestTemplate implements org.springframework.web.client.RestOperations
Extends Spring's central class for client-side HTTP access,RestTemplate
, adding automatic authentication for service to service calls using the currently authenticated Keycloak principal. This class is designed to work with other services secured by Keycloak.The main advantage to using this class over Spring's
RestTemplate
is that authentication is handled automatically when both the service making the API call and the service being called are protected by Keycloak authentication.- Version:
- $Revision: 1 $
- Author:
- Scott Rossillo
- See Also:
RestOperations
,RestTemplate
-
-
Constructor Summary
Constructors Constructor Description KeycloakRestTemplate(KeycloakClientRequestFactory factory)
Create a new instance based on the givenKeycloakClientRequestFactory
.
-
Method Summary
-
Methods inherited from class org.springframework.web.client.RestTemplate
acceptHeaderRequestCallback, delete, delete, delete, doExecute, exchange, exchange, exchange, exchange, exchange, exchange, exchange, exchange, execute, execute, execute, getErrorHandler, getForEntity, getForEntity, getForEntity, getForObject, getForObject, getForObject, getMessageConverters, getUriTemplateHandler, handleResponse, headersExtractor, headForHeaders, headForHeaders, headForHeaders, httpEntityCallback, httpEntityCallback, optionsForAllow, optionsForAllow, optionsForAllow, patchForObject, patchForObject, patchForObject, postForEntity, postForEntity, postForEntity, postForLocation, postForLocation, postForLocation, postForObject, postForObject, postForObject, put, put, put, responseEntityExtractor, setDefaultUriVariables, setErrorHandler, setMessageConverters, setUriTemplateHandler
-
Methods inherited from class org.springframework.http.client.support.InterceptingHttpAccessor
getInterceptors, getRequestFactory, setInterceptors, setRequestFactory
-
Methods inherited from class org.springframework.http.client.support.HttpAccessor
createRequest, getClientHttpRequestInitializers, setClientHttpRequestInitializers
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.web.client.RestOperations
delete, delete, delete, exchange, exchange, exchange, exchange, exchange, exchange, exchange, exchange, execute, execute, execute, getForEntity, getForEntity, getForEntity, getForObject, getForObject, getForObject, headForHeaders, headForHeaders, headForHeaders, optionsForAllow, optionsForAllow, optionsForAllow, patchForObject, patchForObject, patchForObject, postForEntity, postForEntity, postForEntity, postForLocation, postForLocation, postForLocation, postForObject, postForObject, postForObject, put, put, put
-
-
-
-
Constructor Detail
-
KeycloakRestTemplate
public KeycloakRestTemplate(KeycloakClientRequestFactory factory)
Create a new instance based on the givenKeycloakClientRequestFactory
.- Parameters:
factory
- theKeycloakClientRequestFactory
to use when creating new requests
-
-