org.qtunes.auth.spi
Class SessionImpl

java.lang.Object
  extended by org.qtunes.core.Session
      extended by org.qtunes.auth.spi.SessionImpl

public class SessionImpl
extends Session

A Session is a single login session and one must be in place for most ControlMethod objects to be run. Each Session has a unique ID, a record of the Service that created it and a number of "allowances", which determine what the Session can do. These can be checked by calling the isAllowed(java.lang.String) method.

When the session is created a set of Properties can be specified, which can be retrieved later with the getProperties() method. Please see the API docs for that method to get a list of standard properties.


Field Summary
 
Fields inherited from class org.qtunes.core.Session
NONE
 
Method Summary
 java.util.Collection<java.lang.String> getAllowances()
          Return the Set of allowances for this Session
 int getCreated()
          Return the time this session was created, in seconds since epoch
 int getExpiryTime()
          Return the time this session should be expired, in seconds since epoch
 int getId()
          Return the unique numeric ID of this Session
 int getLastActivity()
          Return the last time any activity occurred on this session, in seconds since epoch
 java.util.Map getProperties()
          Get the Properties specified when this Session was created.
 Service getService()
          Return the Service that created this Session
 boolean isAllowed(java.lang.String test)
          Return whether this Session has the specified allowance.
 java.lang.String toString()
           
 void touch()
          Mark the session as active as of this point in time
 
Methods inherited from class org.qtunes.core.Session
bumpTracksCompleted, bumpTracksStarted, bumpTraffic, expire, getCurrentSession, getTracksCompleted, getTracksStarted, getTraffic, isExpired, setCurrentSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getId

public int getId()
Description copied from class: Session
Return the unique numeric ID of this Session

Specified by:
getId in class Session

getService

public Service getService()
Description copied from class: Session
Return the Service that created this Session

Specified by:
getService in class Session

getCreated

public int getCreated()
Description copied from class: Session
Return the time this session was created, in seconds since epoch

Specified by:
getCreated in class Session

touch

public void touch()
Description copied from class: Session
Mark the session as active as of this point in time

Specified by:
touch in class Session

getLastActivity

public int getLastActivity()
Description copied from class: Session
Return the last time any activity occurred on this session, in seconds since epoch

Specified by:
getLastActivity in class Session

getExpiryTime

public int getExpiryTime()
Description copied from class: Session
Return the time this session should be expired, in seconds since epoch

Specified by:
getExpiryTime in class Session

isAllowed

public boolean isAllowed(java.lang.String test)
Description copied from class: Session
Return whether this Session has the specified allowance. The allowances depend on the Authorizer objects that have been registered with the Auth.addAuthorizer(org.qtunes.auth.Authorizer) method - an Authorizer that grants "*" will allow any action, and passing the value "*" in as the test will check for any allowance. The Session.NONE Session does not allow anything.

Specified by:
isAllowed in class Session
Parameters:
test - the allowance we're testing for, or "*" for any allowance

getAllowances

public java.util.Collection<java.lang.String> getAllowances()
Description copied from class: Session
Return the Set of allowances for this Session

Specified by:
getAllowances in class Session

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getProperties

public java.util.Map getProperties()
Description copied from class: Session
Get the Properties specified when this Session was created. The list of recommended properties is as follows - not all will be applicable for each type of Service
ipThe IP address or Hostname for the session, if it was created remotely
userThe username of the user that created the session

Specified by:
getProperties in class Session