org.abstracthorizon.danube.http.auth
Class JAASAuthenticatedHTTPContext

java.lang.Object
  extended by org.abstracthorizon.danube.http.Selector
      extended by org.abstracthorizon.danube.http.HTTPContext
          extended by org.abstracthorizon.danube.http.auth.JAASAuthenticatedHTTPContext
All Implemented Interfaces:
ConnectionHandler

public class JAASAuthenticatedHTTPContext
extends HTTPContext

This class marks start of "web application" by setting context path. All, potential, session handling will be done using context path - path this component is defined on.

Author:
Daniel Sendula

Nested Class Summary
protected  class JAASAuthenticatedHTTPContext.AuthData
          Class holding cached authorisation data
 
Field Summary
static String AUTHORIZATION_DATA_ATTRIBUTE
          Authorisation data session attribute
static String AUTHORIZATION_REQUEST_HEADER
          Client request header for authorisation
static String AUTHORIZATION_RESPONSE_HEADER
          Server response header for authorisation
protected  Map<String,JAASAuthenticatedHTTPContext.AuthData> cachedAuth
          Cache to hold authorisation information for a while
protected  int cacheTimeout
          Cache timeout
static int DEFAULT_CACHE_TIMEOUT
          Default cache timeout
static int DEFAULT_MINIMUM_SCAN_PERIOD
          Default minimum scan period
protected  boolean forceAuthorisation
          Force authorisation
protected  long lastScan
          When was cache scanned last time for expired entries
protected  org.slf4j.Logger logger
          Logger
protected  LoginContext loginContext
          Login context
protected  String loginContextName
          Login context name
protected  int minScanPeriod
          Minimum scan period
protected  String realm
          Realm name
protected  HTTPSessionManager sessionManager
          Session manager
 
Fields inherited from class org.abstracthorizon.danube.http.Selector
components, errorResponse
 
Constructor Summary
JAASAuthenticatedHTTPContext()
          Constructor
 
Method Summary
protected  Subject authorise(String base64)
          Obtains subject object from base 64 encoded username and password
 int getCacheTimeout()
          Returns cache timeout
 boolean getForceAuthorisation()
           
 LoginContext getLoginContext()
          Returns login context
 String getLoginContextName()
          Returns login context name
 int getMinimumScanPeriod()
          Return minimum scan period
 String getRealm()
          Returns realm to be used.
 HTTPSessionManager getSessionManager()
          Returns session manaager
 void handleConnection(Connection connection)
          This method creates sets context path to be same as context path up to here plus this component's path.
 void setCacheTimeout(int cacheTimeout)
          Sets cache timeout
 void setForceAuthorisation(boolean forceAuthorisation)
           
 void setLoginContext(LoginContext loginContext)
          Sets login context
 void setLoginContextName(String loginContextName)
          Sets login context name
 void setMinimumScanPeriod(int minScanPeriod)
          Sets minimum scan period
 void setRealm(String realm)
          Sets realm.
 void setSessionManager(HTTPSessionManager sessionManager)
          Sets session manager
protected  void superHandleConnection(Connection connection)
          Calls super class handle connection method.
 
Methods inherited from class org.abstracthorizon.danube.http.Selector
getComponents, getErrorResponse, setComponents, setErrorResponse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Logger


AUTHORIZATION_DATA_ATTRIBUTE

public static final String AUTHORIZATION_DATA_ATTRIBUTE
Authorisation data session attribute

See Also:
Constant Field Values

AUTHORIZATION_REQUEST_HEADER

public static final String AUTHORIZATION_REQUEST_HEADER
Client request header for authorisation

See Also:
Constant Field Values

AUTHORIZATION_RESPONSE_HEADER

public static final String AUTHORIZATION_RESPONSE_HEADER
Server response header for authorisation

See Also:
Constant Field Values

DEFAULT_CACHE_TIMEOUT

public static final int DEFAULT_CACHE_TIMEOUT
Default cache timeout

See Also:
Constant Field Values

DEFAULT_MINIMUM_SCAN_PERIOD

public static final int DEFAULT_MINIMUM_SCAN_PERIOD
Default minimum scan period

See Also:
Constant Field Values

sessionManager

protected HTTPSessionManager sessionManager
Session manager


realm

protected String realm
Realm name


loginContextName

protected String loginContextName
Login context name


loginContext

protected LoginContext loginContext
Login context


cachedAuth

protected Map<String,JAASAuthenticatedHTTPContext.AuthData> cachedAuth
Cache to hold authorisation information for a while


cacheTimeout

protected int cacheTimeout
Cache timeout


minScanPeriod

protected int minScanPeriod
Minimum scan period


lastScan

protected long lastScan
When was cache scanned last time for expired entries


forceAuthorisation

protected boolean forceAuthorisation
Force authorisation

Constructor Detail

JAASAuthenticatedHTTPContext

public JAASAuthenticatedHTTPContext()
Constructor

Method Detail

handleConnection

public void handleConnection(Connection connection)
                      throws ConnectionException
This method creates sets context path to be same as context path up to here plus this component's path. Component's path is reset to "/"

Specified by:
handleConnection in interface ConnectionHandler
Overrides:
handleConnection in class HTTPContext
Parameters:
connection - socket connection
Throws:
ConnectionException

superHandleConnection

protected void superHandleConnection(Connection connection)
                              throws IOException
Calls super class handle connection method.

Parameters:
connection - connection
Throws:
IOException - if thrown by super handleConnection(Connection)

authorise

protected Subject authorise(String base64)
Obtains subject object from base 64 encoded username and password

Parameters:
base64 - base 64 encoded username and password
Returns:
subject or null

getSessionManager

public HTTPSessionManager getSessionManager()
Returns session manaager

Returns:
http session manager

setSessionManager

public void setSessionManager(HTTPSessionManager sessionManager)
Sets session manager

Parameters:
sessionManager - http session manager

getRealm

public String getRealm()
Returns realm to be used. If not set then component path will be used.

Returns:
realm

setRealm

public void setRealm(String realm)
Sets realm.

Parameters:
realm - realm

getLoginContextName

public String getLoginContextName()
Returns login context name

Returns:
login context name

setLoginContextName

public void setLoginContextName(String loginContextName)
Sets login context name

Parameters:
loginContextName - login context name

getLoginContext

public LoginContext getLoginContext()
Returns login context

Returns:
login context

setLoginContext

public void setLoginContext(LoginContext loginContext)
Sets login context

Parameters:
loginContext - login context

getCacheTimeout

public int getCacheTimeout()
Returns cache timeout

Returns:
cache timeout

setCacheTimeout

public void setCacheTimeout(int cacheTimeout)
Sets cache timeout

Parameters:
cacheTimeout - cache timeout

getMinimumScanPeriod

public int getMinimumScanPeriod()
Return minimum scan period

Returns:
minimum scan period

setMinimumScanPeriod

public void setMinimumScanPeriod(int minScanPeriod)
Sets minimum scan period

Parameters:
minScanPeriod - minimum scan period

getForceAuthorisation

public boolean getForceAuthorisation()

setForceAuthorisation

public void setForceAuthorisation(boolean forceAuthorisation)


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.