public abstract class FdkSession extends Object implements LogInfo
Modifier and Type | Field and Description |
---|---|
protected Thread |
m_CurrentRequestThread |
protected String |
m_Tag |
Constructor and Description |
---|
FdkSession() |
Modifier and Type | Method and Description |
---|---|
abstract void |
beginRequest(boolean wait,
long timeout,
String tag)
Notifies the session that a new request has begun.
|
protected void |
beginRequestCommon()
Protected method that subclasses MUST call when implementing
beginRequest().
|
abstract boolean |
endRequest()
Notifies the session that the request has ended.
|
long |
getCreationTime()
Returns the time when this session was created.The time format is the
same as
System.currentTimeMillis() . |
static FdkSession |
getCurrentSession()
Returns the current session for the ongoing request, or null if no
session is available or cannot be determined.
|
abstract String |
getDistinguishedName()
Returned the distinguished name for the authenticated user.
|
abstract long |
getId()
Returns this session identifier.
|
abstract Object |
getInternalSession()
Returns the internal session associated with this user session.
|
abstract long |
getLastAccessTime()
Returns the time when the last request was completed by calling
endRequest() on the current session. |
abstract ManagersFactory |
getManagersFactory()
Returns the managers factory corresponding to this session.
|
abstract long |
getSessionTimeout()
Returns the session timeout, in seconds, for this session.
|
abstract Object |
getState(Object key)
Returns the value stored at the given key using
setState() . |
String |
getTag()
Returns the tag for this session, set either when the session was
created or when
beginRequest() was called. |
abstract String |
getTrustedApplicationName()
Returns the name of the trusted application or
null if the
session was not created by a truested application. |
abstract String |
getUsername()
Returns the username for the authenticated user.
|
void |
httpBind()
Respond to a bind notification from the HttpSession
|
void |
httpUnbind()
Respond to an unbind notification from the HttpSession
|
abstract boolean |
isConnected()
Returns true if this session is connected.
|
abstract boolean |
isGuest()
Returns true if the session is a guest/anonymous session.
|
abstract boolean |
isRequestInProgress()
Returns true if there is a request being serviced by this session.
|
abstract boolean |
isSystem()
Returns true if the session is a system session.
|
abstract boolean |
isTrustedApplication()
Returns true if the session was created by a trusted application.
|
abstract void |
registerForEvents(FdkSessionListener listener)
Registers a listener for events that may occur on this session.
|
protected void |
requestCleanup()
Request cleanup.
|
abstract void |
setLastAccessTimeUpdate(boolean update)
Sets whether the last access time will be updated when
endRequest() is called on the current session. |
abstract void |
setSessionTimeout(long timeout)
Sets the automatic session timeout for inactivity.
|
abstract void |
setState(Object key,
Object value)
Sets a value representing a piece of state that makes sense to the
application.
|
abstract boolean |
unregisterForEvents(FdkSessionListener listener)
Unregisters a previously registered listener.
|
abstract boolean |
verifyCredential(Credential credential)
Verifies that the given credential is valid for the user represented
by this session.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSessionIdentifier, getUserIdentifier
protected Thread m_CurrentRequestThread
protected String m_Tag
public static FdkSession getCurrentSession()
public abstract ManagersFactory getManagersFactory() throws FdkException
FdkException
public abstract Object getInternalSession() throws FdkException
WARNING!
This method should not be called from client code, except for exceptional circumstances where the caller understands the implications of using the underlying internal session directly and opts out of using the framework.
If you need to use this method, please check with the developers of the framework for possible alternate ways of achieving the same result.
FdkException
public abstract long getId()
public long getCreationTime()
System.currentTimeMillis()
.public abstract long getLastAccessTime()
endRequest()
on the current session. The time format is the
same as System.currentTimeMillis()
.public String getTag()
beginRequest()
was called.public abstract void setLastAccessTimeUpdate(boolean update)
endRequest()
is called on the current session. This is
useful behavior for requests that are not sent by the true end-user but
rather by a polling process for example.
Note that the behavior is changed on a per request basis, the default
behavior if the method is not called during a request is to always update
the last access time and the behavior is reset to the default when a
request is completed by calling endRequest()
.
update
- If false
the last access time will not be
updated, otherwise it will be updated.public abstract boolean isConnected()
public abstract String getUsername()
public abstract String getDistinguishedName()
public abstract boolean isGuest()
public abstract boolean isSystem()
public abstract boolean isTrustedApplication()
public abstract String getTrustedApplicationName()
null
if the
session was not created by a truested application.public abstract boolean verifyCredential(Credential credential) throws FdkException
true
if the credential is
valid or false
otherwise. The method can also throw a
FdkException
if errors occur during the verification
process.credential
- The credential to verify.FdkException
public abstract boolean isRequestInProgress()
beginRequest()
and endRequest()
public abstract void beginRequest(boolean wait, long timeout, String tag) throws FdkException
endRequest()
must be
called from the same thread.wait
- Whether the calling thread should wait for the session
to finish any existing requests or should fail right away
if the session is busy. If wait is false
, the
timeout value is ignored.timeout
- If the caller chooses to wait, this is the timeout in
milliseconds before an error is returned if the session is
still busy. If the parameter is 0, the wait is indefinite.
If the timeout is -1 or any negative value the wait is
defaulted to a system chosen, sensible value.tag
- A tag describing the application that is currently using
this session. The tag can be retrieved later on by
calling getTag()
.
Must not be null
.FdkException
protected void beginRequestCommon()
public abstract boolean endRequest() throws FdkException
false
if there were no outstanding requests on the session or the current
thread did not own the session. The caller may interpret it as an error
or just ignore it, depending on its implementation.FdkException
public abstract void setSessionTimeout(long timeout)
In addition, if the timeout is greater than zero, the session will not be disconnected when it gets the unbind even from the HttpSession, as it is assumed it is being managed by a different entity.
timeout
- Number of seconds to set the timeout to.public abstract long getSessionTimeout()
public abstract void setState(Object key, Object value) throws FdkException
getState()
.
It is recommended that applications store only one object as their state. The object can be a Map that contains other pieces of state.
key
- The key that identifies the piece of state. The namespace
for the key is not specified. It is recommended that a
package-like key name be used in order to avoid potential
conflicts.value
- The value to store at the given key. If null
,
the key will be removed.FdkException
public abstract Object getState(Object key) throws FdkException
setState()
.
See the documentation of setState()
.key
- The key to retrieve the value for.FdkException
public abstract void registerForEvents(FdkSessionListener listener)
FdkSessionListener
interface.listener
- The listener to register. It must imlpement the
FdkSessionListener
interface.public abstract boolean unregisterForEvents(FdkSessionListener listener)
false
is returned.listener
- The listener to register. It must imlpement the
FdkSessionListener
interface.public void httpBind()
public void httpUnbind()
protected void requestCleanup()
Copyright © 2023. All rights reserved.