Source Code Cross Referenced for JGPermissionCollection.java in  » Authentication-Authorization » jguard » net » sf » jguard » core » authorization » permissions » 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 » Authentication Authorization » jguard » net.sf.jguard.core.authorization.permissions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        jGuard is a security framework based on top of jaas (java authentication and authorization security).
003:        it is written for web applications, to resolve simply, access control problems.
004:        version $Name$
005:        http://sourceforge.net/projects/jguard/
006:
007:        Copyright (C) 2004  Charles GAY
008:
009:        This library is free software; you can redistribute it and/or
010:        modify it under the terms of the GNU Lesser General Public
011:        License as published by the Free Software Foundation; either
012:        version 2.1 of the License, or (at your option) any later version.
013:
014:        This library is distributed in the hope that it will be useful,
015:        but WITHOUT ANY WARRANTY; without even the implied warranty of
016:        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:        Lesser General Public License for more details.
018:
019:        You should have received a copy of the GNU Lesser General Public
020:        License along with this library; if not, write to the Free Software
021:        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022:
023:
024:        jGuard project home page:
025:        http://sourceforge.net/projects/jguard/
026:
027:         */
028:        package net.sf.jguard.core.authorization.permissions;
029:
030:        import java.security.Permission;
031:        import java.security.PermissionCollection;
032:        import java.util.Collection;
033:        import java.util.Collections;
034:        import java.util.Enumeration;
035:        import java.util.HashSet;
036:        import java.util.Iterator;
037:        import java.util.Set;
038:        import java.util.logging.Logger;
039:
040:        /**
041:         * contains similar permissions.
042:         * this class contains similar <strong>java.security.Permission</strong> instances,
043:         *  with the same type.
044:         * it is a "technical" container in opposite to Domain,which is a "functional" container.
045:         * Classes extending this abstract class must implements implies method from PermissionCollection.
046:         * @author <a href="mailto:diabolo512@users.sourceforge.net ">Charles Gay</a>
047:         *
048:         */
049:        public abstract class JGPermissionCollection extends
050:                PermissionCollection {
051:
052:            /**
053:             * serial version id.
054:             */
055:            private static final long serialVersionUID = 3834030277143377201L;
056:            /** Logger for this class */
057:            private static final Logger logger = Logger
058:                    .getLogger(JGPermissionCollection.class.getName());
059:
060:            protected Set permissions;
061:
062:            /**
063:             * default constructor.
064:             *
065:             */
066:            public JGPermissionCollection() {
067:
068:                permissions = new HashSet();
069:            }
070:
071:            /**
072:             * constructor.
073:             * @param coll
074:             */
075:            public JGPermissionCollection(Collection coll) {
076:
077:                permissions = new HashSet(coll);
078:            }
079:
080:            /**
081:             * add a permission to the set.
082:             * @see java.security.PermissionCollection#add(java.security.Permission)
083:             */
084:            public void add(Permission permission) {
085:                permissions.add(permission);
086:
087:            }
088:
089:            /**
090:             * add permissions to the set.
091:             * @param permissionSet
092:             * @see java.security.PermissionCollection#add(java.security.Permission)
093:             */
094:            public void addAll(Set permissionSet) {
095:                permissions.addAll(permissionSet);
096:
097:            }
098:
099:            public void addAll(PermissionCollection pcColl) {
100:                Enumeration en = pcColl.elements();
101:                while (en.hasMoreElements()) {
102:                    permissions.add((Permission) en.nextElement());
103:                }
104:            }
105:
106:            /**
107:             * return all the permissions.
108:             * @see java.security.PermissionCollection#elements()
109:             */
110:            public Enumeration elements() {
111:                return Collections.enumeration(permissions);
112:
113:            }
114:
115:            /**
116:             * return the corresponding permission.
117:             * @param permissionName
118:             * @return permission
119:             * @throws NoSuchPermissionException
120:             */
121:            public Permission getPermission(String permissionName)
122:                    throws NoSuchPermissionException {
123:                Permission permission;
124:                Iterator it = permissions.iterator();
125:                while (it.hasNext()) {
126:                    permission = (Permission) it.next();
127:                    if (permission.getName().equals(permissionName)) {
128:                        return permission;
129:                    }
130:
131:                }
132:                logger
133:                        .warning("permission "
134:                                + permissionName
135:                                + " not found in JGPermissionCollection#getPermission!!!");
136:                logger.warning("permissions=" + permissions);
137:                throw new NoSuchPermissionException("permission "
138:                        + permissionName
139:                        + " not found in JGPermissionCollection#getPermission");
140:
141:            }
142:
143:            /**
144:             * remove permission from Permission's collection.
145:             * @param permission
146:             */
147:            public void removePermission(Permission permission) {
148:                permissions.remove(permission);
149:            }
150:
151:            /**
152:             * remove permission from Permission's collection.
153:             * @param permission
154:             */
155:            public void removePermissions(PermissionCollection permColl) {
156:                Enumeration permissionsEnum = permColl.elements();
157:                while (permissionsEnum.hasMoreElements()) {
158:                    permissions.remove((Permission) permissionsEnum
159:                            .nextElement());
160:                }
161:            }
162:
163:            /**
164:             * remove permission from Permission's collection.
165:             * @param permission
166:             */
167:            public void clear() {
168:                permissions.clear();
169:            }
170:
171:            public String toString() {
172:                StringBuffer sb = new StringBuffer();
173:                Iterator permissionsIterator = this .permissions.iterator();
174:                while (permissionsIterator.hasNext()) {
175:                    Permission permission = (Permission) permissionsIterator
176:                            .next();
177:                    sb.append(permission.toString());
178:                    sb.append("\n");
179:                }
180:                return sb.toString();
181:            }
182:
183:            /**
184:             *
185:             * @return permissions number owned by this JgPermissionCollection.
186:             */
187:            public int size() {
188:                return permissions.size();
189:            }
190:
191:            /**
192:             * @return Returns the permissions.
193:             */
194:            public Set getPermissions() {
195:                return permissions;
196:            }
197:
198:            /**
199:             *
200:             * @param permission
201:             * @return
202:             */
203:            public boolean containsPermission(Permission permission) {
204:                return permissions.contains(permission);
205:            }
206:
207:            /**
208:             * @param perms The permissions to set.
209:             */
210:            public void setPermissions(Set perms) {
211:
212:                this.permissions = perms;
213:            }
214:
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.