gov.bnl.gums.db
Class HibernateAccountMapperDB

java.lang.Object
  extended by gov.bnl.gums.db.HibernateAccountMapperDB
All Implemented Interfaces:
AccountPoolMapperDB, ManualAccountMapperDB

public class HibernateAccountMapperDB
extends Object
implements ManualAccountMapperDB, AccountPoolMapperDB

Author:
Gabriele Carcassi, Jay Packard

Constructor Summary
HibernateAccountMapperDB(HibernatePersistenceFactory persistenceFactory, String map)
          Creates a new instance of HibernateMapping
 
Method Summary
 void addAccount(String account)
          Adds an account to the pool of free accounts.
 String assignAccount(GridUser user)
          Assigns a new account from the pool to the user.
 void createMapping(String userDN, String account)
          Saves in the DB the new mapping between the userDN and the account.
 String getMap()
           
 boolean needsCacheRefresh()
          This is a function meant to be used by a wrapper class that is caching some result from the database.
 boolean removeAccount(String account)
          Removes account from the pool of free accounts.
 boolean removeMapping(String userDN)
          Removes the mapping for the given user.
 String retrieveAccount(GridUser user)
          Retrieves the account associated to the Grid identity.
 Map retrieveAccountMap()
          Retrieves user to account map.
 String retrieveMapping(String userDN)
          Retrieves a user mapping from the database.
 Map retrieveReverseAccountMap()
          Retrieves account to user map.
 List retrieveUsersNotUsedSince(Date date)
          Retrieve the list of accounts not in use since the given date.
 void setCacheRefreshed()
          Call when a wrapper class using the DB object has updated its cache.
 void unassignAccount(String account)
          Unassigns whatever user is assigned to this account from the account mapping and renders that account available to the pool.
 void unassignUser(String userDN)
          Removes user from the mapping, and renders it available to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateAccountMapperDB

public HibernateAccountMapperDB(HibernatePersistenceFactory persistenceFactory,
                                String map)
Creates a new instance of HibernateMapping

Method Detail

addAccount

public void addAccount(String account)
Description copied from interface: AccountPoolMapperDB
Adds an account to the pool of free accounts. If the account already exists, will throw an exception

Specified by:
addAccount in interface AccountPoolMapperDB
Parameters:
account - the account to be added

assignAccount

public String assignAccount(GridUser user)
Description copied from interface: AccountPoolMapperDB
Assigns a new account from the pool to the user. If the user is already mapped, will throw an exception.

Specified by:
assignAccount in interface AccountPoolMapperDB
Returns:
the account or null if no more accounts are available

createMapping

public void createMapping(String userDN,
                          String account)
Description copied from interface: ManualAccountMapperDB
Saves in the DB the new mapping between the userDN and the account. If a mapping for the given user is already present, an exception should be thrown.

Specified by:
createMapping in interface ManualAccountMapperDB
Parameters:
userDN - a certificate DN
account - a UNIX account name

getMap

public String getMap()
Specified by:
getMap in interface AccountPoolMapperDB
Returns:
the map this mapper is responsible for

needsCacheRefresh

public boolean needsCacheRefresh()
Description copied from interface: AccountPoolMapperDB
This is a function meant to be used by a wrapper class that is caching some result from the database. When any writing operation occurs, this should return true until set to false by the wrapper class.

Specified by:
needsCacheRefresh in interface AccountPoolMapperDB
Returns:
whether changes require a cache refresh

removeAccount

public boolean removeAccount(String account)
Description copied from interface: AccountPoolMapperDB
Removes account from the pool of free accounts.

Specified by:
removeAccount in interface AccountPoolMapperDB
Parameters:
account - the account to be removed
Returns:
if account was removed

removeMapping

public boolean removeMapping(String userDN)
Description copied from interface: ManualAccountMapperDB
Removes the mapping for the given user.

Specified by:
removeMapping in interface ManualAccountMapperDB
Parameters:
userDN - a certificate DN
Returns:
true if a mapping was deleted

retrieveAccount

public String retrieveAccount(GridUser user)
Description copied from interface: AccountPoolMapperDB
Retrieves the account associated to the Grid identity.

Specified by:
retrieveAccount in interface AccountPoolMapperDB
Returns:
the account or null if the user wasn't mapped

retrieveAccountMap

public Map retrieveAccountMap()
Description copied from interface: ManualAccountMapperDB
Retrieves user to account map.

Specified by:
retrieveAccountMap in interface AccountPoolMapperDB
Specified by:
retrieveAccountMap in interface ManualAccountMapperDB
Returns:
a Map object

retrieveMapping

public String retrieveMapping(String userDN)
Description copied from interface: ManualAccountMapperDB
Retrieves a user mapping from the database.

Specified by:
retrieveMapping in interface ManualAccountMapperDB
Parameters:
userDN - a certificate DN
Returns:
the UNIX account provided by the mapping

retrieveReverseAccountMap

public Map retrieveReverseAccountMap()
Description copied from interface: ManualAccountMapperDB
Retrieves account to user map.

Specified by:
retrieveReverseAccountMap in interface AccountPoolMapperDB
Specified by:
retrieveReverseAccountMap in interface ManualAccountMapperDB
Returns:
a Map object

retrieveUsersNotUsedSince

public List retrieveUsersNotUsedSince(Date date)
Description copied from interface: AccountPoolMapperDB
Retrieve the list of accounts not in use since the given date.

Specified by:
retrieveUsersNotUsedSince in interface AccountPoolMapperDB
Parameters:
date - the time since the accounts haven't been used.
Returns:
a list of String with the accounts

setCacheRefreshed

public void setCacheRefreshed()
Description copied from interface: AccountPoolMapperDB
Call when a wrapper class using the DB object has updated its cache.

Specified by:
setCacheRefreshed in interface AccountPoolMapperDB

unassignAccount

public void unassignAccount(String account)
Description copied from interface: AccountPoolMapperDB
Unassigns whatever user is assigned to this account from the account mapping and renders that account available to the pool.

Specified by:
unassignAccount in interface AccountPoolMapperDB
Parameters:
account - that should be unassigned

unassignUser

public void unassignUser(String userDN)
Description copied from interface: AccountPoolMapperDB
Removes user from the mapping, and renders it available to the pool.

Specified by:
unassignUser in interface AccountPoolMapperDB
Parameters:
userDN - the user that shouldn't be mapped anymore


Copyright © 2004-2009. All Rights Reserved.