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 java.lang.Object
implements ManualAccountMapperDB, AccountPoolMapperDB

Author:
Gabriele Carcassi, Jay Packard

Constructor Summary
HibernateAccountMapperDB(HibernatePersistenceFactory persistenceFactory, java.lang.String map)
          Creates a new instance of HibernateMapping
 
Method Summary
 void addAccount(java.lang.String account)
          Adds an account to the pool of free accounts.
 java.lang.String assignAccount(java.lang.String userDN)
          Assigns a new account from the pool to the user.
 void createMapping(java.lang.String userDN, java.lang.String account)
          Saves in the DB the new mapping between the userDN and the account.
 boolean needsCacheRefresh()
           
 boolean removeAccount(java.lang.String account)
          Removes account from the pool of free accounts.
 boolean removeMapping(java.lang.String userDN)
          Removes the mapping for the given user.
 java.lang.String retrieveAccount(java.lang.String userDN)
          Retrieves the account associated to the Grid identity.
 java.util.Map retrieveAccountMap()
          Retrieves a user to account map.
 java.lang.String retrieveMapping(java.lang.String userDN)
          Retrieves a user mapping from the database.
 java.util.List retrieveMappings()
          Retrieves user mappings from the database.
 java.util.Map retrieveReverseAccountMap()
          Retrieves an account to user DN map, including null DNs, where empty strings are returned if the account is unassigned.
 java.util.List retrieveUsersNotUsedSince(java.util.Date date)
          Retrieve the list of accounts not in use since the given date.
 void setNeedsCacheRefresh(boolean value)
          Set when cache has been refreshed
 void unassignAccount(java.lang.String account)
          Unassigns whatever user is assigned to this account from the account mapping and renders that account available to the pool.
 void unassignUser(java.lang.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,
                                java.lang.String map)
Creates a new instance of HibernateMapping

Method Detail

addAccount

public void addAccount(java.lang.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 java.lang.String assignAccount(java.lang.String userDN)
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
Parameters:
userDN - the user to be mapped
Returns:
the account or null if no more accounts are available

createMapping

public void createMapping(java.lang.String userDN,
                          java.lang.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

needsCacheRefresh

public boolean needsCacheRefresh()
Specified by:
needsCacheRefresh in interface AccountPoolMapperDB
Returns:
whether changes require a cache refresh

removeAccount

public boolean removeAccount(java.lang.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(java.lang.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 java.lang.String retrieveAccount(java.lang.String userDN)
Description copied from interface: AccountPoolMapperDB
Retrieves the account associated to the Grid identity.

Specified by:
retrieveAccount in interface AccountPoolMapperDB
Parameters:
userDN - the certificate DN
Returns:
the account or null if the user wasn't mapped

retrieveAccountMap

public java.util.Map retrieveAccountMap()
Description copied from interface: AccountPoolMapperDB
Retrieves a user to account map.

Specified by:
retrieveAccountMap in interface AccountPoolMapperDB
Returns:
a Map between the userDN (String) as the key and the account (String).

retrieveMapping

public java.lang.String retrieveMapping(java.lang.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

retrieveMappings

public java.util.List retrieveMappings()
Description copied from interface: ManualAccountMapperDB
Retrieves user mappings from the database.

Specified by:
retrieveMappings in interface ManualAccountMapperDB
Returns:
all the mappings

retrieveReverseAccountMap

public java.util.Map retrieveReverseAccountMap()
Description copied from interface: AccountPoolMapperDB
Retrieves an account to user DN map, including null DNs, where empty strings are returned if the account is unassigned.

Specified by:
retrieveReverseAccountMap in interface AccountPoolMapperDB
Returns:
a Map between the userDN (String) as the key and the account (String).

retrieveUsersNotUsedSince

public java.util.List retrieveUsersNotUsedSince(java.util.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

setNeedsCacheRefresh

public void setNeedsCacheRefresh(boolean value)
Description copied from interface: AccountPoolMapperDB
Set when cache has been refreshed

Specified by:
setNeedsCacheRefresh in interface AccountPoolMapperDB

unassignAccount

public void unassignAccount(java.lang.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(java.lang.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-2008. All Rights Reserved.