com.metamatrix.platform.security.session.service
Class SessionServiceImpl

java.lang.Object
  extended by com.metamatrix.platform.service.controller.AbstractService
      extended by com.metamatrix.platform.security.session.service.SessionServiceImpl
All Implemented Interfaces:
EventObjectListener, SessionServiceInterface, ServiceInterface, java.util.EventListener

public class SessionServiceImpl
extends AbstractService
implements SessionServiceInterface

This class serves as the primary implementation of the Session Service.


Field Summary
 
Fields inherited from interface com.metamatrix.platform.security.api.service.SessionServiceInterface
NAME
 
Fields inherited from interface com.metamatrix.platform.service.api.ServiceInterface
WAIT_TO_DIE_TIME
 
Constructor Summary
SessionServiceImpl()
           
 
Method Summary
protected  void closeService()
          Close the service to new work if applicable.
 void closeSession(MetaMatrixSessionID sessionID)
          Closes the specified session.
 MetaMatrixSessionInfo createSession(java.lang.String userName, Credentials credentials, java.io.Serializable trustedToken, java.lang.String applicationName, java.util.Properties properties)
          Create a session for the given user authenticating against the given Credentials.
 java.util.Collection<MetaMatrixSessionInfo> getActiveSessions()
          Get the collection of active user sessions on the system.
 int getActiveSessionsCount()
          Get the number of active user sessions on the system.
 MetaMatrixPrincipal getPrincipal(MetaMatrixSessionID sessionID)
          Returns a MetaMatrixPrincipal object describing the owner (user) of the indicated session.
 java.util.Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(java.lang.String VDBName, java.lang.String VDBVersion)
          Get all MetaMatrixSessionIDs that are in the ACTIVE state and currently logged in to a VDB.
protected  void initService(java.util.Properties env)
          Perform initialization and commence processing.
protected  void killService()
          Terminate all processing and reclaim resources.
 void pingServer(MetaMatrixSessionID sessionID)
          Periodically called by the client to indicate the client is still alive.
 void setIdGenerator(DBIDController idGenerator)
           
 boolean terminateSession(MetaMatrixSessionID terminatedSessionID, MetaMatrixSessionID adminSessionID)
          Terminates the specified session.
 MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
          This method is intended to verify that the session is valid, and, if need be, set the session in an active state, ready to be used.
protected  void waitForServiceToClear()
          Wait until the service has completed all outstanding work.
 
Methods inherited from class com.metamatrix.platform.service.controller.AbstractService
checkState, die, dieNow, getConnectionPoolStats, getCurrentState, getHostname, getID, getInitException, getInstanceName, getProcessName, getProperties, getQueueStatistics, getQueueStatistics, getResourceName, getServiceData, getServiceName, getServiceType, getStartTime, getStateChangeTime, init, isAlive, isClosed, isInitialized, isOpen, processEvent, registerForEvents, setInitException, unregisterForEvents, updateState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.metamatrix.platform.service.api.ServiceInterface
checkState, die, dieNow, getConnectionPoolStats, getCurrentState, getHostname, getID, getInitException, getProcessName, getProperties, getQueueStatistics, getQueueStatistics, getServiceData, getServiceType, getStartTime, getStateChangeTime, init, isAlive, setInitException, updateState
 

Constructor Detail

SessionServiceImpl

public SessionServiceImpl()
Method Detail

initService

protected void initService(java.util.Properties env)
                    throws java.lang.Exception
Perform initialization and commence processing. This method is called only once.

Specified by:
initService in class AbstractService
Throws:
java.lang.Exception

closeService

protected void closeService()
Close the service to new work if applicable. After this method is called the service should no longer accept new work to perform but should continue to process any outstanding work. This method is called by die().

Specified by:
closeService in class AbstractService

waitForServiceToClear

protected void waitForServiceToClear()
                              throws java.lang.Exception
Wait until the service has completed all outstanding work. This method is called by die() just before calling dieNow().

Specified by:
waitForServiceToClear in class AbstractService
Throws:
java.lang.Exception

killService

protected void killService()
Terminate all processing and reclaim resources. This method is called by dieNow() and is only called once.

Specified by:
killService in class AbstractService

closeSession

public void closeSession(MetaMatrixSessionID sessionID)
                  throws InvalidSessionException,
                         SessionServiceException
Description copied from interface: SessionServiceInterface
Closes the specified session.

Specified by:
closeSession in interface SessionServiceInterface
Parameters:
sessionID - The MetaMatrixSessionID identifying user's session to be closed
Throws:
InvalidSessionException - If sessionID identifies an invalid session
SessionServiceException

createSession

public MetaMatrixSessionInfo createSession(java.lang.String userName,
                                           Credentials credentials,
                                           java.io.Serializable trustedToken,
                                           java.lang.String applicationName,
                                           java.util.Properties properties)
                                    throws MetaMatrixAuthenticationException,
                                           SessionServiceException
Description copied from interface: SessionServiceInterface
Create a session for the given user authenticating against the given Credentials.

Specified by:
createSession in interface SessionServiceInterface
Throws:
MetaMatrixAuthenticationException
SessionServiceException

setIdGenerator

public void setIdGenerator(DBIDController idGenerator)

getActiveSessions

public java.util.Collection<MetaMatrixSessionInfo> getActiveSessions()
                                                              throws SessionServiceException
Description copied from interface: SessionServiceInterface
Get the collection of active user sessions on the system.

Specified by:
getActiveSessions in interface SessionServiceInterface
Returns:
The collection of MetaMatrixSessionInfo objects of active users on the system - possibly empty, never null.
Throws:
SessionServiceException

getActiveSessionsCount

public int getActiveSessionsCount()
                           throws SessionServiceException
Description copied from interface: SessionServiceInterface
Get the number of active user sessions on the system.

Specified by:
getActiveSessionsCount in interface SessionServiceInterface
Returns:
int
Throws:
SessionServiceException

getPrincipal

public MetaMatrixPrincipal getPrincipal(MetaMatrixSessionID sessionID)
                                 throws InvalidSessionException,
                                        SessionServiceException
Description copied from interface: SessionServiceInterface
Returns a MetaMatrixPrincipal object describing the owner (user) of the indicated session.

Specified by:
getPrincipal in interface SessionServiceInterface
Parameters:
sessionID - MetaMatrixSessionID representing the session
Returns:
MetaMatrixPrincipal object describing the owner of the indicated session.
Throws:
InvalidSessionException
SessionServiceException

getSessionsLoggedInToVDB

public java.util.Collection<MetaMatrixSessionInfo> getSessionsLoggedInToVDB(java.lang.String VDBName,
                                                                            java.lang.String VDBVersion)
                                                                     throws SessionServiceException,
                                                                            ServiceStateException
Description copied from interface: SessionServiceInterface
Get all MetaMatrixSessionIDs that are in the ACTIVE state and currently logged in to a VDB.

Specified by:
getSessionsLoggedInToVDB in interface SessionServiceInterface
Parameters:
VDBName - The name of the VDB.
VDBVersion - The version of the VDB.
Throws:
SessionServiceException - when transaction with database fails or unexpected exception happens
ServiceStateException

pingServer

public void pingServer(MetaMatrixSessionID sessionID)
                throws ServiceStateException,
                       InvalidSessionException
Description copied from interface: SessionServiceInterface
Periodically called by the client to indicate the client is still alive.

Specified by:
pingServer in interface SessionServiceInterface
Parameters:
sessionID - - identifies the client
Throws:
ServiceStateException
InvalidSessionException

terminateSession

public boolean terminateSession(MetaMatrixSessionID terminatedSessionID,
                                MetaMatrixSessionID adminSessionID)
                         throws AuthorizationException,
                                SessionServiceException
Description copied from interface: SessionServiceInterface
Terminates the specified session. This is an administrative action.

Specified by:
terminateSession in interface SessionServiceInterface
Parameters:
terminatedSessionID - The MetaMatrixSessionID identifying user's session to be terminated
adminSessionID - The session id identifying session of administrator
Throws:
AuthorizationException - if the caller denoted by adminSessionID does not have authority to terminate the terminatedSessionID session
SessionServiceException

validateSession

public MetaMatrixSessionInfo validateSession(MetaMatrixSessionID sessionID)
                                      throws InvalidSessionException,
                                             SessionServiceException
Description copied from interface: SessionServiceInterface
This method is intended to verify that the session is valid, and, if need be, set the session in an active state, ready to be used.

Specified by:
validateSession in interface SessionServiceInterface
Parameters:
sessionID - MetaMatrixSessionID representing the session
Returns:
SessionToken object identifying the session
Throws:
InvalidSessionException - If sessionID identifies an invalid session
SessionServiceException


Copyright © 2009. All Rights Reserved.