Source Code Cross Referenced for Permission.java in  » Web-Framework » argun » biz » hammurapi » web » 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 » Web Framework » argun » biz.hammurapi.web.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * argun 1.0
003:         * Web 2.0 delivery framework 
004:         * Copyright (C) 2007  Hammurapi Group
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2 of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         *
020:         * URL: http://www.hammurapi.biz
021:         * e-Mail: support@hammurapi.biz
022:         */
023:        package biz.hammurapi.web.security;
024:
025:        import java.sql.ResultSet;
026:        import java.sql.SQLException;
027:        import java.util.ArrayList;
028:        import java.util.Collection;
029:        import java.util.Iterator;
030:        import java.util.Properties;
031:
032:        import org.apache.xpath.CachedXPathAPI;
033:        import org.w3c.dom.Element;
034:
035:        import biz.hammurapi.config.ConfigurationException;
036:        import biz.hammurapi.sql.DataAccessObject;
037:        import biz.hammurapi.sql.RowProcessor;
038:        import biz.hammurapi.sql.SQLProcessor;
039:        import biz.hammurapi.web.security.sql.AssignedPermissionImpl;
040:        import biz.hammurapi.web.security.sql.SecurityEngine;
041:        import biz.hammurapi.xml.dom.DOMUtils;
042:
043:        /**
044:         * This class overrides equality - it uses class name and action name instead of "helper" permission id.
045:         * @author Pavel Vlasov
046:         * @revision $Revision$
047:         */
048:        public class Permission extends AssignedPermissionImpl implements 
049:                DataAccessObject {
050:
051:            /**
052:             * 
053:             */
054:            public Permission() {
055:                // Default constructor
056:            }
057:
058:            public Permission(String className, String action) {
059:                setClassName(className);
060:                setActionName(action);
061:            }
062:
063:            public int hashCode() {
064:                return getClass().hashCode() ^ getActionName().hashCode();
065:            }
066:
067:            public boolean equals(Object obj) {
068:                if (obj == this ) {
069:                    return true;
070:                }
071:
072:                if (obj instanceof  Permission) {
073:                    Permission op = (Permission) obj;
074:                    return getClassName().equals(op.getClassName())
075:                            && getActionName().equals(op.getActionName());
076:                }
077:
078:                return false;
079:            }
080:
081:            private Collection impliedPermissions = new ArrayList();
082:
083:            /**
084:             * @param className
085:             * @param actionName
086:             * @return True if permission for given class and action is granted by this permission or permissions
087:             * implied by this permission.
088:             */
089:            public Boolean isGranted(String className, String actionName) {
090:                if (isImplied(className, actionName)) {
091:                    return getIsDenied() ? Boolean.FALSE : Boolean.TRUE;
092:                }
093:
094:                return null;
095:            }
096:
097:            private boolean isImplied(String className, String actionName) {
098:                if (getClassName().equals(className)
099:                        && getActionName().equals(actionName)) {
100:                    return true;
101:                }
102:
103:                Iterator it = impliedPermissions.iterator();
104:                while (it.hasNext()) {
105:                    if (((Permission) it.next()).isImplied(className,
106:                            actionName)) {
107:                        return true;
108:                    }
109:                }
110:
111:                return false;
112:            }
113:
114:            /**
115:             * @param force
116:             */
117:            public Permission(boolean force) {
118:                super (force);
119:            }
120:
121:            /**
122:             * @param rs
123:             * @throws SQLException
124:             */
125:            public Permission(ResultSet rs) throws SQLException {
126:                super (rs);
127:            }
128:
129:            /**
130:             * @param holder
131:             * @param force
132:             * @throws ConfigurationException
133:             */
134:            public Permission(Element holder, boolean force)
135:                    throws ConfigurationException {
136:                super (holder, force);
137:            }
138:
139:            /**
140:             * @param holder
141:             * @param pathMap
142:             * @param cxpa
143:             * @param force
144:             * @throws ConfigurationException
145:             */
146:            public Permission(Element holder, Properties pathMap,
147:                    CachedXPathAPI cxpa, boolean force)
148:                    throws ConfigurationException {
149:                super (holder, pathMap, cxpa, force);
150:            }
151:
152:            private boolean isDerived;
153:
154:            /**
155:             * Sets derived indicator.
156:             * @param isDerived
157:             */
158:            public void setDerived(boolean isDerived) {
159:                this .isDerived = isDerived;
160:            }
161:
162:            /**
163:             * Indicates whether permission was directly assigned to the object or derived from other objects. 
164:             * E.g. User derives permission from Role.   
165:             * @return
166:             */
167:            public boolean isDerived() {
168:                return isDerived;
169:            }
170:
171:            /**
172:             * Retrieves derived permissons
173:             */
174:            public void setSQLProcessor(SQLProcessor processor)
175:                    throws SQLException {
176:                SecurityEngine engine = new SecurityEngine(processor);
177:                engine.processImpliedPermissions(getId(), new RowProcessor() {
178:
179:                    public boolean process(ResultSet rs) throws SQLException {
180:                        impliedPermissions.add(new Permission(rs));
181:                        return true;
182:                    }
183:
184:                });
185:            }
186:
187:            public void toDom(Element holder) {
188:                super .toDom(holder);
189:                DOMUtils.toDom(impliedPermissions, "implied-permissions",
190:                        holder);
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.