Source Code Cross Referenced for PermissionSet.java in  » Content-Management-System » contelligent » de » finix » contelligent » core » security » 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 » Content Management System » contelligent » de.finix.contelligent.core.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.core.security;
019:
020:        import java.io.Serializable;
021:        import java.security.acl.Permission;
022:        import java.util.Collection;
023:        import java.util.Iterator;
024:        import java.util.TreeSet;
025:
026:        /**
027:         * This class represents a set of Permissions. It makes it easy to build a UI
028:         * that would allow someone to add a group of Permissions to a Role. It wraps a
029:         * TreeSet object to enforce that only Permission objects are allowed in the set
030:         * and only relevant methods are available. TreeSet's contain only unique
031:         * Objects (no duplicates).
032:         */
033:        public class PermissionSet implements  Serializable {
034:            /** Set to hold the Permission Set */
035:            private TreeSet set;
036:
037:            /**
038:             * Constructs an empty PermissionSet
039:             */
040:            public PermissionSet() {
041:                set = new TreeSet();
042:            }
043:
044:            /**
045:             * Constructs a new PermissionSet with specifed contents.
046:             * 
047:             * If the given collection contains multiple objects that are identical WRT
048:             * equals() method, some objects will be overwriten.
049:             * 
050:             * @param permissions
051:             *            A collection of permissions to be contained in the set.
052:             */
053:            public PermissionSet(Collection permissions) {
054:                this ();
055:                add(permissions);
056:            }
057:
058:            /**
059:             * Adds a Permission to this PermissionSet.
060:             * 
061:             * @param permission
062:             *            A Permission.
063:             * @return True if Permission was added; false if PermissionSet already
064:             *         contained the Permission.
065:             */
066:            public boolean add(Permission permission) {
067:                return set.add((Object) permission);
068:            }
069:
070:            /**
071:             * Adds the Permissions in a Collection to this PermissionSet.
072:             * 
073:             * @param permissionSet
074:             *            A Collection of Permissions.
075:             * @return True if this PermissionSet changed as a result; false if no
076:             *         change to this PermissionSet occurred (this PermissionSet already
077:             *         contained all members of the added PermissionSet).
078:             */
079:            public boolean add(Collection permissions) {
080:                return set.addAll(permissions);
081:            }
082:
083:            /**
084:             * Adds the Permissions in another PermissionSet to this PermissionSet.
085:             * 
086:             * @param permissionSet
087:             *            A PermissionSet.
088:             * @return True if this PermissionSet changed as a result; false if no
089:             *         change to this PermissionSet occurred (this PermissionSet already
090:             *         contained all members of the added PermissionSet).
091:             */
092:            public boolean add(PermissionSet permissionSet) {
093:                return set.addAll((Collection) permissionSet.set);
094:            }
095:
096:            /**
097:             * Removes a Permission from this PermissionSet.
098:             * 
099:             * @param permission
100:             *            A Permission.
101:             * @return True if this PermissionSet contained the Permission before it was
102:             *         removed.
103:             */
104:            public boolean remove(Permission permission) {
105:                return set.remove((Object) permission);
106:            }
107:
108:            /**
109:             * Removes all Permissions from this PermissionSet.
110:             */
111:            public void clear() {
112:                set.clear();
113:            }
114:
115:            /**
116:             * Checks whether this PermissionSet contains a Permission.
117:             * 
118:             * @param permission
119:             *            A Permission.
120:             * @return True if this PermissionSet contains the Permission, false
121:             *         otherwise.
122:             */
123:            public boolean contains(Permission permission) {
124:                return set.contains((Object) permission);
125:            }
126:
127:            /**
128:             * Returns a Permission with the specified string representation, if it is
129:             * contained in this PermissionSet.
130:             * 
131:             * @param permissionString
132:             *            string representation of the Permission to find.
133:             * @return Permission if argument matched a Permission in this
134:             *         PermissionSet; null if no match.
135:             */
136:            public Permission getPermission(String permissionString) {
137:                if (permissionString != null) {
138:                    Iterator iter = set.iterator();
139:                    while (iter.hasNext()) {
140:                        Permission permission = (Permission) iter.next();
141:                        if (permissionString.equals(permission.toString())) {
142:                            return permission;
143:                        }
144:                    }
145:                }
146:                return null;
147:            }
148:
149:            /**
150:             * Returns an Permissions[] of Permissions in this PermissionSet.
151:             * 
152:             * @return A Permission[].
153:             */
154:            public Permission[] getPermissionsArray() {
155:                return (Permission[]) set.toArray(new Permission[0]);
156:            }
157:
158:            /**
159:             * Returns an Iterator for Permissions in this PermissionSet.
160:             */
161:            public Iterator elements() {
162:                return set.iterator();
163:            }
164:
165:            /**
166:             * Returns size (cardinality) of this set.
167:             * 
168:             * @return The cardinality of this PermissionSet.
169:             */
170:            public int size() {
171:                return set.size();
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.