Package com.orchestranetworks.rest.inject

# Interface SessionContext

public interface SessionContext
This interface provides EBX® information for the current REST request. An instance of this class should be injected using the `Context` annotation as in the following example:

          @Path("/my-service")
          public final class MyService {
          @Context
          private SessionContext sessionContext;

          @GET
          @Path("/data")
          @Consumes(MediaType.APPLICATION_JSON)
          @Produces(MediaType.APPLICATION_JSON)
          @ResourceDescription("My service")
          public Perspective getData() {
              Session session = sessionContext.getSession();
              ...
          }

Since:
  5.9.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getClientDevice()`
  Returns the client device type.
  `Locale`
  `getLocale()`
  Returns the preferred EBX® built-in locale according to the current request.
  `List<Locale>`
  `getLocales()`
  Returns all EBX® built-in locales.
  `ProcedureUtility`
  `getProcedureUtility()`
  Returns a configured procedure utility instance.
  `Repository`
  `getRepository()`
  Returns the current EBX® repository.
  `Session`
  `getSession()`
  Returns the EBX® session for the current authenticated user.
  `Session`
  `getSessionOrNull()`
  Returns the EBX® session for the current authenticated user or `null` if the user is not authenticated.
  `URIInfoUtility`
  `getURIInfoUtility()`
  Returns a configured URI information utility instance.
  `boolean`
  `isAuthenticated()`
  Returns `true` if and only if the current user is authenticated.
  `boolean`
  `isSecure()`
  Returns `true` if the request was made using a secure channel (such as HTTPS), `false` otherwise.

- ## Method Details

  - ### getClientDevice

    String getClientDevice()
    Returns the client device type.

    The device type is either calculated or explicitly set by the client. The device can be set by caller using query parameter `device`. Currently valid values for this parameter are restricted to "desktop" (for any client that is not EBX® GO) and "go" (if client is EBX® GO).

    Returns:
      the device type. Never `null`. Default is `desktop`.

  - ### getLocale

    Locale getLocale()
    Returns the preferred EBX® built-in locale according to the current request. The current request locales are extracted from `HttpHeaders.getAcceptableLanguages()`.
    Returns:
      the locale. Is never `null` and is always a locale from `getLocales()` method.

  - ### getLocales

    List<Locale> getLocales()
    Returns all EBX® built-in locales. First item in the list is the default locale.

    The returned collection is unmodifiable.

  - ### getProcedureUtility

    ProcedureUtility getProcedureUtility()
    Returns a configured procedure utility instance.
    Since:
      6.0.0

  - ### getRepository

    Repository getRepository()
    Returns the current EBX® repository.

  - ### getSession

    Session getSession() throws NotAuthorizedException
    Returns the EBX® session for the current authenticated user.
    Throws:
      `NotAuthorizedException` - if the user is not authenticated (this may happen only if `AnonymousAccessEnabled` has been set).

  - ### getSessionOrNull

    Session getSessionOrNull()
    Returns the EBX® session for the current authenticated user or `null` if the user is not authenticated. May return `false` only if the annotation `AnonymousAccessEnabled` has been set.
    Returns:
      the authenticated `Session` or `null` if the user is not authenticated.

  - ### getURIInfoUtility

    URIInfoUtility getURIInfoUtility()
    Returns a configured URI information utility instance.

  - ### isAuthenticated

    boolean isAuthenticated()
    Returns `true` if and only if the current user is authenticated. May return `false` only if the annotation `AnonymousAccessEnabled` has been set.

  - ### isSecure

    boolean isSecure()
    Returns `true` if the request was made using a secure channel (such as HTTPS), `false` otherwise.