KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > usermanager > JahiaUser


1 /*
2  * ____.
3  * __/\ ______| |__/\. _______
4  * __ .____| | \ | +----+ \
5  * _______| /--| | | - \ _ | : - \_________
6  * \\______: :---| : : | : | \________>
7  * |__\---\_____________:______: :____|____:_____\
8  * /_____|
9  *
10  * . . . i n j a h i a w e t r u s t . . .
11  *
12  *
13  *
14  * ----- BEGIN LICENSE BLOCK -----
15  * Version: JCSL 1.0
16  *
17  * The contents of this file are subject to the Jahia Community Source License
18  * 1.0 or later (the "License"); you may not use this file except in
19  * compliance with the License. You may obtain a copy of the License at
20  * http://www.jahia.org/license
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the rights, obligations and limitations governing use of the contents
25  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
26  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
27  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
28  *
29  * The Shared Modifications are Jahia View Helper.
30  *
31  * The Developer of the Shared Modifications is Jahia Solution S�rl.
32  * Portions created by the Initial Developer are Copyright (C) 2002 by the
33  * Initial Developer. All Rights Reserved.
34  *
35  * Contributor(s):
36  * 18-JAN-2001, Xo3 SA, Fulco Houkes
37  * 09-AUG-2003, Jahia Solutions Sarl, Fulco Houkes
38  *
39  * ----- END LICENSE BLOCK -----
40  */

41
42 package org.jahia.services.usermanager;
43
44
45 import java.io.Serializable JavaDoc;
46 import java.security.Principal JavaDoc;
47 import java.util.Properties JavaDoc;
48 import java.util.Vector JavaDoc;
49
50
51 /**
52  * A JahiaUser represents a physical person who is defined by a username and
53  * a password for authentification purpose. Every other property of a JahiaUser
54  * is stored in it's properties list, which hold key-value string pairs. For
55  * example email, firstname, lastname, ... information should be stored in this
56  * properties list.
57  *
58  * @author Fulco Houkes
59  * @author Khue Nguyen
60  * @version 2.2
61  */

62 public interface JahiaUser extends Principal JavaDoc, Serializable JavaDoc {
63
64     /**
65      * Return the unique user's username ( = his user key )
66      *
67      * @return Return a String representation of the user. In Jahia this
68      * corresponds to the user key, which is unique within a Jahia system.
69      */

70     public String JavaDoc getName ();
71
72     /**
73      * Return the user username.
74      *
75      * @return Return the username.
76      */

77     public String JavaDoc getUsername ();
78
79     /**
80      * Return the unique String identifier of this user.
81      *
82      * @return the unique String identifier of this user.
83      */

84     public String JavaDoc getUserKey ();
85
86     /**
87      * Return the id of the owner ( the site ) of this user.
88      *
89      * @return the id owner of this user.
90      */

91     public int getSiteID ();
92
93     /**
94      * Sets the id of the owner ( the site ) of this user.
95      *
96      * @param siteID the id owner of this user.
97      */

98     public void setSiteID (int siteID);
99
100     /**
101      * Returns the group's home page id.
102      * -1 : undefined
103      *
104      * @return int The group homepage id.
105      */

106     public abstract int getHomepageID ();
107
108     /**
109      * Set the home page id.
110      *
111      * @param id The group homepage id.
112      *
113      * @return false on error
114      */

115     public abstract boolean setHomepageID (int id);
116
117     /**
118      * Return a unique hashcode identifiying the user. The returned integer
119      * must be unique for each specific user. For exemple, two different users
120      * must return 2 different integer values, but two instanciation of the
121      * same user must return the same value.
122      *
123      * @return Return a valid hashcode integer of the user, on failure, -1 is
124      * returned.
125      */

126     public int hashCode ();
127
128
129     /**
130      * Get user's properties list.
131      * The properties here should not be modified, as the modifications will
132      * not be serialized. Use the setProperty() method to modify a user's
133      * properties.
134      * @return Return a reference on the user's properties list, or null if no
135      * property is present.
136      */

137     public Properties JavaDoc getProperties ();
138
139     /**
140      * Returns the users properties format, in which we can test if a property
141      * is read-only or not.
142      * The properties here should not be modified, as the modifications will
143      * not be serialized. Use the setProperty() method to modify a user's
144      * properties.
145      * @return UserProperties
146      */

147     public UserProperties getUserProperties();
148
149     /**
150      * Retrieve the requested user property.
151      *
152      * @param key Property's name.
153      *
154      * @return Return the property's value of the specified key, or null if the
155      * property does not exist.
156      */

157     public String JavaDoc getProperty (String JavaDoc key);
158
159     /**
160      * Retrieves the user property object, so that we can test is the property
161      * is read-only or not.
162      * @param key String
163      * @return UserProperty
164      */

165     public UserProperty getUserProperty(String JavaDoc key);
166
167     /**
168      * Remove the specified property from the properties list.
169      * This method can fail and do no modification is the property we are
170      * trying to set is read-only.
171      * @param key Property's name.
172      */

173     public boolean removeProperty (String JavaDoc key);
174
175
176     /**
177      * Add (or update if not already in the property list) a property key-value
178      * pair in the user's properties list.
179      * This method can fail and do no modification is the property we are
180      * trying to set is read-only.
181      * @param key Property's name.
182      * @param value Property's value.
183      */

184     public boolean setProperty (String JavaDoc key, String JavaDoc value);
185
186
187     /**
188      * Return a string representation of the user and it's internal state.
189      *
190      * @return A string representation of this user.
191      */

192     public abstract String JavaDoc toString ();
193
194
195     /**
196      * Compare this User to specified object. Return true if this user is the
197      * same as the object passed in.
198      *
199      * @param another Principal compare with.
200      *
201      * @return Return true if the passed in is the same as the encapsulated by this
202      * Principal, and false otherwise.
203      */

204     public boolean equals (Object JavaDoc another);
205
206
207     /**
208      * Method to test if the password is read-only
209      * @return boolean
210      */

211     public boolean isPasswordReadOnly();
212
213     /**
214      * Change the user's password.
215      *
216      * @param password New user's password
217      *
218      * @return Return true if the password was successfully changed, false
219      * otherwise
220      */

221     public boolean setPassword (String JavaDoc password);
222
223
224     /**
225      * Test if the user is member of the specified group.
226      *
227      * @param name Groupname.
228      *
229      * @return Return true if the user is member of the specified group, or
230      * false on any error.
231      */

232     public boolean isMemberOfGroup (int siteID, String JavaDoc name);
233
234
235     /**
236      * Test if the user is an admin member
237      *
238      * @return Return true if the user is an admin member
239      * false on any error.
240      */

241     public boolean isAdminMember (int siteID);
242
243     /**
244      * Test if the user is the root user
245      *
246      * @return Return true if the user is the root user
247      * false on any error.
248      */

249     public boolean isRoot ();
250
251     /**
252      * Verifiy if the passed in password is the same as the encapsulated by this
253      * user.
254      *
255      * @param password String representation of an non-encrypted password.
256      *
257      * @return Return true if the passed in password is the same as the
258      * encapsulated password in this user, and return false on any error.
259      */

260     public boolean verifyPassword (String JavaDoc password);
261
262     /**
263      * Retrieve a vector of language codes stored for this user. The order
264      * of these codes is important. The first language is the first choice, and
265      * as the list goes down so does the importance of the languages.
266      *
267      * @return a Vector containing String objects that contain language codes,
268      * the vector may be empty if this property was never set for the user.
269      */

270     public Vector JavaDoc getLanguageCodes ();
271
272     /**
273      * Sets the language codes for a user. This Vector contains String object
274      * that contain language codes. The order of this list is defined so as that
275      * the most important language is first.
276      *
277      * @param userLanguages a Vector of String object containing the language
278      * codes. The order is from the most important language first to the least
279      * important one last.
280      */

281     public void setLanguageCodes (Vector JavaDoc userLanguages);
282
283     /**
284      * Returns true if this user has activated the language mixing function
285      * of Jahia. This means that the content that will be displayed on his
286      * page will content multiple languages based on language preference list.
287      *
288      * @return true if the property is active.
289      */

290     public boolean isMixLanguagesActive ();
291
292     /**
293      * Sets the user property that indicates whether the user wants to see
294      * mixed language content in the pages he is browsing or not.
295      *
296      * @param mixLanguagesActive a boolean set to true to allow language mixing
297      */

298     public void setMixLanguagesActive (boolean mixLanguagesActive);
299
300     /**
301      * Returns true if the user has setup this property indicating that he
302      * doesn't want to default to any other languages than the ones he has
303      * setup in his users settings. This will shortcut defaulting to the
304      * browser and site settings.
305      *
306      * @return true if the user only wants to see the languages he has configured
307      * and never the ones configured in his browser or in the site settings.
308      */

309     public boolean isUserLanguagesOnlyActive ();
310
311     /**
312      * Sets the value indicating whether a user wants to fallback to browser
313      * or site setting languages. If set to true this means we are NOT falling
314      * back to the above mentioned settings.
315      *
316      * @param userLanguagesOnlyActive true means we are not falling back to
317      * browser or site settings.
318      */

319     public void setUserLanguagesOnlyActive (boolean userLanguagesOnlyActive);
320
321     /**
322      * Get the name of the provider of this user.
323      *
324      * @return String representation of the name of the provider of this user
325      */

326     public String JavaDoc getProviderName ();
327
328
329 }
330
Popular Tags