001: /**
002: * Copyright (C) 2001 Yasna.com. All rights reserved.
003: *
004: * ===================================================================
005: * The Apache Software License, Version 1.1
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions
009: * are met:
010: *
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The end-user documentation included with the redistribution,
020: * if any, must include the following acknowledgment:
021: * "This product includes software developed by
022: * Yasna.com (http://www.yasna.com)."
023: * Alternately, this acknowledgment may appear in the software itself,
024: * if and wherever such third-party acknowledgments normally appear.
025: *
026: * 4. The names "Yazd" and "Yasna.com" must not be used to
027: * endorse or promote products derived from this software without
028: * prior written permission. For written permission, please
029: * contact yazd@yasna.com.
030: *
031: * 5. Products derived from this software may not be called "Yazd",
032: * nor may "Yazd" appear in their name, without prior written
033: * permission of Yasna.com.
034: *
035: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038: * DISCLAIMED. IN NO EVENT SHALL YASNA.COM OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046: * SUCH DAMAGE.
047: * ====================================================================
048: *
049: * This software consists of voluntary contributions made by many
050: * individuals on behalf of Yasna.com. For more information
051: * on Yasna.com, please see <http://www.yasna.com>.
052: */
053:
054: /**
055: * Copyright (C) 2000 CoolServlets.com. All rights reserved.
056: *
057: * ===================================================================
058: * The Apache Software License, Version 1.1
059: *
060: * Redistribution and use in source and binary forms, with or without
061: * modification, are permitted provided that the following conditions
062: * are met:
063: *
064: * 1. Redistributions of source code must retain the above copyright
065: * notice, this list of conditions and the following disclaimer.
066: *
067: * 2. Redistributions in binary form must reproduce the above copyright
068: * notice, this list of conditions and the following disclaimer in
069: * the documentation and/or other materials provided with the
070: * distribution.
071: *
072: * 3. The end-user documentation included with the redistribution,
073: * if any, must include the following acknowledgment:
074: * "This product includes software developed by
075: * CoolServlets.com (http://www.coolservlets.com)."
076: * Alternately, this acknowledgment may appear in the software itself,
077: * if and wherever such third-party acknowledgments normally appear.
078: *
079: * 4. The names "Jive" and "CoolServlets.com" must not be used to
080: * endorse or promote products derived from this software without
081: * prior written permission. For written permission, please
082: * contact webmaster@coolservlets.com.
083: *
084: * 5. Products derived from this software may not be called "Jive",
085: * nor may "Jive" appear in their name, without prior written
086: * permission of CoolServlets.com.
087: *
088: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
089: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
090: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
091: * DISCLAIMED. IN NO EVENT SHALL COOLSERVLETS.COM OR
092: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
093: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
094: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
095: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
096: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
097: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
098: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
099: * SUCH DAMAGE.
100: * ====================================================================
101: *
102: * This software consists of voluntary contributions made by many
103: * individuals on behalf of CoolServlets.com. For more information
104: * on CoolServlets.com, please see <http://www.coolservlets.com>.
105: */package com.Yasna.forum;
106:
107: import java.util.*;
108:
109: /**
110: * Organizes Users into a group for easier permissions management at the
111: * Forum level. In this way, Groups essentially serve the same purpose that
112: * they do in Unix or Windows.<p>
113: *
114: * For example, CREATE_THREAD permissions can be set per forum. A forum
115: * administrator may wish to create a "Thread Posters" group that has
116: * CREATE_THREAD permissions in the forum. Then, users can be added to that
117: * group and will automatically receive CREATE_THREAD permissions in that forum.
118: * <p>
119: *
120: * Security for Group objects is provide by GroupProxy protection proxy objects.
121: *
122: * @see User
123: */
124: public interface Group {
125:
126: /**
127: * Returns the id of the group.
128: *
129: * @return the id of the group.
130: */
131: public int getID();
132:
133: /**
134: * Returns the name of the group. For example, 'XYZ Admins'.
135: *
136: * @return the name of the group.
137: */
138: public String getName();
139:
140: /**
141: * Sets the name of the group. For example, 'XYZ Admins'.<p>
142: *
143: * This method is restricted to those with group administration permission.
144: *
145: * @param name the name for the group.
146: * @throws UnauthorizedException if does not have group admin permissions.
147: */
148: public void setName(String name) throws UnauthorizedException;
149:
150: /**
151: * Returns the description of the group. The description often summarizes
152: * a group's function, such as 'Administrators of the XYZ forum'.
153: *
154: * @return the description of the group.
155: */
156: public String getDescription();
157:
158: /**
159: * This method returns true if the group has automatic membership. If Automatic membership
160: * is turned on, any new member will automatically become a member of that group, and will inherit
161: * the permissions for that group too.
162: * @return
163: */
164: public boolean getAutoGroupMembership();
165:
166: /**
167: * this method sets the automatic membership of the group.
168: * this method is restricted to thos with group administration permission.
169: * @param param
170: */
171: public void setAutoGroupMembership(boolean param)
172: throws UnauthorizedException;
173:
174: /**
175: * Sets the description of the group.
176: *
177: * The description often summarizes a group's function, such as
178: * 'Administrators of the XYZ forum'.<p>
179: *
180: * This method is restricted to those with group administration permission.
181: *
182: * @param name the description of the group.
183: * @throws UnauthorizedException if does not have group admin permissions.
184: */
185: public void setDescription(String description)
186: throws UnauthorizedException;
187:
188: /**
189: * Grants administrator privileges of the group to a user.<p>
190: *
191: * This method is restricted to those with group administration permission.
192: *
193: * @param user the User to grant adminstrative privileges to.
194: * @throws UnauthorizedException if does not have group admin permissions.
195: */
196: public void addAdministrator(User user)
197: throws UnauthorizedException;
198:
199: /**
200: * Revokes administrator privileges of the group to a user.<p>
201: *
202: * This method is restricted to those with group administration permission.
203: *
204: * @param user the User to grant adminstrative privileges to.
205: * @throws UnauthorizedException if does not have group admin permissions.
206: */
207: public void removeAdministrator(User user)
208: throws UnauthorizedException;
209:
210: /**
211: * Adds a member to the group.<p>
212: *
213: * This method is restricted to those with group administration permission.
214: *
215: * @param user the User to add to the group.
216: * @throws UnauthorizedException if does not have group admin permissions.
217: */
218: public void addMember(User user) throws UnauthorizedException;
219:
220: /**
221: * Removes a member from the group. If the User is not in the group, this
222: * method does nothing.<p>
223: *
224: * This method is restricted to those with group administration permission.
225: *
226: * @param user the User to remove from the group.
227: * @throws UnauthorizedException if does not have group admin permissions.
228: */
229: public void removeMember(User user) throws UnauthorizedException;
230:
231: /**
232: * Returns true if the User has group administrator permissions. Group
233: * administrators are also considered to be members.
234: *
235: * @return true if the User is an administrator of the group.
236: */
237: public boolean isAdministrator(User user);
238:
239: /**
240: * Returns true if if the User is a member of the group.
241: *
242: * @return true if the User is a member of the group.
243: */
244: public boolean isMember(User user);
245:
246: /**
247: * Returns the number of group administrators.
248: *
249: * @return the number of group administrators.
250: */
251: public int getAdministratorCount();
252:
253: /**
254: * Returns the number of group members.
255: *
256: * @return the number of group members.
257: */
258: public int getMemberCount();
259:
260: /**
261: * An iterator for all the users that are members of the group.
262: *
263: * @return an Iterator for all members of the group.
264: */
265: public Iterator members();
266:
267: /**
268: * An iterator for all the users that are administrators of the group.
269: *
270: * @return an Iterator for all administrators of the group.
271: */
272: public Iterator administrators();
273:
274: /**
275: * Returns the permissions for the group that correspond to the
276: * passed-in Authorization.
277: *
278: * @param authorization the auth token to lookup permissions for.
279: */
280: public abstract ForumPermissions getPermissions(
281: Authorization authorization);
282:
283: /**
284: * Returns true if the handle on the object has the permission specified.
285: * A list of possible permissions can be found in the ForumPermissions
286: * class. Certain methods of this class are restricted to certain
287: * permissions as specified in the method comments.
288: *
289: * @param type a permission type.
290: * @return true if the specified permission is valid.
291: * @see ForumPermissions
292: */
293: public boolean hasPermission(int type);
294: }
|