Package org.keycloak.services
Class DefaultKeycloakContext
- java.lang.Object
-
- org.keycloak.services.DefaultKeycloakContext
-
- All Implemented Interfaces:
KeycloakContext
public class DefaultKeycloakContext extends Object implements KeycloakContext
- Author:
- Stian Thorgersen
-
-
Constructor Summary
Constructors Constructor Description DefaultKeycloakContext(KeycloakSession session)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected HttpRequestcreateHttpRequest()protected HttpResponsecreateHttpResponse()AuthenticationSessionModelgetAuthenticationSession()Get current AuthenticationSessionModel, can be null out of the AuthenticationSession context.URIgetAuthServerUrl()ClientModelgetClient()ClientConnectiongetConnection()<T> TgetContextObject(Class<T> clazz)StringgetContextPath()HttpRequestgetHttpRequest()HttpResponsegetHttpResponse()RealmModelgetRealm()javax.ws.rs.core.HttpHeadersgetRequestHeaders()Deprecated.UsegetHttpRequest()to obtain the request headers.KeycloakUriInfogetUri()Returns the URI assuming it is a frontend request.KeycloakUriInfogetUri(UrlType type)Returns the URI.LocaleresolveLocale(UserModel user)voidsetAuthenticationSession(AuthenticationSessionModel authenticationSession)voidsetClient(ClientModel client)voidsetRealm(RealmModel realm)
-
-
-
Constructor Detail
-
DefaultKeycloakContext
public DefaultKeycloakContext(KeycloakSession session)
-
-
Method Detail
-
getAuthServerUrl
public URI getAuthServerUrl()
- Specified by:
getAuthServerUrlin interfaceKeycloakContext
-
getContextPath
public String getContextPath()
- Specified by:
getContextPathin interfaceKeycloakContext
-
getUri
public KeycloakUriInfo getUri(UrlType type)
Description copied from interface:KeycloakContextReturns the URI. If a frontend request (from user-agent) @frontendRequest should be set to true. If a backend request (request from a client) should be set to false. Depending on the configure hostname provider it may return a hard-coded base URL for frontend request (for example https://auth.mycompany.com) and use the request URL for backend requests. Frontend URI should also be used for realm issuer fields in tokens.- Specified by:
getUriin interfaceKeycloakContext- Parameters:
type- the type of the request- Returns:
-
getUri
public KeycloakUriInfo getUri()
Description copied from interface:KeycloakContextReturns the URI assuming it is a frontend request. To resolve URI for a backend request useKeycloakContext.getUri(UrlType)- Specified by:
getUriin interfaceKeycloakContext- Returns:
-
getRequestHeaders
@Deprecated public javax.ws.rs.core.HttpHeaders getRequestHeaders()
Deprecated.UsegetHttpRequest()to obtain the request headers.- Specified by:
getRequestHeadersin interfaceKeycloakContext- Returns:
-
getContextObject
public <T> T getContextObject(Class<T> clazz)
- Specified by:
getContextObjectin interfaceKeycloakContext
-
getRealm
public RealmModel getRealm()
- Specified by:
getRealmin interfaceKeycloakContext
-
setRealm
public void setRealm(RealmModel realm)
- Specified by:
setRealmin interfaceKeycloakContext
-
getClient
public ClientModel getClient()
- Specified by:
getClientin interfaceKeycloakContext
-
setClient
public void setClient(ClientModel client)
- Specified by:
setClientin interfaceKeycloakContext
-
getConnection
public ClientConnection getConnection()
- Specified by:
getConnectionin interfaceKeycloakContext
-
resolveLocale
public Locale resolveLocale(UserModel user)
- Specified by:
resolveLocalein interfaceKeycloakContext
-
getAuthenticationSession
public AuthenticationSessionModel getAuthenticationSession()
Description copied from interface:KeycloakContextGet current AuthenticationSessionModel, can be null out of the AuthenticationSession context.- Specified by:
getAuthenticationSessionin interfaceKeycloakContext- Returns:
- current AuthenticationSessionModel or null
-
setAuthenticationSession
public void setAuthenticationSession(AuthenticationSessionModel authenticationSession)
- Specified by:
setAuthenticationSessionin interfaceKeycloakContext
-
getHttpRequest
public HttpRequest getHttpRequest()
- Specified by:
getHttpRequestin interfaceKeycloakContext
-
getHttpResponse
public HttpResponse getHttpResponse()
- Specified by:
getHttpResponsein interfaceKeycloakContext
-
createHttpRequest
protected HttpRequest createHttpRequest()
-
createHttpResponse
protected HttpResponse createHttpResponse()
-
-