gov.bnl.gums.db
Class LDAPAccountMapperDB

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

public class LDAPAccountMapperDB
extends Object
implements AccountPoolMapperDB, ManualAccountMapperDB

Author:
Gabriele Carcassi, Jay Packard

Constructor Summary
LDAPAccountMapperDB(LDAPPersistenceFactory factory, String map)
          Creates a new LDAP map, named "map=map" in the defaultGumsOU.
LDAPAccountMapperDB(LDAPPersistenceFactory factory, String map, String group, List secondaryGroups)
          Creates a new LDAP map, named "map=map" in the defaultGumsOU.
 
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 createGroupIfNotExists()
           
 void createMapping(String userDN, String account)
          Saves in the DB the new mapping between the userDN and the account.
 boolean doesMapExist()
           
 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 a user to account map.
 String retrieveEmail(String account)
           
 String retrieveMapping(String userDN)
          Retrieves a user mapping from the database.
 Map retrieveReverseAccountMap()
          Retrieves an account to user DN map, including null DNs, where empty strings are returned if the account is unassigned.
 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

LDAPAccountMapperDB

public LDAPAccountMapperDB(LDAPPersistenceFactory factory,
                           String map)
Creates a new LDAP map, named "map=map" in the defaultGumsOU.

Parameters:
factory - the LDAP factory that will provide LDAP connectivity
map - the name of the map

LDAPAccountMapperDB

public LDAPAccountMapperDB(LDAPPersistenceFactory factory,
                           String map,
                           String group,
                           List secondaryGroups)
Creates a new LDAP map, named "map=map" in the defaultGumsOU. When accounts are assigned they will be associated with the gids for the UNIX groups given.

Parameters:
factorythe - LDAP factory that will provide LDAP connectivity
mapthe - name of the map
groupthe - UNIX primary group for the accounts assigned
secondaryGroups - the UNIX secondary groups for the accounts assigned
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

createGroupIfNotExists

public void createGroupIfNotExists()

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

doesMapExist

public boolean doesMapExist()

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: AccountPoolMapperDB
Retrieves a user to account map.

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

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: 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
Specified by:
retrieveReverseAccountMap in interface ManualAccountMapperDB
Returns:
a Map between the userDN (String) as the key and the account (String).

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

retrieveEmail

public String retrieveEmail(String account)

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.