Source Code Cross Referenced for UnresolvedPrincipal.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » 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 » Apache Harmony Java SE » org package » org.apache.harmony.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Alexey V. Varlamov
020:         * @version $Revision$
021:         */package org.apache.harmony.security;
022:
023:        import java.security.Principal;
024:
025:        import org.apache.harmony.security.internal.nls.Messages;
026:
027:        /**
028:         * Descriptive implementation of Principal, which holds a name and a classname
029:         * of unresolved principal. It is used to define an arbitrary Principal which
030:         * may be not yet instantiated and authenticated. 
031:         * <br>
032:         * This concept is somewhat similar to UnresolvedPermission. A principal-based 
033:         * policy may grant permissions depending on what Principals own the current 
034:         * execution thread. So the policy refers to this model definition of 
035:         * acceptable principal and compares it with the actual principal. 
036:         * 
037:         * @see org.apache.harmony.security.PolicyEntry
038:         * @see org.apache.harmony.security.DefaultPolicy
039:         */
040:        public final class UnresolvedPrincipal implements  Principal {
041:
042:            /** 
043:             * Wildcard value denotes any class and/or any name. 
044:             */
045:            public static final String WILDCARD = DefaultPolicyScanner.PrincipalEntry.WILDCARD;
046:
047:            // Class name
048:            private final String klass;
049:
050:            // Principal name
051:            private final String name;
052:
053:            /**
054:             * Constructs a a new definition of a Principal with specified
055:             * parameters. 
056:             * @param klass fully qualified class name, may be wildcard
057:             * @param name name of principal, may be wildcard
058:             * @throws IllegalArgumentException if <code>klass</code> value 
059:             * is <code>null </code> or is empty string 
060:             */
061:            public UnresolvedPrincipal(String klass, String name) {
062:                if (klass == null || klass.length() == 0) {
063:                    throw new IllegalArgumentException(Messages
064:                            .getString("security.91")); //$NON-NLS-1$
065:                }
066:
067:                this .klass = klass;
068:                this .name = name;
069:            }
070:
071:            /**
072:             * Returns name of a modeled Principal, or wildcard 
073:             * if any name is acceptable.
074:             */
075:            public String getName() {
076:                return name;
077:            }
078:
079:            /** 
080:             * Returns fully qualified class name of a modeled Principal,
081:             * or wildcard if any class is acceptable. 
082:             */
083:            public String getClassName() {
084:                return klass;
085:            }
086:
087:            /**
088:             * Returns <code>true</code> if compared object is a Principal
089:             * matching this definition, or if it is an UnresolvedPrincipal, 
090:             * which defines the same Principal; <code>false</code> otherwise.  
091:             */
092:            public boolean equals(Object that) {
093:                if (that instanceof  UnresolvedPrincipal) {
094:                    UnresolvedPrincipal up = (UnresolvedPrincipal) that;
095:                    return klass.equals(up.klass)
096:                            && (name == null ? up.name == null : name
097:                                    .equals(up.name));
098:                }
099:                if (that instanceof  Principal) {
100:                    return implies((Principal) that);
101:                }
102:                return false;
103:            }
104:
105:            /** 
106:             * Returns <code>true</code> if compared object is a Principal
107:             * exactly matching this definition. Namely, if the fully qualified name 
108:             * of class of passed Principal is equal to the class name value
109:             * of this definition and the name of passed Principal is equal to 
110:             * the name value of this definition, or if this definition allows
111:             * any class or name, respectively.  
112:             * Otherwise returns <code>false</code> .
113:             */
114:            public boolean implies(Principal another) {
115:                return (another != null)
116:                        && (WILDCARD.equals(klass) || klass.equals(another
117:                                .getClass().getName())
118:                                && (WILDCARD.equals(name) || (name == null ? another
119:                                        .getName() == null
120:                                        : name.equals(another.getName()))));
121:            }
122:
123:            /** 
124:             * Returns the hash code value for this object. 
125:             */
126:            public int hashCode() {
127:                int hash = 0;
128:                if (name != null) {
129:                    hash ^= name.hashCode();
130:                }
131:                if (klass != null) {
132:                    hash ^= klass.hashCode();
133:                }
134:                return hash;
135:            }
136:
137:            /** 
138:             * Returns a string describing this model of Principal.
139:             * The format is 'Principal classname &quot;name&quot;'.
140:             */
141:            public String toString() {
142:                return "Principal " + klass + " \"" + name + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.