Source Code Cross Referenced for AuthorizationPrincipalImpl.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » security » provider » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.security.provider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001, 2002 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.security.provider;
007:
008:        import org.jasig.portal.AuthorizationException;
009:        import org.jasig.portal.security.IAuthorizationPrincipal;
010:        import org.jasig.portal.security.IAuthorizationService;
011:        import org.jasig.portal.security.IPermission;
012:        import org.jasig.portal.security.IPermissionPolicy;
013:
014:        /**
015:         * @author Dan Ellentuck
016:         * @version $Revision: 34771 $
017:         */
018:        public class AuthorizationPrincipalImpl implements 
019:                IAuthorizationPrincipal {
020:            private java.lang.String key;
021:            private java.lang.Class type;
022:            private org.jasig.portal.security.IAuthorizationService authorizationService;
023:            private java.lang.String principalString;
024:
025:            /**
026:             * Constructor for ReferenceAuthorizationPrincipal.
027:             */
028:            public AuthorizationPrincipalImpl(String newKey, Class newType) {
029:                this (newKey, newType, null);
030:            }
031:
032:            /**
033:             * Constructor for ReferenceAuthorizationPrincipal.
034:             */
035:            public AuthorizationPrincipalImpl(String newKey, Class newType,
036:                    IAuthorizationService authService) {
037:                super ();
038:                key = newKey;
039:                type = newType;
040:                authorizationService = authService;
041:                initialize();
042:            }
043:
044:            /**
045:             * Answers if this <code>IAuthorizationPrincipal</code> has permission to publish.
046:             * @return boolean
047:             * @exception AuthorizationException thrown when authorization information could not be retrieved.
048:             */
049:            public boolean canPublish()
050:                    throws org.jasig.portal.AuthorizationException {
051:                return getAuthorizationService().canPrincipalPublish(this );
052:            }
053:
054:            /**
055:             * Answers if this <code>IAuthorizationPrincipal</code> has permission to render this channel.
056:             * @return boolean
057:             * @param channelPublishId int - the Channel publish ID
058:             * @exception AuthorizationException thrown when authorization information could not be retrieved.
059:             */
060:            public boolean canRender(int channelPublishId)
061:                    throws org.jasig.portal.AuthorizationException {
062:                return getAuthorizationService().canPrincipalRender(this ,
063:                        channelPublishId);
064:            }
065:
066:            /**
067:             * Answers if this <code>IAuthorizationPrincipal</code> has permission to subscribe to this channel.
068:             * @return boolean
069:             * @param  channelPublishId int - the Channel publish ID
070:             * @exception AuthorizationException thrown when authorization information could not be retrieved.
071:             */
072:            public boolean canSubscribe(int channelPublishId)
073:                    throws org.jasig.portal.AuthorizationException {
074:                return getAuthorizationService().canPrincipalSubscribe(this ,
075:                        channelPublishId);
076:            }
077:
078:            /**
079:             * Compares two objects for equality. Returns a boolean that indicates
080:             * whether this object is equivalent to the specified object. This method
081:             * is used when an object is stored in a hashtable.
082:             * @param obj the Object to compare with
083:             * @return true if these Objects are equal; false otherwise.
084:             * @see java.util.Hashtable
085:             */
086:            public boolean equals(Object obj) {
087:                if (obj == null)
088:                    return false;
089:                if (obj == this )
090:                    return true;
091:                if (!(obj instanceof  IAuthorizationPrincipal))
092:                    return false;
093:
094:                IAuthorizationPrincipal otherAP = (IAuthorizationPrincipal) obj;
095:                return this .getKey().equals(otherAP.getKey())
096:                        && this .getType() == otherAP.getType();
097:            }
098:
099:            /**
100:             * Returns the <code>IPermissions</code> for this <code>IAuthorizationPrincipal</code>, including
101:             * inherited <code>IPermissions</code>.  
102:             * 
103:             * @return org.jasig.portal.security.IPermission[]
104:             * @exception AuthorizationException indicates authorization information could not 
105:             * be retrieved.
106:             */
107:            public IPermission[] getAllPermissions()
108:                    throws AuthorizationException {
109:                return getAllPermissions(null, null, null);
110:            }
111:
112:            /**
113:             * Returns the <code>IPermissions</code> for this <code>IAuthorizationPrincipal</code> for the 
114:             * specified <code>owner</code>, <code>activity</code> and <code>target</code>.  Inherited
115:             * <code>IPermissions</code> are included.  Null parameters are ignored, so 
116:             * <code>getPermissions(null, null, null)</code> should retrieve all <code>IPermissions</code> 
117:             * for an <code>IAuthorizationPrincipal</code>.
118:             * 
119:             * @return org.jasig.portal.security.IPermission[]
120:             * @param owner java.lang.String
121:             * @param activity java.lang.String
122:             * @param target java.lang.String
123:             * @exception AuthorizationException indicates authorization information could not 
124:             * be retrieved.
125:             */
126:            public IPermission[] getAllPermissions(String owner,
127:                    String activity, String target)
128:                    throws AuthorizationException {
129:                return getAuthorizationService().getAllPermissionsForPrincipal(
130:                        this , owner, activity, target);
131:            }
132:
133:            /**
134:             * @return org.jasig.portal.security.IAuthorization
135:             */
136:            IAuthorizationService getAuthorizationService() {
137:                return authorizationService;
138:            }
139:
140:            /**
141:             * Return a Vector of IChannels.
142:             * @return a <code>java.util.Vector</code> of IChannels
143:             * @exception AuthorizationException indicates authorization information could not be retrieved.
144:             */
145:            public java.util.Vector getAuthorizedChannels()
146:                    throws org.jasig.portal.AuthorizationException {
147:                return getAuthorizationService().getAuthorizedChannels(this );
148:            }
149:
150:            /**
151:             * @return java.lang.String
152:             */
153:            public java.lang.String getKey() {
154:                return key;
155:            }
156:
157:            /**
158:             * Returns the <code>IPermissions</code> for this <code>IAuthorizationPrincipal</code>.  
159:             * 
160:             * @return org.jasig.portal.security.IPermission[]
161:             * @exception AuthorizationException indicates authorization information could not 
162:             * be retrieved.
163:             */
164:            public IPermission[] getPermissions() throws AuthorizationException {
165:                return getPermissions(null, null, null);
166:            }
167:
168:            /**
169:             * Returns the <code>IPermissions</code> for this <code>IAuthorizationPrincipal</code> for the 
170:             * specified <code>owner</code>, <code>activity</code> and <code>target</code>.  Null parameters 
171:             * are ignored, so <code>getPermissions(null, null, null)</code> should retrieve all 
172:             * <code>IPermissions</code> for an <code>IAuthorizationPrincipal</code>.
173:             * 
174:             * @return org.jasig.portal.security.IPermission[]
175:             * @param owner java.lang.String
176:             * @param activity java.lang.String
177:             * @param target java.lang.String
178:             * @exception AuthorizationException indicates authorization information could not 
179:             * be retrieved.
180:             */
181:            public IPermission[] getPermissions(String owner, String activity,
182:                    String target) throws AuthorizationException {
183:                return getAuthorizationService().getPermissionsForPrincipal(
184:                        this , owner, activity, target);
185:            }
186:
187:            /**
188:             * @return java.lang.String
189:             */
190:            public String getPrincipalString() {
191:                return principalString;
192:            }
193:
194:            /**
195:             * @return java.lang.Class
196:             */
197:            public java.lang.Class getType() {
198:                return type;
199:            }
200:
201:            /**
202:             * Generates a hash code for the receiver.
203:             * This method is supported primarily for
204:             * hash tables, such as those provided in java.util.
205:             * @return an integer hash code for the receiver
206:             * @see java.util.Hashtable
207:             */
208:            public int hashCode() {
209:                return getKey().hashCode() + getType().hashCode();
210:            }
211:
212:            /**
213:             * Answers if this <code>IAuthorizationPrincipal</code> has permission to perform the 
214:             * <code>activity</code> on the <code>target</code>.  Params <code>owner</code> and 
215:             * <code>activity</code> must be non-null.  If <code>target</code> is null, then the
216:             * target is not checked.
217:             * 
218:             * @return boolean
219:             * @param owner java.lang.String
220:             * @param activity java.lang.String
221:             * @param target java.lang.String
222:             * @exception AuthorizationException indicates authorization information could not 
223:             * be retrieved.
224:             */
225:            public boolean hasPermission(String owner, String activity,
226:                    String target)
227:                    throws org.jasig.portal.AuthorizationException {
228:                return getAuthorizationService().doesPrincipalHavePermission(
229:                        this , owner, activity, target);
230:            }
231:
232:            /**
233:             * Set the value of the principal string.
234:             */
235:            private void initialize() {
236:                principalString = getAuthorizationService().getPrincipalString(
237:                        this );
238:            }
239:
240:            /**
241:             * @param newAuthorizationService org.jasig.portal.security.IAuthorizationService
242:             */
243:            void setAuthorizationService(
244:                    IAuthorizationService newAuthorizationService) {
245:                authorizationService = newAuthorizationService;
246:            }
247:
248:            /**
249:             * Returns a String that represents the value of this object.
250:             * @return a string representation of the receiver
251:             */
252:            public String toString() {
253:                return getPrincipalString();
254:            }
255:
256:            /**
257:             * Answers if this <code>IAuthorizationPrincipal</code> has permission to perform the
258:             * <code>activity</code> on the <code>target</code>, as evaluated by the 
259:             * <code>policy</code>.  Params <code>policy</code>, <code>owner</code> and
260:             * <code>activity</code> must be non-null.  
261:             *
262:             * @return boolean
263:             * @param owner java.lang.String
264:             * @param activity java.lang.String
265:             * @param target java.lang.String
266:             * @param policy org.jasig.portal.security.IPermissionPolicy
267:             * @exception AuthorizationException indicates authorization information could not
268:             * be retrieved.
269:             */
270:            public boolean hasPermission(String owner, String activity,
271:                    String target, IPermissionPolicy policy)
272:                    throws AuthorizationException {
273:                return getAuthorizationService().doesPrincipalHavePermission(
274:                        this, owner, activity, target, policy);
275:            }
276:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.