KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > admin > security > right > SecurityRightsBean


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: SecurityRightsBean.java,v $
31  * Revision 1.3 2005/04/10 19:55:43 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:04 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:50:44 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.5 2004/11/12 15:56:45 colinmacleod
45  * Removed dependencies on SSLEXT.
46  * Moved Persistence classes to ivata masks.
47  *
48  * Revision 1.4 2004/07/13 19:41:11 colinmacleod
49  * Moved project to POJOs from EJBs.
50  * Applied PicoContainer to services layer (replacing session EJBs).
51  * Applied Hibernate to persistence layer (replacing entity EJBs).
52  *
53  * Revision 1.2 2004/02/01 22:00:31 colinmacleod
54  * Added full names to author tags
55  *
56  * Revision 1.1.1.1 2004/01/27 20:57:45 colinmacleod
57  * Moved open portal to sourceforge.
58  *
59  * Revision 1.8 2003/11/03 11:28:24 jano
60  * commiting addressbook,
61  * tryinjg to fix deploying problem
62  *
63  * Revision 1.7 2003/10/17 12:36:12 jano
64  * fixing problems with building
65  * converting intranet -> portal
66  * Eclipse building
67  *
68  * Revision 1.6 2003/10/16 07:53:32 jano
69  * fixing XDoclet
70  *
71  * Revision 1.5 2003/10/15 12:51:43 colin
72  * fixing with XDoclet
73  *
74  * Revision 1.4 2003/10/15 12:48:32 jano
75  * goning to 1.1
76  *
77  * Revision 1.1.1.1 2003/10/13 20:50:06 colin
78  * Restructured portal into subprojects
79  *
80  * Revision 1.4 2003/08/21 09:48:59 jano
81  * user has rights to add/amend/remove another user if he can
82  * add/amend/remove in "everyone" user group
83  *
84  * Revision 1.3 2003/08/19 15:02:42 jano
85  * fixing users & rights popup window
86  *
87  * Revision 1.2 2003/05/02 16:25:11 peter
88  * only administrators can handle users now
89  *
90  * Revision 1.1 2003/02/24 18:53:57 colin
91  * added to admin
92  *
93  * Revision 1.5 2003/02/04 17:43:50 colin
94  * copyright notice
95  *
96  * Revision 1.4 2003/01/03 17:17:21 jano
97  * fixing findr problem in canUser
98  *
99  * Revision 1.3 2003/01/02 16:40:29 jano
100  * taking VIEW of
101  *
102  * Revision 1.2 2002/12/16 13:42:18 jano
103  * finder and collection problem
104  *
105  * Revision 1.1 2002/09/09 08:35:24 colin
106  * new security EJB takes over role of
107  * logging into the system
108  * maintaining user names and passwords
109  * -----------------------------------------------------------------------------
110  */

111 package com.ivata.groupware.admin.security.right;
112
113
114 import javax.ejb.CreateException JavaDoc;
115 import javax.ejb.RemoveException JavaDoc;
116 import javax.ejb.SessionBean JavaDoc;
117 import javax.ejb.SessionContext JavaDoc;
118
119 import org.picocontainer.PicoContainer;
120
121 import com.ivata.groupware.admin.security.server.SecuritySession;
122 import com.ivata.groupware.container.PicoContainerFactory;
123 import com.ivata.mask.util.SystemException;
124
125
126 /**
127  * <p>Security rights determine what each user can and cannot do within the
128  * security subsystem. If you need to know where a user has sufficient rights
129  * to add, change or remove another user, then this is the class to tell you.</p>
130  *
131  *
132  * @since 2002-09-08
133  * @author Colin MacLeod
134  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
135  * @version $Revision: 1.3 $
136  *
137  * @ejb.bean
138  * name="SecurityRights"
139  * display-name="SecurityRights"
140  * type="Stateless"
141  * view-type="both"
142  * local-jndi-name = "SecurityRightsLocal"
143  * jndi-name="SecurityRightsRemote"
144  *
145  * @ejb.transaction
146  * type = "Required"
147  *
148  * @ejb.home
149  * generate="false"
150  * remote-class="com.ivata.groupware.admin.security.right.SecurityRightsRemoteHome"
151  *
152  * @ejb.interface
153  * remote-class="com.ivata.groupware.admin.security.right.SecurityRightsRemote"
154  */

155 public class SecurityRightsBean implements SessionBean JavaDoc {
156
157     /**
158      * <p>Provides the session bean with container-specific information.</p>
159      */

160     SessionContext JavaDoc sessionContext;
161
162     /**
163      * <p>See if a user has sufficient rights to add user to the system - it's meen to everyOne group.</p>
164      *
165      * @param userName the user who wants to add another user.
166      * @param personId the unique identifier of the person who will be added.
167      * @return <code>true</code> if this action is authorized by the system,
168      * otherwise <code>false</code>.
169      *
170      * @ejb.interface-method
171      * view-type = "both"
172      */

173     public boolean canAddUser(final SecuritySession securitySession)
174             throws SystemException {
175         return getSecurityRights().canAddUser(securitySession);
176     }
177
178     /**
179      * <p>See if a user has sufficient rights to amend user in the
180      * system - it's meen in everyone group.</p>
181      *
182      * @param userName the user who wants to add another user.
183      * @param userNameAmend the user who should be amended.
184      * @return <code>true</code> if this action is authorized by the system,
185      * otherwise <code>false</code>.
186      *
187      * @ejb.interface-method
188      * view-type = "both"
189      */

190     public boolean canAmendUser(final SecuritySession securitySession)
191             throws SystemException {
192         return getSecurityRights().canAmendUser(securitySession);
193     }
194
195     /**
196      * <p>See if a user has sufficient rights to remove user from the
197      * system - it's meen from everone group.</p>
198      *
199      * @param userName the user who wants to add another user.
200      * @param userNameRemove the user who should be removed.
201      * @return <code>true</code> if this action is authorized by the system,
202      * otherwise <code>false</code>.
203      *
204      * @ejb.interface-method
205      * view-type = "both"
206      */

207     public boolean canRemoveUser(final SecuritySession securitySession)
208             throws SystemException {
209         return getSecurityRights().canRemoveUser(securitySession);
210     }
211
212     /**
213      * <p>Internal helper method. Find out if a user is allowed to access
214      * entries in a given group.</p>
215      *
216      * @param userName the name of the user to check the user rights for.
217      * @param groupId the unique identifier of the group to check.
218      * @param access the access level as defined in {@link
219      * com.ivata.groupware.security.person.group.right.RightConstants
220      * RightConstants}.
221      * @return <code>true</code> if the user is entitled to access entries in the
222      * group, otherwise <code>false</code>.
223      */

224     public boolean canUser(final SecuritySession securitySession,
225             final Integer JavaDoc access)
226             throws SystemException {
227         return getSecurityRights().canUser(securitySession, access);
228     }
229
230     /**
231      * <p>Called by the container to notify an entity object it has been
232      * activated.</p>
233      */

234     public void ejbActivate() {}
235
236     /**
237      * <p>Called by the container just after the bean has been created.</p>
238      *
239      * @exception CreateException if any error occurs. Never thrown by this
240      * class.
241      *
242      * @ejb.create-method
243      */

244     public void ejbCreate() throws CreateException JavaDoc {}
245
246     /**
247      * <p>Called by the container to notify the entity object it will be
248      * deactivated. Called just before deactivation.</p>
249      */

250     public void ejbPassivate() {}
251
252     /**
253      * <p>This method is called by the container when the bean is about
254      * to be removed.</p>
255      *
256      * <p>This method will be called after a client calls the <code>remove</code>
257      * method of the remote/local home interface.</p>
258      *
259      * @throws RemoveException if any error occurs. Currently never thrown by
260      * this class.
261      */

262     public void ejbRemove() {}
263     /**
264      * Get the addressbook implementation from the <code>PicoContainer</code>.
265      */

266     private SecurityRights getSecurityRights() throws SystemException {
267         PicoContainer container = PicoContainerFactory.getInstance()
268             .getGlobalContainer();
269         return (SecurityRights) container.getComponentInstance(SecurityRights.class);
270     }
271
272     /**
273      * <p>Set up the context for this entity object. The session bean stores the
274      * context for later use.</p>
275      *
276      * @param sessionContext the new context which the session object should
277      * store.
278      */

279     public final void setSessionContext(final SessionContext JavaDoc sessionContext) {
280         this.sessionContext = sessionContext;
281     }
282 }
283
Popular Tags