org.sr.server.http
Class HttpCallerContext

java.lang.Object
  extended by org.sr.server.http.HttpCallerContext
All Implemented Interfaces:
ICallerContextInfo<javax.servlet.http.HttpServletRequest>

public class HttpCallerContext
extends java.lang.Object
implements ICallerContextInfo<javax.servlet.http.HttpServletRequest>

This class is implemented as an adaptor class for http servlet requests.

Author:
Serhat Dirik

Constructor Summary
HttpCallerContext(javax.servlet.http.HttpServletRequest request, HttpClientSession session)
           
 
Method Summary
 java.lang.String getProtocol()
          Returns protocol name
 java.lang.String getRemoteAddr()
          Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
 java.lang.String getRemoteHost()
          Returns the fully qualified name of the client or the last proxy that sent the request.
 int getRemotePort()
          Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
 java.lang.String getRemoteUser()
          Gives authenticated client user information
 IClientSessionInfo<?> getSession()
          Gives client session information if there is any
 javax.servlet.http.HttpServletRequest getWrappedRequest()
          Gives the protocol specific request information
 java.lang.Class<javax.servlet.http.HttpServletRequest> getWrappedType()
          Type information of wrapped session
 boolean isProtocolSecure()
          Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS
 boolean isUserInRole(java.lang.String role)
          Checks if the authenticated client has the given role
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpCallerContext

public HttpCallerContext(javax.servlet.http.HttpServletRequest request,
                         HttpClientSession session)
Method Detail

getRemoteUser

public java.lang.String getRemoteUser()
Description copied from interface: ICallerContextInfo
Gives authenticated client user information

Specified by:
getRemoteUser in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
user name or null there is no authentication

getSession

public IClientSessionInfo<?> getSession()
Description copied from interface: ICallerContextInfo
Gives client session information if there is any

Specified by:
getSession in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
Client Session Information

getWrappedRequest

public javax.servlet.http.HttpServletRequest getWrappedRequest()
Description copied from interface: ICallerContextInfo
Gives the protocol specific request information

Specified by:
getWrappedRequest in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
protocol specific request information

getWrappedType

public java.lang.Class<javax.servlet.http.HttpServletRequest> getWrappedType()
Description copied from interface: ICallerContextInfo
Type information of wrapped session

Specified by:
getWrappedType in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
class of the wrapped session object

isUserInRole

public boolean isUserInRole(java.lang.String role)
Description copied from interface: ICallerContextInfo
Checks if the authenticated client has the given role

Specified by:
isUserInRole in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Parameters:
role - role name
Returns:
true if user belongs to given role

getProtocol

public java.lang.String getProtocol()
Description copied from interface: ICallerContextInfo
Returns protocol name

Specified by:
getProtocol in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
protocol name

getRemoteAddr

public java.lang.String getRemoteAddr()
Description copied from interface: ICallerContextInfo
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.

Specified by:
getRemoteAddr in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
Internet Protocol (IP) address of the client

getRemoteHost

public java.lang.String getRemoteHost()
Description copied from interface: ICallerContextInfo
Returns the fully qualified name of the client or the last proxy that sent the request.

Specified by:
getRemoteHost in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
name of the client

getRemotePort

public int getRemotePort()
Description copied from interface: ICallerContextInfo
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.

Specified by:
getRemotePort in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
Internet Protocol (IP) source port of the client

isProtocolSecure

public boolean isProtocolSecure()
Description copied from interface: ICallerContextInfo
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS

Specified by:
isProtocolSecure in interface ICallerContextInfo<javax.servlet.http.HttpServletRequest>
Returns:
true if the protocol is secure