View Javadoc

1   /*
2    * AccountMapper.java
3    *
4    * Created on March 30, 2004, 5:56 PM
5    */
6   
7   package gov.bnl.gums.account;
8   
9   import gov.bnl.gums.configuration.Configuration;
10  
11  /** 
12   * Defines the logic with which a user will be mapped to a local account.
13   * As of now, the logic is a simple certificate subject mapped to a user
14   * account. In the future this interface will be extended to map the credential
15   * of a full proxy (DN, vo, role, group) to a user and group account.
16   *
17   * @author  Gabriele Carcassi, Jay Packard
18   */
19  public abstract class AccountMapper {
20      /**
21       * @return user friendly string representation of the property type called statically 
22       */
23  	static public String getTypeStatic() {
24  		return "abstract";
25  	}
26  	
27  	private String name = "";
28  	private String description = "";
29  	private Configuration configuration = null;
30  	
31  	/**
32  	 * Create an account mapper object - empty constructor needed by XML Digestor
33  	 */
34  	public AccountMapper() {
35      }
36   
37  	/**
38  	 * Create an account mapper object with a given configuration
39  	 * 
40  	 * @param configuration
41  	 */
42  	public AccountMapper(Configuration configuration) {
43      	this.configuration = configuration;
44      }
45  	
46  	/**
47  	 * Create an account mapper object with a given configuration and name
48  	 * 
49  	 * @param configuration
50  	 * @param name
51  	 */
52  	public AccountMapper(Configuration configuration, String name) {
53      	this.configuration = configuration;
54      	this.name = name;
55      }
56      
57  	/**
58  	 * Create a clone of itself
59  	 * 
60  	 * @param configuration
61  	 * @return
62  	 */
63  	public abstract AccountMapper clone(Configuration configuration);
64  
65  	/**
66  	 * @return Configuration object
67  	 */
68  	public Configuration getConfiguration() {
69  		return configuration;
70  	}
71  	
72  	/**
73  	 * @return description as string
74  	 */
75  	public String getDescription() {
76  		return description;
77  	}
78  	
79  	/**
80  	 * @return name as string
81  	 */
82  	public String getName() {
83  		return name;
84  	}
85  	
86  	/**
87  	 * @return string representation of type of account mapper
88  	 */
89  	public String getType() {
90  		return "abstract";
91  	}
92  	
93  	/**
94       * Maps a grid identity to a local account name.
95       * @param userDN the certificate DN (i.e. '/DC=org/DC=doegrids/OU=People/CN=John Smith').
96       * @return a user account (i.e. 'atlas').
97       */
98      public abstract String mapUser(String userDN, boolean createNew);
99  
100     /**
101      * @param configuration
102      */
103     public void setConfiguration(Configuration configuration) {
104 		this.configuration = configuration;
105 	}
106 	
107     /**
108      * @param name
109      */
110     public void setName(String name) {
111 		this.name = name;
112 	}
113     
114     /**
115      * @param description
116      */
117     public void setDescription(String description) {
118     	this.description = description;
119     }
120 
121     /**
122      * Get string representation of this object for displaying in the 
123      * diagnostic summary web page
124      * 
125      * @param bgColor back ground color
126      * @return
127      */
128     public abstract String toString(String bgColor);
129     
130     /**
131      * Get XML representation of this object for writing to gums.config
132      * 
133      * @return xml as string
134      */
135     public abstract String toXML();
136 }