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 and Description
    `DefaultKeycloakContext(KeycloakSession session)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AuthenticationSessionModel` | `getAuthenticationSession()` Get current AuthenticationSessionModel, can be null out of the AuthenticationSession context.
    `URI` | `getAuthServerUrl()`
    `ClientModel` | `getClient()`
    `ClientConnection` | `getConnection()`
    `<T> T` | `getContextObject(Class<T> clazz)`
    `String` | `getContextPath()`
    `RealmModel` | `getRealm()`
    `javax.ws.rs.core.HttpHeaders` | `getRequestHeaders()`
    `KeycloakUriInfo` | `getUri()` Returns the URI assuming it is a frontend request.
    `KeycloakUriInfo` | `getUri(UrlType type)` Returns the URI.
    `Locale` | `resolveLocale(UserModel user)`
    `void` | `setAuthenticationSession(AuthenticationSessionModel authenticationSession)`
    `void` | `setClient(ClientModel client)`
    `void` | `setRealm(RealmModel realm)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultKeycloakContext

          public DefaultKeycloakContext(KeycloakSession session)

  - ### Method Detail

    - #### getAuthServerUrl

          public URI getAuthServerUrl()

      Specified by:
        `getAuthServerUrl` in interface `KeycloakContext`

    - #### getContextPath

          public String getContextPath()

      Specified by:
        `getContextPath` in interface `KeycloakContext`

    - #### getUri

          public KeycloakUriInfo getUri(UrlType type)

      Description copied from interface: `KeycloakContext`
      Returns 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:
        `getUri` in interface `KeycloakContext`
      Parameters:
        `type` - the type of the request
      Returns:

    - #### getUri

          public KeycloakUriInfo getUri()

      Description copied from interface: `KeycloakContext`
      Returns the URI assuming it is a frontend request. To resolve URI for a backend request use `KeycloakContext.getUri(UrlType)`
      Specified by:
        `getUri` in interface `KeycloakContext`
      Returns:

    - #### getRequestHeaders

          public javax.ws.rs.core.HttpHeaders getRequestHeaders()

      Specified by:
        `getRequestHeaders` in interface `KeycloakContext`

    - #### getContextObject

          public <T> T getContextObject(Class<T> clazz)

      Specified by:
        `getContextObject` in interface `KeycloakContext`

    - #### getRealm

          public RealmModel getRealm()

      Specified by:
        `getRealm` in interface `KeycloakContext`

    - #### setRealm

          public void setRealm(RealmModel realm)

      Specified by:
        `setRealm` in interface `KeycloakContext`

    - #### getClient

          public ClientModel getClient()

      Specified by:
        `getClient` in interface `KeycloakContext`

    - #### setClient

          public void setClient(ClientModel client)

      Specified by:
        `setClient` in interface `KeycloakContext`

    - #### getConnection

          public ClientConnection getConnection()

      Specified by:
        `getConnection` in interface `KeycloakContext`

    - #### resolveLocale

          public Locale resolveLocale(UserModel user)

      Specified by:
        `resolveLocale` in interface `KeycloakContext`

    - #### getAuthenticationSession

          public AuthenticationSessionModel getAuthenticationSession()

      Description copied from interface: `KeycloakContext`
      Get current AuthenticationSessionModel, can be null out of the AuthenticationSession context.
      Specified by:
        `getAuthenticationSession` in interface `KeycloakContext`
      Returns:
        current AuthenticationSessionModel or null

    - #### setAuthenticationSession

          public void setAuthenticationSession(AuthenticationSessionModel authenticationSession)

      Specified by:
        `setAuthenticationSession` in interface `KeycloakContext`

Copyright © 2021 JBoss by Red Hat. All rights reserved.