Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jeteam/bean/security/PrivilegeBean.java


1   /*
2    * JETeam, Java Enterprise TeamWork
3    *
4    * Distributable under the GPL license.
5    * See terms of licence at http://www.gnu.org
6    *
7    * $Source: /cvsroot/jeteam/jeteam/jeteam-bcx/src/java/org/jeteam/bean/security/PrivilegeBean.java,v $
8    * $Date: 2003/05/28 22:07:48 $
9    * $Author: draftdog $
10   * $Revision: 1.12 $
11   */
12  package org.jeteam.bean.security;
13  
14  import javax.ejb.CreateException;
15  import javax.ejb.EntityBean;
16  import java.util.Collection;
17  
18  
19  /**
20   *
21   * <p>
22   *  A privilege represents an authorization for a certain action in
23   *  the system. It is represented by the permission attribute that
24   *  indicates what specific action is authorized.
25   * </p>
26   *
27   * <p>
28   *  There are two types of privileges:
29   * </p>
30   *
31   * <p>
32   *  1. First there are fine-grained privileges, these operate on the
33   *  level of a specific method call, for example the permission <b>
34   *  User.createUser </b> represents the authorization to create a new
35   *  user in the system.
36   * </p>
37   *
38   * <p>
39   *  2. Secondly there are coarse-grained privileges, these are the
40   *  ones that give authorization for a whole entity, for example the
41   *  permission <b> User </b> represents the authorization to have
42   *  full control over all user services as defined in the UserService
43   *  EJB.
44   * </p>
45   *
46   * <p>
47   *  The description is an optional piece of text that gives a little
48   *  more information about this privilige, however, most of the time
49   *  this will be left empty.
50   * </p>
51   *
52   * <p>
53   *  Privileges are typically assigned to roles, but it is not
54   *  mandatory to do so. However, when a privilege is not assigned to
55   *  a role it has no purpose in the system; the reason to allow a
56   *  privilege not to have any roles associated to it is pure for ease
57   *  of use in case you would like to prepare some priviliges do not
58   *  want to use them yet, this can be considered a business
59   *  requirement.
60   * </p>
61   *
62   * @ejb.bean
63   *     name="Privilege" type="CMP" cmp-version="2.x"
64   *     local-jndi-name="org.jeteam.bean.security/Privilege/LocalHome"
65   *     jndi-name="org.jeteam.bean.security/Privilege/Home"
66   *     view-type="local"
67   *     primkey-field="id"
68   * @ejb.interface
69   *     generate="local,remote"
70   *     remote-class="org.jeteam.bean.security.Privilege"
71   *     local-class="org.jeteam.bean.security.PrivilegeLocal"
72   * @ejb.home
73   *     generate="local"
74   *     local-class="org.jeteam.bean.security.PrivilegeLocalHome"
75   * @ejb.pk
76   *     generate="false"
77   *     class="java.lang.String"
78   * @ejb.finder
79   *     signature="org.jeteam.bean.security.PrivilegeLocal findByPrimaryKey(java.lang.String pk)"
80   *     unchecked="false"
81   *     role-name="Privilege,Privilege.findByPrimaryKey"
82   * @ejb.finder
83   *     signature="java.util.Collection findAll()"
84   *     unchecked="false"
85   *     role-name="Privilege,Privilege.findAll"
86   * @ejb.finder
87   *     signature="java.util.Collection findByPermission(java.lang.String permission)"
88   *     query="SELECT OBJECT(o) FROM Privilege o WHERE o.permission = ?1"
89   *     unchecked="false"
90   *     role-name="Privilege,Privilege.findByPermission"
91   * @ejb.util
92   *     generate="physical"
93   * @ejb.value-object
94   *     name="Privilege" match="*" instantiation="eager"
95   *
96   * @ejb.persistence
97   *     table-name="Privilege"
98   *
99   * @jboss.persistence
100  *     create-table="true"
101  *     remove-table="false"
102  *     tuned-updates="true"
103  *     read-only="false"
104  *
105  * @struts.form
106  *     name="Edit"
107  *     include-all="true"
108  *
109  * element.uuid    127-0-0-1-8a88a9:f38ae934f1:-7ff9
110  *
111  *
112  */
113 public abstract class PrivilegeBean implements EntityBean
114 {
115 
116    // --------------- attributes ---------------------
117 
118    /**
119     *
120     * @ejb.pk-field
121     * @ejb.persistence
122     *     column-name="ID"
123     *       jdbc-type="VARCHAR"
124     *        sql-type="VARCHAR(255)"
125     *
126     * @ejb.interface-method view-type="local"
127     * @ejb.transaction      type="Required"
128     * @ejb.permission
129     *     unchecked = "false"
130     *     role-name = "InternalUser"
131     */
132    public abstract java.lang.String getId();
133 
134    /**
135     * @ejb.interface-method view-type="local"
136     * @ejb.transaction      type="Required"
137     * @ejb.permission
138     *     unchecked = "false"
139     *     role-name = "InternalUser"
140     */
141    public abstract void setId(java.lang.String newValue);
142 
143 
144    /**
145     *
146     * @ejb.persistence
147     *     column-name="PERMISSION"
148     *       jdbc-type="VARCHAR"
149     *        sql-type="VARCHAR(255)"
150     *
151     * @ejb.interface-method view-type="local"
152     * @ejb.transaction      type="Required"
153     * @ejb.permission
154     *     unchecked = "false"
155     *     role-name = "InternalUser"
156     */
157    public abstract java.lang.String getPermission();
158 
159    /**
160     * @ejb.interface-method view-type="local"
161     * @ejb.transaction      type="Required"
162     * @ejb.permission
163     *     unchecked = "false"
164     *     role-name = "InternalUser"
165     */
166    public abstract void setPermission(java.lang.String newValue);
167 
168 
169    /**
170     *
171     * @ejb.persistence
172     *     column-name="DESCRIPTION"
173     *       jdbc-type="VARCHAR"
174     *        sql-type="VARCHAR(255)"
175     *
176     * @ejb.interface-method view-type="local"
177     * @ejb.transaction      type="Required"
178     * @ejb.permission
179     *     unchecked = "false"
180     *     role-name = "InternalUser"
181     */
182    public abstract java.lang.String getDescription();
183 
184    /**
185     * @ejb.interface-method view-type="local"
186     * @ejb.transaction      type="Required"
187     * @ejb.permission
188     *     unchecked = "false"
189     *     role-name = "InternalUser"
190     */
191    public abstract void setDescription(java.lang.String newValue);
192 
193 
194    // ------------- relations ------------------
195 
196    /**
197     *
198     * @ejb.interface-method view-type="local"
199     * @ejb.transaction      type="Required"
200     * @ejb.relation
201     *    name="privileges-roles"
202     *    role-name="privileges"
203     *
204     * @jboss.relation
205     *    related-pk-field="id"
206     *    fk-column="ROLES_FK"
207     * @jboss.relation-table
208     *    table-name="PRIVILEGES_ROLES"
209     * @weblogic.relation
210     *       join-table-name = "PRIVILEGES_ROLES"
211     *    foreign-key-column = "ROLES_FK"
212     * @resin-ejb.relation
213     *     sql-table = "PRIVILEGES_ROLES"
214     *    sql-column = "ROLES_FK"
215     * @ejb.permission
216     *     unchecked = "false"
217     *     role-name = "InternalUser"
218     */
219    public abstract Collection getRoles();
220 
221    /**
222     * @ejb.interface-method view-type="local"
223     * @ejb.transaction      type="Required"
224     * @ejb.permission
225     *     unchecked = "false"
226     *     role-name = "InternalUser"
227     */
228    public abstract void setRoles(Collection roles);
229 
230 
231 
232    // --------------- getter/setter for value objects ------------
233 
234    /**
235     * @ejb.interface-method view-type="local"
236     * @ejb.transaction      type="Required"
237     * @ejb.permission
238     *     unchecked = "false"
239     *     role-name = "InternalUser"
240     */
241 
242    public org.jeteam.bean.security.PrivilegeData getPrivilegeData()
243    {
244       org.jeteam.bean.security.PrivilegeData result = new org.jeteam.bean.security.PrivilegeData(getId(), getPermission(), getDescription());
245       return result;
246    }
247 
248    /**
249     * @ejb.interface-method view-type="local"
250     * @ejb.transaction      type="Required"
251     * @ejb.permission
252     *     unchecked = "false"
253     *     role-name = "InternalUser"
254     */
255    public void setPrivilegeData(org.jeteam.bean.security.PrivilegeData value)
256    {
257       setPermission(value.getPermission());
258       setDescription(value.getDescription());
259    }
260 
261    // ---------------- business methods  ----------------------
262 
263 
264    // ---------------- create methods with separate attributes --------------------
265 
266    /**
267     * @ejb.create-method
268     * @ejb.transaction type="Required"
269     * @ejb.permission
270     *     unchecked = "false"
271     *     role-name = "InternalUser"
272     */
273    public java.lang.String ejbCreate(java.lang.String permission, java.lang.String description)
274       throws CreateException
275    {
276       setPermission(permission);
277       setDescription(description);
278 
279       String primaryKey = PrivilegeUtil.generateGUID(this);
280       setId(primaryKey);
281       return null;  // should not return primaryKey for CMP: see EJB spec,
282       // chapter 10.5.2 "Bean Provider’s entity bean instance’s view"
283    }
284 
285    public void ejbPostCreate(java.lang.String permission, java.lang.String description)
286       throws CreateException
287    {
288    }
289 
290    // ---------------- create methods using value object --------------------
291 
292    /**
293     * @ejb.create-method
294     * @ejb.transaction type="Required"
295     * @ejb.permission
296     *     unchecked = "false"
297     *     role-name = "InternalUser"
298     */
299    public java.lang.String ejbCreate(org.jeteam.bean.security.PrivilegeData data)
300       throws CreateException
301    {
302       setPermission(data.getPermission());
303       setDescription(data.getDescription());
304 
305       String primaryKey = PrivilegeUtil.generateGUID(this);
306       setId(primaryKey);
307       return null;  // should not return primaryKey for CMP: see EJB spec,
308       // chapter 10.5.2 "Bean Provider’s entity bean instance’s view"
309    }
310 
311    public void ejbPostCreate(org.jeteam.bean.security.PrivilegeData data)
312       throws CreateException
313    {
314    }
315 
316    // ------------------------- remove method -------------------------------
317 
318    /**
319     * @ejb.transaction           type="Required"
320     * @ejb.permission
321     *     unchecked = "false"
322     *     role-name = "InternalUser"
323     */
324    public void ejbRemove() throws javax.ejb.RemoveException
325    {
326    }
327 
328 }