org.yawlfoundation.yawl.authentication
Class YSessionCache

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.concurrent.ConcurrentHashMap<String,YSession>
          extended by org.yawlfoundation.yawl.authentication.YSessionCache
All Implemented Interfaces:
Serializable, ConcurrentMap<String,YSession>, Map<String,YSession>

public class YSessionCache
extends ConcurrentHashMap<String,YSession>

An extended Hashtable that manages connections to the engine from custom services and external applications.

The map is of the form [sessionHandle, session].

Since:
2.1
Author:
Michael Adams
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
YSessionCache()
           
 
Method Summary
 boolean checkConnection(String handle)
          Checks that a session handle represents an active session.
 String connect(String name, String password, long timeOutSeconds)
          Creates and stores a new session between the the Engine and a custom service or external application.
 void disconnect(String handle)
          Ends an active session of a custom service or external application.
 void disconnect(YClient client)
          Ends an active session of a custom service or external application.
 void expire(String handle)
          Removes a session from the set of active sessions after an idle timeout.
 YSession getSession(String handle)
          Gets the session associated with a session handle.
 boolean isClientConnected(YExternalClient client)
          Checks that a particular external client has an active session with the Engine.
 boolean isServiceConnected(String uri)
          Checks that a particular custom service has an active session with the Engine.
 void shutdown()
          Called when the hosting server shuts down to write a shutdown record for each active session to the audit log.
 
Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, contains, containsKey, containsValue, elements, entrySet, get, isEmpty, keys, keySet, put, putAll, putIfAbsent, remove, remove, replace, replace, size, values
 
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

YSessionCache

public YSessionCache()
Method Detail

connect

public String connect(String name,
                      String password,
                      long timeOutSeconds)
Creates and stores a new session between the the Engine and a custom service or external application.

Parameters:
name - the username of the external client
password - the corresponding (hashed) password
timeOutSeconds - the maximum idle time for this session (in seconds). A value of 0 will default to 60 minutes; a value less than zero means this session will never timeout.
Returns:
a valid session handle, or an appropriate error message

checkConnection

public boolean checkConnection(String handle)
Checks that a session handle represents an active session. If it does, the session idle timer is restarted also.

Parameters:
handle - the session handle held by a client or service.
Returns:
true if the handle's session is active.

isServiceConnected

public boolean isServiceConnected(String uri)
Checks that a particular custom service has an active session with the Engine.

Parameters:
uri - the uri of the custom service.
Returns:
true if the service has an active session.

isClientConnected

public boolean isClientConnected(YExternalClient client)
Checks that a particular external client has an active session with the Engine.

Parameters:
client - the client.
Returns:
true if the client has an active session.

getSession

public YSession getSession(String handle)
Gets the session associated with a session handle.

Parameters:
handle - a session handle.
Returns:
the session object associated with the handle, or null if the handle is invalid or inactive.

expire

public void expire(String handle)
Removes a session from the set of active sessions after an idle timeout. Also writes the expiration to the session audit log.

Parameters:
handle - the session handle of the session to remove.

disconnect

public void disconnect(YClient client)
Ends an active session of a custom service or external application.

Parameters:
client - the service or application to disconnect from the Engine. Also writes the disconnection to the session audit log.

disconnect

public void disconnect(String handle)
Ends an active session of a custom service or external application.

Parameters:
handle - the session handle of a service or application to disconnect from the Engine. Also writes the disconnection to the session audit log.

shutdown

public void shutdown()
Called when the hosting server shuts down to write a shutdown record for each active session to the audit log.



Copyright © 2004-2012 The YAWL Foundation.