View Javadoc

1   /*
2    * ManualAccountMapper.java
3    *
4    * Created on May 25, 2004, 5:06 PM
5    */
6   
7   package gov.bnl.gums;
8   
9   /*** An account mapping policy that looks at a stored table to determine the
10   * account. The database implementation is an abstract interface, which
11   * allows the mapping to be persistent on different mediums (i.e. database,
12   * LDAP, file, ...)
13   * <p>
14   * This class will provide also configurable data caching.
15   *
16   * @author  Gabriele Carcassi
17   */
18  public class ManualAccountMapper implements AccountMapper {
19      
20      private ManualAccountMapperDB db;
21      private String name;
22      private PersistenceFactory persistanceFactory;
23      
24      public String mapUser(String userDN) {
25          return db.retrieveMapping(userDN);
26      }
27      
28      public void createMapping(String userDN, String account) {
29          db.createMapping(userDN, account);
30      }
31      
32      public boolean removeMapping(String userDN) {
33          return db.removeMapping(userDN);
34      }
35      
36      public String getName() {
37          return name;
38      }
39      
40      public String getPersistenceFactory() {
41          return persistanceFactory.getName();
42      }
43      
44      public void setPersistence(PersistenceFactory persistanceFactory, String name) {
45          this.persistanceFactory = persistanceFactory;
46          this.name = name;
47          db = persistanceFactory.retrieveManualAccountMapperDB(name);
48      }
49      
50  }