org.opentox.toxotis.util.aa
Class TokenPool

java.lang.Object
  extended by org.opentox.toxotis.util.aa.TokenPool

public final class TokenPool
extends Object

Serves as a pool of tokens you can use in your project to best manage your tokens and not create multiple tokens for the same user.

Author:
Pantelis Sopasakis, Charalampos Chomenides

Method Summary
static TokenPool getInstance()
           
 Collection<User> getLoggedIn()
           
 AuthenticationToken getToken(String username)
          Returns the token for a certain user by searching in the pool.
 User getUser(String username)
           
 AuthenticationToken login(File credentialsFile)
          Login and acquire an authentication token that you can use to access OpenTox services
 AuthenticationToken login(String credentialsFile)
           
 AuthenticationToken login(String username, String password)
           
 int logout(String username)
          Logs out a user identified by its username.
 void logoutAll()
           
static void setMasterPasswordFile(File masterPasswordFile)
           
static void setMasterPasswordFile(String masterPasswordFile)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TokenPool getInstance()

size

public int size()

setMasterPasswordFile

public static void setMasterPasswordFile(File masterPasswordFile)

setMasterPasswordFile

public static void setMasterPasswordFile(String masterPasswordFile)

getToken

public AuthenticationToken getToken(String username)
Returns the token for a certain user by searching in the pool. If no such token is found, null is returned. Note that the token you get, if not null, might have expired. Always check the status of the token you get from this method using AuthenticationToken.getStatus().

Parameters:
username - Username for which the token is to be lookep up for.
Returns:
Authentication token for the specified user and null if no such user is found in the pool.

login

public AuthenticationToken login(String username,
                                 String password)
                          throws ToxOtisException,
                                 ServiceInvocationException
Throws:
ToxOtisException
ServiceInvocationException

login

public AuthenticationToken login(File credentialsFile)
                          throws IOException,
                                 ToxOtisException,
                                 ServiceInvocationException
Login and acquire an authentication token that you can use to access OpenTox services

Parameters:
credentialsFile - Encrypted file with your credentials (username and password) that have
Returns:
The authentication token that results from the login/authentication operation.
Throws:
IOException
ToxOtisException
ServiceInvocationException

getUser

public User getUser(String username)

getLoggedIn

public Collection<User> getLoggedIn()

login

public AuthenticationToken login(String credentialsFile)
                          throws IOException,
                                 ToxOtisException,
                                 ServiceInvocationException
Throws:
IOException
ToxOtisException
ServiceInvocationException

logout

public int logout(String username)
           throws ServiceInvocationException
Logs out a user identified by its username. An invalidation request is sent to the remote SSO service and the token of that user becomes invalid.

Parameters:
username - Name of the user which is to be logged out.
Returns:
Returns an integer flag that identifies whether the token was invalidated. In particular returns 1 if the user has a token in the pool and it is successfully invalidated, -1
Throws:
ServiceInvocationException

logoutAll

public void logoutAll()
               throws ServiceInvocationException
Throws:
ServiceInvocationException


Copyright © 2011-2012 OpenTox. All Rights Reserved.