Source Code Cross Referenced for TorqueRole.java in  » Web-Framework » TURBINE » org » apache » turbine » services » security » torque » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » TURBINE » org.apache.turbine.services.security.torque 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.services.security.torque;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.Iterator;
023:
024:        import org.apache.turbine.om.security.Permission;
025:        import org.apache.turbine.om.security.Role;
026:        import org.apache.turbine.services.security.TurbineSecurity;
027:        import org.apache.turbine.util.security.PermissionSet;
028:        import org.apache.turbine.util.security.TurbineSecurityException;
029:
030:        import org.apache.torque.om.Persistent;
031:
032:        /**
033:         * This class represents a role played by the User associated with the
034:         * current Session. It is separated from the actual Torque peer object
035:         * to be able to replace the Peer with an user supplied Peer (and Object)
036:         *
037:         * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
038:         * @author <a href="mailto:jmcnally@collab.net">John D. McNally</a>
039:         * @author <a href="mailto:bmclaugh@algx.net">Brett McLaughlin</a>
040:         * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
041:         * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
042:         * @version $Id: TorqueRole.java 534527 2007-05-02 16:10:59Z tv $
043:         */
044:
045:        public class TorqueRole extends TorqueObject implements  Role,
046:                Comparable {
047:
048:            private static final long serialVersionUID = -7774684697021445523L;
049:
050:            /** The permissions for this role. */
051:            private PermissionSet permissionSet = null;
052:
053:            /**
054:             * Constructs a new Role
055:             */
056:            public TorqueRole() {
057:                super ();
058:            }
059:
060:            /**
061:             * Constructs a new Role with the specified name.
062:             *
063:             * @param name The name of the new object.
064:             */
065:            public TorqueRole(String name) {
066:                super (name);
067:            }
068:
069:            /**
070:             * The package private Constructor is used when the RolePeerManager
071:             * has retrieved a list of Database Objects from the peer and
072:             * must 'wrap' them into TorqueRole Objects. You should not use it directly!
073:             *
074:             * @param obj An Object from the peer
075:             */
076:            public TorqueRole(Persistent obj) {
077:                super (obj);
078:            }
079:
080:            /**
081:             * Returns the underlying Object for the Peer
082:             *
083:             * Used in the RolePeerManager when building a new Criteria.
084:             *
085:             * @return The underlying persistent object
086:             *
087:             */
088:
089:            public Persistent getPersistentObj() {
090:                if (obj == null) {
091:                    obj = RolePeerManager.newPersistentInstance();
092:                }
093:                return obj;
094:            }
095:
096:            /**
097:             * Returns the name of this role.
098:             *
099:             * @return The name of the role.
100:             */
101:            public String getName() {
102:                return RolePeerManager.getRoleName(getPersistentObj());
103:            }
104:
105:            /**
106:             * Sets the name of this Role
107:             *
108:             * @param name The name of the role.
109:             */
110:            public void setName(String name) {
111:                RolePeerManager.setRoleName(getPersistentObj(), name);
112:            }
113:
114:            /**
115:             * Gets the Id of this object
116:             *
117:             * @return The Id of the object
118:             */
119:            public int getId() {
120:                return RolePeerManager.getIdAsObj(getPersistentObj())
121:                        .intValue();
122:            }
123:
124:            /**
125:             * Gets the Id of this object
126:             *
127:             * @return The Id of the object
128:             */
129:            public Integer getIdAsObj() {
130:                return RolePeerManager.getIdAsObj(getPersistentObj());
131:            }
132:
133:            /**
134:             * Sets the Id of this object
135:             *
136:             * @param id The new Id
137:             */
138:            public void setId(int id) {
139:                RolePeerManager.setId(getPersistentObj(), id);
140:            }
141:
142:            /**
143:             * Returns the set of Permissions associated with this Role.
144:             *
145:             * @return A PermissionSet.
146:             *
147:             * @exception Exception a generic exception.
148:             */
149:            public PermissionSet getPermissions() throws Exception {
150:                return permissionSet;
151:            }
152:
153:            /**
154:             * Sets the Permissions associated with this Role.
155:             *
156:             * @param permissionSet A PermissionSet.
157:             */
158:            public void setPermissions(PermissionSet permissionSet) {
159:                this .permissionSet = permissionSet;
160:            }
161:
162:            // These following methods are wrappers around TurbineSecurity
163:
164:            /**
165:             * Creates a new Role in the system.
166:             *
167:             * @param name The name of the new Role.
168:             * @return An object representing the new Role.
169:             * @throws TurbineSecurityException if the Role could not be created.
170:             */
171:            public Role create(String name) throws TurbineSecurityException {
172:                return TurbineSecurity.createRole(name);
173:            }
174:
175:            /**
176:             * Makes changes made to the Role attributes permanent.
177:             *
178:             * @throws TurbineSecurityException if there is a problem while
179:             *  saving data.
180:             */
181:            public void save() throws TurbineSecurityException {
182:                TurbineSecurity.saveRole(this );
183:            }
184:
185:            /**
186:             * Removes a role from the system.
187:             *
188:             * @throws TurbineSecurityException if the Role could not be removed.
189:             */
190:            public void remove() throws TurbineSecurityException {
191:                TurbineSecurity.removeRole(this );
192:            }
193:
194:            /**
195:             * Renames the role.
196:             *
197:             * @param name The new Role name.
198:             * @throws TurbineSecurityException if the Role could not be renamed.
199:             */
200:            public void rename(String name) throws TurbineSecurityException {
201:                TurbineSecurity.renameRole(this , name);
202:            }
203:
204:            /**
205:             * Grants a Permission to this Role.
206:             *
207:             * @param permission A Permission.
208:             * @throws TurbineSecurityException if there is a problem while assigning
209:             * the Permission.
210:             */
211:            public void grant(Permission permission)
212:                    throws TurbineSecurityException {
213:                TurbineSecurity.grant(this , permission);
214:            }
215:
216:            /**
217:             * Grants Permissions from a PermissionSet to this Role.
218:             *
219:             * @param permissionSet A PermissionSet.
220:             * @throws TurbineSecurityException if there is a problem while assigning
221:             * the Permissions.
222:             */
223:            public void grant(PermissionSet permissionSet)
224:                    throws TurbineSecurityException {
225:                Iterator permissions = permissionSet.iterator();
226:                while (permissions.hasNext()) {
227:                    TurbineSecurity
228:                            .grant(this , (Permission) permissions.next());
229:                }
230:            }
231:
232:            /**
233:             * Revokes a Permission from this Role.
234:             *
235:             * @param permission A Permission.
236:             * @throws TurbineSecurityException if there is a problem while unassigning
237:             * the Permission.
238:             */
239:            public void revoke(Permission permission)
240:                    throws TurbineSecurityException {
241:                TurbineSecurity.revoke(this , permission);
242:            }
243:
244:            /**
245:             * Revokes Permissions from a PermissionSet from this Role.
246:             *
247:             * @param permissionSet A PermissionSet.
248:             * @throws TurbineSecurityException if there is a problem while unassigning
249:             * the Permissions.
250:             */
251:            public void revoke(PermissionSet permissionSet)
252:                    throws TurbineSecurityException {
253:                Iterator permissions = permissionSet.iterator();
254:                while (permissions.hasNext()) {
255:                    TurbineSecurity.revoke(this , (Permission) permissions
256:                            .next());
257:                }
258:            }
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.