org.qtunes.auth.spi
Class AuthImpl

java.lang.Object
  extended by org.qtunes.auth.spi.AuthImpl
All Implemented Interfaces:
Auth, Service

public class AuthImpl
extends java.lang.Object
implements Auth

The Auth class handles creation of Sessions and determining what rights those Sessions have. Each QTunes object has only one Auth service Different Services may register an Authorizer with this object: when a Session is created by a call to login(java.util.Map), each Authorizer for the matching Service is queried to see what "allowances" it gives it.


Constructor Summary
AuthImpl()
           
 
Method Summary
 void addAuthorizer(Authorizer auth)
          Add an Authorizer to the Auth object.
 java.util.Collection<java.lang.String> getAllowances(Session session)
          Return the set of allowances for the specified Session
 ServiceContext getContext()
          Return the ServiceContext that was passed into Service.startService(org.qtunes.core.ServiceContext)
 Session getSession(int id)
          Get the Session with the specified ID, or null if it doesn't exist
 Session login(java.util.Map properties)
          Create a new Session
 void logout(Session session)
          Expire the specified Session
 void logoutSessions(Service service)
          Expire all Sessions created by the specified Service
 void removeAuthorizer(Authorizer auth)
          Remove the previously added Authorizer from the Auth object
 java.util.Map<java.lang.String,java.lang.Object> reportState()
          Return a Map describing the state of this Service, for serialization back to any client that needs to know (eg webplayer) - so values should be serializable objects, eg Lists, Maps or simple objects.
 void startService(ServiceContext context)
          Start the Service
 void stopService(ServiceContext context)
          Stop the Service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthImpl

public AuthImpl()
Method Detail

startService

public void startService(ServiceContext context)
Description copied from interface: Service
Start the Service

Specified by:
startService in interface Service
Parameters:
context - the ServiceContext for this Service

stopService

public void stopService(ServiceContext context)
Description copied from interface: Service
Stop the Service

Specified by:
stopService in interface Service
Parameters:
context - the ServiceContext for this Service (same as was passed into start)

getContext

public ServiceContext getContext()
Description copied from interface: Service
Return the ServiceContext that was passed into Service.startService(org.qtunes.core.ServiceContext)

Specified by:
getContext in interface Service

getSession

public Session getSession(int id)
Description copied from interface: Auth
Get the Session with the specified ID, or null if it doesn't exist

Specified by:
getSession in interface Auth

login

public Session login(java.util.Map properties)
Description copied from interface: Auth
Create a new Session

Specified by:
login in interface Auth
Parameters:
properties - a Map of properties which are part of the session - the exact content depends on the service (for example, a web service might include the Remote IP address of the connection). These properties are tested by the various Authorizers registered with the system to determine the set of allowances. At a minimum the Map must contain a "session" key with the value as either the name of the Service or the Service itself.

logout

public void logout(Session session)
Description copied from interface: Auth
Expire the specified Session

Specified by:
logout in interface Auth
Parameters:
session - the session to expire

getAllowances

public java.util.Collection<java.lang.String> getAllowances(Session session)
Description copied from interface: Auth
Return the set of allowances for the specified Session

Specified by:
getAllowances in interface Auth

addAuthorizer

public void addAuthorizer(Authorizer auth)
Description copied from interface: Auth
Add an Authorizer to the Auth object. Any session creation requests will check with all the authorizers to see what rights that Session has.

Specified by:
addAuthorizer in interface Auth

removeAuthorizer

public void removeAuthorizer(Authorizer auth)
Description copied from interface: Auth
Remove the previously added Authorizer from the Auth object

Specified by:
removeAuthorizer in interface Auth

logoutSessions

public void logoutSessions(Service service)
Description copied from interface: Auth
Expire all Sessions created by the specified Service

Specified by:
logoutSessions in interface Auth

reportState

public java.util.Map<java.lang.String,java.lang.Object> reportState()
Description copied from interface: Service
Return a Map describing the state of this Service, for serialization back to any client that needs to know (eg webplayer) - so values should be serializable objects, eg Lists, Maps or simple objects. If no useful state, return null.

Specified by:
reportState in interface Service