Source Code Cross Referenced for FileAccreditableManager.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » lenya » ac » file » 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 » Content Management System » apache lenya 2.0 » org.apache.lenya.ac.file 
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:        /* $Id: FileAccreditableManager.java 508055 2007-02-15 18:04:30Z andreas $  */
020:
021:        package org.apache.lenya.ac.file;
022:
023:        import java.io.File;
024:        import java.io.IOException;
025:        import java.net.URI;
026:        import java.util.Arrays;
027:        import java.util.HashSet;
028:        import java.util.Set;
029:
030:        import org.apache.avalon.framework.logger.Logger;
031:        import org.apache.avalon.framework.service.ServiceManager;
032:        import org.apache.cocoon.util.NetUtils;
033:        import org.apache.excalibur.source.Source;
034:        import org.apache.excalibur.source.SourceResolver;
035:        import org.apache.lenya.ac.AccessControlException;
036:        import org.apache.lenya.ac.GroupManager;
037:        import org.apache.lenya.ac.IPRangeManager;
038:        import org.apache.lenya.ac.RoleManager;
039:        import org.apache.lenya.ac.UserManager;
040:        import org.apache.lenya.ac.UserType;
041:        import org.apache.lenya.ac.impl.AbstractAccreditableManager;
042:        import org.apache.lenya.util.Assert;
043:
044:        /**
045:         * File-based accreditable manager.
046:         */
047:        public class FileAccreditableManager extends
048:                AbstractAccreditableManager {
049:
050:            private ServiceManager manager;
051:
052:            /**
053:             * Creates a new FileAccessController based on a configuration directory.
054:             * @param manager The service manager.
055:             * @param logger The logger.
056:             * @param configurationUri The configuration directory URI.
057:             * @param _userTypes The supported user types.
058:             */
059:            public FileAccreditableManager(ServiceManager manager,
060:                    Logger logger, String configurationUri,
061:                    UserType[] _userTypes) {
062:                super (logger);
063:
064:                Assert.notNull("service manager", manager);
065:                this .manager = manager;
066:
067:                Assert.notNull("configuration directory", configurationUri);
068:                this .configurationDirectoryUri = configurationUri;
069:
070:                this .userTypes = new HashSet(Arrays.asList(_userTypes));
071:            }
072:
073:            private File configurationDirectory;
074:            private Set userTypes;
075:
076:            /**
077:             * Returns the supported user types.
078:             * @return An array of user types.
079:             * @throws AccessControlException if an error occurs.
080:             */
081:            public UserType[] getUserTypes() throws AccessControlException {
082:                if (this .userTypes == null)
083:                    throw new AccessControlException(
084:                            "User types not initialized");
085:                return (UserType[]) this .userTypes
086:                        .toArray(new UserType[this .userTypes.size()]);
087:            }
088:
089:            /**
090:             * Returns the configuration directory.
091:             * @return The configuration directory.
092:             * @throws AccessControlException when something went wrong.
093:             */
094:            public File getConfigurationDirectory()
095:                    throws AccessControlException {
096:
097:                if (this .configurationDirectory == null) {
098:
099:                    if (this .configurationDirectoryUri == null) {
100:                        throw new AccessControlException(
101:                                "Configuration directory not set!");
102:                    }
103:
104:                    Source source = null;
105:                    SourceResolver resolver = null;
106:                    File directory;
107:                    try {
108:
109:                        getLogger().debug(
110:                                "Configuration directory Path: ["
111:                                        + this .configurationDirectoryUri + "]");
112:
113:                        resolver = (SourceResolver) getManager().lookup(
114:                                SourceResolver.ROLE);
115:                        source = resolver
116:                                .resolveURI(this .configurationDirectoryUri);
117:
118:                        getLogger().debug(
119:                                "Configuration directory URI: "
120:                                        + source.getURI());
121:                        directory = new File(new URI(NetUtils.encodePath(source
122:                                .getURI())));
123:                    } catch (Exception e) {
124:                        throw new AccessControlException(e);
125:                    } finally {
126:                        if (resolver != null) {
127:                            if (source != null) {
128:                                resolver.release(source);
129:                            }
130:                            getManager().release(resolver);
131:                        }
132:                    }
133:                    this .configurationDirectory = directory;
134:                }
135:
136:                return this .configurationDirectory;
137:            }
138:
139:            // provided for backward compatibility
140:            protected static final String DEFAULT_USER_TYPE_CLASS = FileUser.class
141:                    .getName();
142:            protected static final String DEFAULT_USER_TYPE_KEY = "Local User";
143:            protected static final String DEFAULT_USER_CREATE_USE_CASE = "userAddUser";
144:
145:            /**
146:             * Returns the default user type.
147:             * @return A user type.
148:             */
149:            public static UserType getDefaultUserType() {
150:                return new UserType(DEFAULT_USER_TYPE_KEY,
151:                        DEFAULT_USER_TYPE_CLASS, DEFAULT_USER_CREATE_USE_CASE);
152:            }
153:
154:            private String configurationDirectoryUri;
155:
156:            /**
157:             * Returns the service manager.
158:             * @return A service manager.
159:             */
160:            protected ServiceManager getManager() {
161:                return this .manager;
162:            }
163:
164:            /**
165:             * @see org.apache.lenya.ac.impl.AbstractAccreditableManager#initializeGroupManager()
166:             */
167:            protected GroupManager initializeGroupManager()
168:                    throws AccessControlException {
169:                FileGroupManager _manager = FileGroupManager.instance(this ,
170:                        getConfigurationDirectory(), getLogger());
171:                return _manager;
172:            }
173:
174:            /**
175:             * @see org.apache.lenya.ac.impl.AbstractAccreditableManager#initializeIPRangeManager()
176:             */
177:            protected IPRangeManager initializeIPRangeManager()
178:                    throws AccessControlException {
179:                FileIPRangeManager _manager = FileIPRangeManager.instance(this ,
180:                        getConfigurationDirectory(), getLogger());
181:                return _manager;
182:            }
183:
184:            /**
185:             * @see org.apache.lenya.ac.impl.AbstractAccreditableManager#initializeRoleManager()
186:             */
187:            protected RoleManager initializeRoleManager()
188:                    throws AccessControlException {
189:                FileRoleManager _manager = FileRoleManager.instance(this ,
190:                        getConfigurationDirectory(), getLogger());
191:                return _manager;
192:            }
193:
194:            /**
195:             * @see org.apache.lenya.ac.impl.AbstractAccreditableManager#initializeUserManager()
196:             */
197:            protected UserManager initializeUserManager()
198:                    throws AccessControlException {
199:                FileUserManager _manager = FileUserManager.instance(this ,
200:                        getConfigurationDirectory(), getUserTypes(),
201:                        getLogger());
202:                return _manager;
203:            }
204:
205:            public String getConfigurationCollectionUri() {
206:                try {
207:                    return "file://"
208:                            + getConfigurationDirectory().getCanonicalPath();
209:                } catch (Exception e) {
210:                    throw new RuntimeException(e);
211:                }
212:            }
213:
214:            public String getId() {
215:                try {
216:                    Assert.notNull("configuration directory", this 
217:                            .getConfigurationDirectory());
218:                    return this .getConfigurationDirectory().getCanonicalPath();
219:                } catch (IOException e) {
220:                    throw new RuntimeException(e);
221:                } catch (AccessControlException e) {
222:                    throw new RuntimeException(e);
223:                }
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.