Package org.forgerock.services.context
Class ClientContext
java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.services.context.ClientContext
- All Implemented Interfaces:
- Context
Client context gives easy access to client-related information that are available into the request.
 Supported data includes:
 
- Remote IP address
- Remote port
- Username
- Client provided certificates
- User-Agent information
- Whether the client is external
- Whether the connection to the client is secure
- Local port
- Local address
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classBuilder for creatingClientContextinstances.
- 
Field SummaryFields inherited from class org.forgerock.services.context.AbstractContextdata
- 
Constructor SummaryConstructorsConstructorDescriptionClientContext(JsonValue savedContext, ClassLoader classLoader) Restore from JSON representation.
- 
Method SummaryModifier and TypeMethodDescriptionstatic ClientContext.BuilderbuildExternalClientContext(Context parent) Creates aClientContext.Builderfor creating an externalClientContextinstance.Collection<? extends Certificate>Returns the collection (possibly empty) of certificate(s) provided by the client.Returns the IP address of the interface that received the request.intReturns the port of the interface that received the request.Returns the IP address of the client (or last proxy) that sent the request or an empty string if the client is internal.intReturns the source port of the client (or last proxy) that sent the request or-1if the client is internal.Returns the login of the user making this request or an empty string if not known.Returns the value of the User-Agent HTTP Header (if any, returns an empty string otherwise).booleanReturnstrueif this client is external.booleanisSecure()Returnstrueif this client connection is secure.static ClientContextnewInternalClientContext(Context parent) Creates an internalClientContextinstance.Methods inherited from class org.forgerock.services.context.AbstractContextas, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
- 
Constructor Details- 
ClientContextRestore from JSON representation.- Parameters:
- savedContext- The JSON representation from which this context's attributes should be parsed.
- classLoader- The ClassLoader which can properly resolve the persisted class-name.
 
 
- 
- 
Method Details- 
buildExternalClientContextCreates aClientContext.Builderfor creating an externalClientContextinstance.- Parameters:
- parent- The parent context.
- Returns:
- A builder for an external ClientContextinstance.
 
- 
newInternalClientContextCreates an internalClientContextinstance. All data related to external context (e.g remote address, user agent...) will be set with empty non null values. The returned internalClientContextis considered as secure.- Parameters:
- parent- The parent context.
- Returns:
- An internal ClientContextinstance.
 
- 
getRemoteUserReturns the login of the user making this request or an empty string if not known.- Returns:
- the login of the user making this request or an empty string if not known.
 
- 
getRemoteAddressReturns the IP address of the client (or last proxy) that sent the request or an empty string if the client is internal.- Returns:
- the IP address of the client (or last proxy) that sent the request or an empty string if the client is internal.
 
- 
getRemotePortpublic int getRemotePort()Returns the source port of the client (or last proxy) that sent the request or-1if the client is internal.- Returns:
- the source port of the client (or last proxy) that sent the request
 or -1if the client is internal.
 
- 
getCertificatesReturns the collection (possibly empty) of certificate(s) provided by the client. If no certificates are available, an empty list is returned.- Returns:
- the collection (possibly empty) of certificate(s) provided by the client.
 
- 
getUserAgentReturns the value of the User-Agent HTTP Header (if any, returns an empty string otherwise).- Returns:
- the value of the User-Agent HTTP Header (if any, returns an empty string otherwise).
 
- 
isExternalpublic boolean isExternal()Returnstrueif this client is external.- Returns:
- trueif this client is external.
 
- 
isSecurepublic boolean isSecure()Returnstrueif this client connection is secure. It is the responsibility to the underlying protocol/implementation to determine whether or not the connection is secure. For example HTTPS and internal connections are meant to be secure.- Returns:
- trueif this client connection is secure.
 
- 
getLocalAddressReturns the IP address of the interface that received the request.- Returns:
- the IP address of the server that received the request.
 
- 
getLocalPortpublic int getLocalPort()Returns the port of the interface that received the request.- Returns:
- the port of the interface that received the request.
 
 
-