Class MessageContext
- java.lang.Object
- 
- com.thetransactioncompany.jsonrpc2.server.MessageContext
 
- 
 public class MessageContext extends Object Context information about JSON-RPC 2.0 request and notification messages. This class is immutable.- The client's hostname.
- The client's IP address.
- Whether the request / notification was transmitted securely (e.g. via HTTPS).
- The client principal(s) (user), if authenticated.
 - Author:
- Vladimir Dzhuvinov
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description classMessageContext.BasicPrincipalMinimal implementation of thePrincipalinterface.
 - 
Constructor SummaryConstructors Constructor Description MessageContext()Creates a new JSON-RPC 2.0 request / notification context.MessageContext(String clientHostName, String clientInetAddress)Creates a new JSON-RPC 2.0 request / notification context.MessageContext(String clientHostName, String clientInetAddress, boolean secure)Creates a new JSON-RPC 2.0 request / notification context.MessageContext(String clientHostName, String clientInetAddress, boolean secure, String principalName)Creates a new JSON-RPC 2.0 request / notification context.MessageContext(String clientHostName, String clientInetAddress, boolean secure, String[] principalNames)Creates a new JSON-RPC 2.0 request / notification context.MessageContext(URLConnection connection)Creates a new JSON-RPC 2.0 request / notification context from the specified URL connection.MessageContext(HttpServletRequest httpRequest)Creates a new JSON-RPC 2.0 request / notification context from the specified HTTP request.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetClientHostName()Gets the hostname of the client that sent the request / notification.StringgetClientInetAddress()Gets the IP address of the client that sent the request / notification.PrincipalgetPrincipal()Returns the first authenticated client principal,nullif none.StringgetPrincipalName()Returns the first authenticated client principal name,nullif none.String[]getPrincipalNames()Returns the authenticated client principal names,nullif none.Principal[]getPrincipals()Returns the authenticated client principals,nullif none.booleanisSecure()Indicates whether the request / notification was received over a secure HTTPS connection.StringtoString()
 
- 
- 
- 
Constructor Detail- 
MessageContextpublic MessageContext(String clientHostName, String clientInetAddress, boolean secure, String principalName) Creates a new JSON-RPC 2.0 request / notification context.- Parameters:
- clientHostName- The client hostname,- nullif unknown.
- clientInetAddress- The client IP address,- nullif unknown.
- secure- Specifies a request received over HTTPS.
- principalName- Specifies the authenticated client principle name,- nullif unknown. The name must not be an empty or blank string.
 
 - 
MessageContextpublic MessageContext(String clientHostName, String clientInetAddress, boolean secure, String[] principalNames) Creates a new JSON-RPC 2.0 request / notification context.- Parameters:
- clientHostName- The client hostname,- nullif unknown.
- clientInetAddress- The client IP address,- nullif unknown.
- secure- Specifies a request received over HTTPS.
- principalNames- Specifies the authenticated client principle names,- nullif unknown. The names must not be an empty or blank string.
 
 - 
MessageContextpublic MessageContext(String clientHostName, String clientInetAddress, boolean secure) Creates a new JSON-RPC 2.0 request / notification context. No authenticated client principal is specified.- Parameters:
- clientHostName- The client hostname,- nullif unknown.
- clientInetAddress- The client IP address,- nullif unknown.
- secure- Specifies a request received over HTTPS.
 
 - 
MessageContextpublic MessageContext(String clientHostName, String clientInetAddress) Creates a new JSON-RPC 2.0 request / notification context. Indicates an insecure transport (plain HTTP) and no authenticated client principal.- Parameters:
- clientHostName- The client hostname,- nullif unknown.
- clientInetAddress- The client IP address,- nullif unknown.
 
 - 
MessageContextpublic MessageContext() Creates a new JSON-RPC 2.0 request / notification context. Indicates an insecure transport (plain HTTP) and no authenticated client principal. Not client hostname / IP is specified.
 - 
MessageContextpublic MessageContext(HttpServletRequest httpRequest) Creates a new JSON-RPC 2.0 request / notification context from the specified HTTP request.- Parameters:
- httpRequest- The HTTP request.
 
 - 
MessageContextpublic MessageContext(URLConnection connection) Creates a new JSON-RPC 2.0 request / notification context from the specified URL connection. Use this constructor in cases when the HTTP server is the origin of the JSON-RPC 2.0 requests / notifications. If the IP address of the HTTP server cannot be resolvedgetClientInetAddress()will returnnull.- Parameters:
- connection- The URL connection, must be established and not- null.
 
 
- 
 - 
Method Detail- 
getClientHostNamepublic String getClientHostName() Gets the hostname of the client that sent the request / notification.- Returns:
- The client hostname, nullif unknown.
 
 - 
getClientInetAddresspublic String getClientInetAddress() Gets the IP address of the client that sent the request / notification.- Returns:
- The client IP address, nullif unknown.
 
 - 
isSecurepublic boolean isSecure() Indicates whether the request / notification was received over a secure HTTPS connection.- Returns:
- trueIf the request was received over HTTPS,- falseif it was received over plain HTTP.
 
 - 
getPrincipalpublic Principal getPrincipal() Returns the first authenticated client principal,nullif none.- Returns:
- The first client principal, nullif none.
 
 - 
getPrincipalspublic Principal[] getPrincipals() Returns the authenticated client principals,nullif none.- Returns:
- The client principals, nullif none.
 
 - 
getPrincipalNamepublic String getPrincipalName() Returns the first authenticated client principal name,nullif none.- Returns:
- The first client principal name, nullif none.
 
 - 
getPrincipalNamespublic String[] getPrincipalNames() Returns the authenticated client principal names,nullif none.- Returns:
- The client principal names, nullif none.
 
 
- 
 
-