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 TypeMethodDescriptionReturns the client device type.Returns the preferred EBX® built-in locale according to the current request.Returns all EBX® built-in locales.Returns a configured procedure utility instance.Returns the current EBX® repository.Returns the EBX® session for the current authenticated user.Returns the EBX® session for the current authenticated user ornull
if the user is not authenticated.Returns a configured URI information utility instance.boolean
Returnstrue
if and only if the current user is authenticated.boolean
isSecure()
Returnstrue
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 isdesktop
.
-
getLocale
Locale getLocale()Returns the preferred EBX® built-in locale according to the current request. The current request locales are extracted fromHttpHeaders.getAcceptableLanguages()
.- Returns:
- the locale. Is never
null
and is always a locale fromgetLocales()
method.
-
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
Returns the EBX® session for the current authenticated user.- Throws:
NotAuthorizedException
- if the user is not authenticated (this may happen only ifAnonymousAccessEnabled
has been set).
-
getSessionOrNull
Session getSessionOrNull()Returns the EBX® session for the current authenticated user ornull
if the user is not authenticated. May returnfalse
only if the annotationAnonymousAccessEnabled
has been set.- Returns:
- the authenticated
Session
ornull
if the user is not authenticated.
-
getURIInfoUtility
URIInfoUtility getURIInfoUtility()Returns a configured URI information utility instance. -
isAuthenticated
boolean isAuthenticated()Returnstrue
if and only if the current user is authenticated. May returnfalse
only if the annotationAnonymousAccessEnabled
has been set. -
isSecure
boolean isSecure()Returnstrue
if the request was made using a secure channel (such as HTTPS),false
otherwise.
-