1 /* 2 * AccountPoolMapperDB.java 3 * 4 * Created on June 14, 2004, 3:18 PM 5 */ 6 7 package gov.bnl.gums.db; 8 9 import java.util.Date; 10 import java.util.List; 11 import java.util.Map; 12 13 /** 14 * Provides the set of accounts for the AccountPoolMapper class which 15 * assignes accounts from a pool. 16 * <p> 17 * The implementation shouldn't buffer the information, as it the 18 * AccountPoolMapper responsability to do so. 19 * 20 * @author Gabriele Carcassi, Jay Packard 21 */ 22 public interface AccountPoolMapperDB { 23 24 /** 25 * Adds an account to the pool of free accounts. If the account 26 * already exists, will throw an exception 27 * 28 * @param account the account to be added 29 */ 30 void addAccount(String account); 31 32 /** 33 * Assigns a new account from the pool to the user. If the user is already 34 * mapped, will throw an exception. 35 * 36 * @todo decide which exception are thrown when 37 * @param userDN the user to be mapped 38 * @return the account or null if no more accounts are available 39 */ 40 String assignAccount(String userDN); 41 42 /** 43 * 44 * @return whether changes require a cache refresh 45 */ 46 boolean needsCacheRefresh(); 47 48 /** 49 * Removes account from the pool of free accounts. 50 * 51 * @param account the account to be removed 52 * @return if account was removed 53 */ 54 boolean removeAccount(String account); 55 56 /** Retrieves the account associated to the Grid identity. 57 * 58 * @param userDN the certificate DN 59 * @return the account or null if the user wasn't mapped 60 */ 61 String retrieveAccount(String userDN); 62 63 /** Retrieves a user to account map. 64 * 65 * @return a Map between the userDN (String) as the key and the account (String). 66 */ 67 Map retrieveAccountMap(); 68 69 /** 70 * Retrieves an account to user DN map, including null DNs, where empty strings are returned 71 * if the account is unassigned. 72 * 73 * @return a Map between the userDN (String) as the key and the account (String). 74 */ 75 Map retrieveReverseAccountMap(); 76 77 /** 78 * Retrieve the list of accounts not in use since the given date. 79 * 80 * @param date the time since the accounts haven't been used. 81 * @return a list of String with the accounts 82 */ 83 List retrieveUsersNotUsedSince(Date date); 84 85 /** 86 * Set when cache has been refreshed 87 * 88 * @param value 89 */ 90 void setNeedsCacheRefresh(boolean value); 91 92 /** 93 * Unassigns whatever user is assigned to this account from the account mapping 94 * and renders that account available to the pool. 95 * 96 * @param account that should be unassigned 97 */ 98 void unassignAccount(String account); 99 100 /** 101 * Removes user from the mapping, and renders it available to the pool. 102 * 103 * @param user the user that shouldn't be mapped anymore 104 */ 105 void unassignUser(String user); 106 }