View Javadoc

1   /*
2    * GroupAccountMapper.java
3    *
4    * Created on May 25, 2004, 2:10 PM
5    */
6   
7   package gov.bnl.gums.account;
8   
9   import javax.persistence.Entity;
10  import javax.persistence.Transient;
11  
12  import gov.bnl.gums.SiteUser;
13  import gov.bnl.gums.configuration.Configuration;
14  
15  import org.apache.log4j.Logger;
16  
17  
18  /** 
19   * An account mapping policy that maps all user to the same account.
20   * <p>
21   * To configure the policy one needs only to set the groupName property
22   * as the desired group account.
23   *
24   * @author Gabriele Carcassi, Jay Packard
25   */
26  @Entity
27  public class GroupAccountMapper extends AccountMapper {
28  	static private Logger log = Logger.getLogger(GroupAccountMapper.class);
29      
30  	// persistent variables
31  	private String accountName;
32      
33      public GroupAccountMapper() {
34      	super();
35      }
36      
37      public GroupAccountMapper(Configuration configuration, String name) {
38      	super(configuration, name);
39      }
40  	
41  	public void clearCachedItems() {
42  
43  	}
44      
45  	public String getAccountName() {
46  		return accountName;
47  	}    
48      
49      public SiteUser mapDn(String dn, boolean createIfDoesNotExist) {       
50          if (log.isDebugEnabled())
51              log.debug("User " + dn + " mapped to account " + accountName);
52          
53          return new SiteUser(accountName);
54      }
55  
56      @ConfigFieldAnnotation(label="Account", example="myAccount", help="the account to map to") 
57      public void setAccountName(String accountName) {
58      	if (this.accountName != null)
59      		log.debug("account name changed from  " + this.accountName + " to " + accountName);
60  		this.accountName = accountName;
61  	}
62  
63  }