public interface SessionContext
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(); ... }
Modifier and Type | Method and 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.
|
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 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. |
String getClientDevice()
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).
null
. Default is desktop
.Locale getLocale()
HttpHeaders.getAcceptableLanguages()
.null
and is always a locale from
getLocales()
method.List<Locale> getLocales()
The returned collection is unmodifiable.
Repository getRepository()
Session getSession() throws NotAuthorizedException
NotAuthorizedException
- if the user is not authenticated (this may happen only if
AnonymousAccessEnabled
has been set).Session getSessionOrNull()
null
if user is not authenticated. May return false
only if the annotation
AnonymousAccessEnabled
has been set.Session
or null
if the user is not authenticated.URIInfoUtility getURIInfoUtility()
boolean isAuthenticated()
true
if and only if the current user
is authenticated.
May return false
only if the annotation
AnonymousAccessEnabled
has been set.boolean isSecure()
true
if the request was made using a secure
channel (such as HTTPS), false
otherwise.