Source Code Cross Referenced for Domain.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.io.Serializable;
031:        import java.security.Permission;
032:        import java.security.PermissionCollection;
033:        import java.util.HashSet;
034:        import java.util.Iterator;
035:        import java.util.Set;
036:
037:        /**
038:         * regroups Permissions (in a 'functional' way) as a JGPositivePermissionCollection
039:         *  (additive mechanism).it differs from JGPermissionCollection 
040:         *  which regroups Permission in a technical way, by owning a name which
041:         *  refers to functional resources.
042:         * @author <a href="mailto:diabolo512@users.sourceforge.net">Charles Gay</a>
043:         *
044:         */
045:        public class Domain extends JGPermissionCollection implements 
046:                Comparable, Cloneable, Serializable {
047:
048:            private static final long serialVersionUID = 178066544850786962L;
049:
050:            private String name;
051:
052:            public Domain(String domainName) {
053:                super ();
054:                name = domainName;
055:            }
056:
057:            public Domain(String domainName, PermissionCollection pcoll) {
058:                name = domainName;
059:                permissions = new HashSet();
060:                super .addAll(pcoll);
061:            }
062:
063:            /**
064:             * @return Returns the domainName.
065:             */
066:            public String getName() {
067:                return name;
068:            }
069:
070:            /**
071:             * @param domainName The domainName to set.
072:             */
073:            public void setName(String domainName) {
074:
075:                this .name = domainName;
076:            }
077:
078:            /**
079:             * override the <i>equals</i> method inherited from Object.
080:             * @param obj an Domain
081:             * @return true if equals, false otherwise
082:             */
083:            public boolean equals(Object obj) {
084:                Domain domain = (Domain) obj;
085:                if (this .name.equals(domain.getName())) {
086:                    return true;
087:                }
088:                return false;
089:            }
090:
091:            /**
092:             * methode used to accelerate the comparation process:
093:             *  useful when hashcode return different int.
094:             *  it uses hashcode of the name.
095:             * @return hashcode
096:             */
097:            public int hashCode() {
098:                return name.toString().hashCode();
099:            }
100:
101:            /**
102:             * override the java.lang.Object 's <i>clone</i> method.
103:             * @return new Domain
104:             */
105:            public Object clone() throws CloneNotSupportedException {
106:                JGPermissionCollection dom = new Domain(new String(this .name));
107:                Set perms = new HashSet();
108:                Iterator itPermissions = permissions.iterator();
109:                while (itPermissions.hasNext()) {
110:                    Permission perm = (Permission) itPermissions.next();
111:                    String permName = perm.getName();
112:                    String permActions = perm.getActions();
113:                    Class permClass = perm.getClass();
114:                    Permission newPerm;
115:                    try {
116:                        newPerm = PermissionUtils.getPermission(permClass
117:                                .getName(), permName, permActions);
118:                    } catch (ClassNotFoundException e) {
119:                        throw new CloneNotSupportedException(e.getMessage());
120:                    }
121:                    perms.add(newPerm);
122:                }
123:                dom.setPermissions(perms);
124:                return dom;
125:            }
126:
127:            /**
128:             * compare name with the name of the specified object for order.
129:             * @param o the Domain to compare
130:             * @see java.lang.Comparable#compareTo(java.lang.Object)
131:             */
132:            public int compareTo(Object o) {
133:                Domain domain = (Domain) o;
134:                return this .name.compareTo(domain.getName());
135:            }
136:
137:            /**
138:             * convert object into a string representation.
139:             * @return string representation
140:             */
141:            public String toString() {
142:                StringBuffer sb = new StringBuffer();
143:                sb.append("\n");
144:                sb.append(" name=" + name);
145:                sb.append("\n");
146:                sb.append(" permissions=\n" + super .toString());
147:                sb.append("\n");
148:                return sb.toString();
149:            }
150:
151:            public boolean implies(Permission permission) {
152:                Iterator it = permissions.iterator();
153:                Permission p;
154:
155:                while (it.hasNext()) {
156:                    p = (Permission) it.next();
157:                    if (p.implies(permission)) {
158:                        return true;
159:                    }
160:                }
161:                return false;
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.