Source Code Cross Referenced for BasePrincipalImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » security » impl » 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 » jetspeed 2.1.3 » org.apache.jetspeed.security.impl 
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:        package org.apache.jetspeed.security.impl;
018:
019:        import org.apache.jetspeed.security.BasePrincipal;
020:
021:        /**
022:         * <p>
023:         * {@link BasePrincipal} interface implementation.
024:         * </p>
025:         * 
026:         * @author <a href="mailto:dlestrat@apache.org">David Le Strat</a>
027:         */
028:        public abstract class BasePrincipalImpl implements  BasePrincipal {
029:
030:            /** The version uid. */
031:            private static final long serialVersionUID = 5687385387290144541L;
032:
033:            /** The principal name. */
034:            private final String name;
035:
036:            /** The full path. */
037:            private final String fullPath;
038:
039:            /** is this principal enabled **/
040:            private boolean enabled = true;
041:
042:            /** is this principal a mapping **/
043:            private boolean isMapping = false;
044:
045:            /**
046:             * <p>
047:             * Principal constructor given a name and preferences root.
048:             * </p>
049:             * 
050:             * @param name The principal name.
051:             * @param prefsRoot The preferences root node.
052:             */
053:            public BasePrincipalImpl(String name, String prefsRoot,
054:                    boolean hiearchicalNames) {
055:                this (name, prefsRoot, hiearchicalNames, true, false);
056:            }
057:
058:            public BasePrincipalImpl(String name, String prefsRoot,
059:                    boolean hiearchicalNames, boolean isEnabled,
060:                    boolean isMapping) {
061:                this .name = name;
062:                this .fullPath = getFullPathFromPrincipalName(name, prefsRoot,
063:                        hiearchicalNames);
064:                this .enabled = isEnabled;
065:                this .isMapping = isMapping;
066:            }
067:
068:            /**
069:             * @see org.apache.jetspeed.security.BasePrincipal#getFullPath()
070:             */
071:            public String getFullPath() {
072:                return this .fullPath;
073:            }
074:
075:            /**
076:             * @see java.security.Principal#getName()
077:             */
078:            public String getName() {
079:                return this .name;
080:            }
081:
082:            /**
083:             * @see java.lang.Object#hashCode()
084:             */
085:            public int hashCode() {
086:                return this .name.hashCode();
087:            }
088:
089:            /**
090:             * <p>
091:             * Returns a string representation of this principal.
092:             * </p>
093:             * 
094:             * @return A string representation of this principal.
095:             */
096:            public String toString() {
097:                return this .name;
098:            }
099:
100:            /**
101:             * <p>
102:             * Gets the principal implementation full path from the principal name.
103:             * </p>
104:             * <p>
105:             * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
106:             * separator for hierarchical elements.
107:             * </p>
108:             * <p>
109:             * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
110:             * </p>
111:             * 
112:             * @param name The principal name.
113:             * @param prefsRoot The preferences root node.
114:             * @param hiearchicalNames indicator if hierarchy encoding (replacing '.' with '/') should be done
115:             * @return The preferences full path / principal name.
116:             */
117:            public static String getFullPathFromPrincipalName(String name,
118:                    String prefsRoot, boolean hiearchicalNames) {
119:                String fullPath = name;
120:                if (null != name) {
121:                    fullPath = prefsRoot
122:                            + (hiearchicalNames ? name.replace('.', '/') : name);
123:                }
124:                return fullPath;
125:            }
126:
127:            /**
128:             * <p>
129:             * Gets the principal implementation full path from the principal name.
130:             * </p>
131:             * <p>
132:             * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
133:             * separator for hierarchical elements.
134:             * </p>
135:             * <p>
136:             * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
137:             * </p>
138:             * 
139:             * @param name The principal name.
140:             * @param prefsRoot The preferences root node.
141:             * @return The preferences full path / principal name.
142:             */
143:
144:            /**
145:             * <p>
146:             * Gets the principal name from the principal implementation full path.
147:             * </p>
148:             * <p>
149:             * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
150:             * separator for hierarchical elements.
151:             * </p>
152:             * <p>
153:             * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
154:             * </p>
155:             * 
156:             * @param fullPath The principal full path.
157:             * @param prefsRoot The preferences root node.
158:             * @param hiearchicalNames indicator if hierarchical decoding (replacing '/' with '.') should be done
159:             * @return The principal name.
160:             */
161:            public static String getPrincipalNameFromFullPath(String fullPath,
162:                    String prefsRoot, boolean hiearchicalNames) {
163:                String name = fullPath;
164:                if (null != name) {
165:                    name = name.substring(prefsRoot.length(), name.length());
166:                    if (hiearchicalNames) {
167:                        name = name.replace('/', '.');
168:                    }
169:                }
170:                return name;
171:            }
172:
173:            /**
174:             * <p>
175:             * Gets the principal name from the principal implementation full path.
176:             * </p>
177:             * <p>
178:             * Hierarchical principal names should follow: {principal}.{subprincipal}. "." is used as the
179:             * separator for hierarchical elements.
180:             * </p>
181:             * <p>
182:             * The implementation path follow /PREFS_{PRINCIPAL}_ROOT/{principal}/{subprincipal}.
183:             * </p>
184:             * 
185:             * @param fullPath The principal full path.
186:             * @param prefsRoot The preferences root node.
187:             * @return The principal name.
188:             */
189:            // MOVED TO DERVICED CLASSES    
190:            //    public static String getPrincipalNameFromFullPath(String fullPath, String prefsRoot)
191:            //    {
192:            //        return getPrincipalNameFromFullPath(fullPath, prefsRoot, true);
193:            //    }
194:            /**
195:             * @see org.apache.jetspeed.security.BasePrincipal#isEnabled()
196:             */
197:            public boolean isEnabled() {
198:                return enabled;
199:            }
200:
201:            /**
202:             * @see org.apache.jetspeed.security.BasePrincipal#setEnabled(boolean)
203:             */
204:            public void setEnabled(boolean enabled) {
205:                this .enabled = enabled;
206:            }
207:
208:            public boolean isMapping() {
209:                return isMapping;
210:            }
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.