Class KeycloakSecurityContextClientRequestInterceptor
java.lang.Object
org.keycloak.adapters.springboot.client.KeycloakSecurityContextClientRequestInterceptor
- All Implemented Interfaces:
org.springframework.http.client.ClientHttpRequestInterceptor
public class KeycloakSecurityContextClientRequestInterceptor
extends Object
implements org.springframework.http.client.ClientHttpRequestInterceptor
Interceptor for
ClientHttpRequestExecution objects created for server to server secured
communication using OAuth2 bearer tokens issued by Keycloak.- Version:
- $Revision: 1 $
- Author:
- James McShane
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected KeycloakSecurityContextorg.springframework.http.client.ClientHttpResponseintercept(org.springframework.http.HttpRequest httpRequest, byte[] bytes, org.springframework.http.client.ClientHttpRequestExecution clientHttpRequestExecution)
-
Constructor Details
-
KeycloakSecurityContextClientRequestInterceptor
public KeycloakSecurityContextClientRequestInterceptor()
-
-
Method Details
-
getKeycloakSecurityContext
Returns theKeycloakSecurityContextfrom the SpringServletRequestAttributes'sPrincipal. The principal must support retrieval of the KeycloakSecurityContext, so at this point, onlyKeycloakPrincipalvalues are supported- Returns:
- the current
KeycloakSecurityContext
-
intercept
public org.springframework.http.client.ClientHttpResponse intercept(org.springframework.http.HttpRequest httpRequest, byte[] bytes, org.springframework.http.client.ClientHttpRequestExecution clientHttpRequestExecution) throws IOException - Specified by:
interceptin interfaceorg.springframework.http.client.ClientHttpRequestInterceptor- Throws:
IOException
-