Index: src/java/org/apache/lenya/ac/UserManager.java =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/java/org/apache/lenya/ac/UserManager.java,v retrieving revision 1.3 diff -u -r1.3 UserManager.java --- src/java/org/apache/lenya/ac/UserManager.java 16 Aug 2004 16:21:22 -0000 1.3 +++ src/java/org/apache/lenya/ac/UserManager.java 10 Sep 2004 13:35:04 -0000 @@ -17,6 +17,8 @@ package org.apache.lenya.ac; +import java.util.Collection; + /** * User manager. * @version $Id: UserManager.java,v 1.3 2004/08/16 16:21:22 andreas Exp $ @@ -30,6 +32,13 @@ */ User[] getUsers(); + /** + * Get all supported user types + * + * @return a collection of user types + */ + Collection getUserTypes(); + /** * Add the given user * Index: src/java/org/apache/lenya/ac/file/FileAccreditableManager.java =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/java/org/apache/lenya/ac/file/FileAccreditableManager.java,v retrieving revision 1.5 diff -u -r1.5 FileAccreditableManager.java --- src/java/org/apache/lenya/ac/file/FileAccreditableManager.java 16 Aug 2004 15:48:37 -0000 1.5 +++ src/java/org/apache/lenya/ac/file/FileAccreditableManager.java 10 Sep 2004 13:35:04 -0000 @@ -21,7 +21,12 @@ import java.io.File; import java.net.URI; +import java.util.Collection; +import java.util.HashSet; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.parameters.Parameterizable; import org.apache.avalon.framework.parameters.Parameters; @@ -35,13 +40,14 @@ import org.apache.lenya.ac.IPRangeManager; import org.apache.lenya.ac.RoleManager; import org.apache.lenya.ac.UserManager; +import org.apache.lenya.ac.UserType; import org.apache.lenya.ac.impl.AbstractAccreditableManager; /** * File-based accreditable manager. */ public class FileAccreditableManager extends AbstractAccreditableManager implements Serviceable, - Parameterizable { + Configurable, Parameterizable { /** * Creates a new FileAccreditableManager. If you use this constructor, you have to set the @@ -55,15 +61,26 @@ * Creates a new FileAccessController based on a configuration directory. * * @param configurationDirectory The configuration directory. + * @param userTypes The supported user types. */ - public FileAccreditableManager(File configurationDirectory) { + public FileAccreditableManager(File configurationDirectory, Collection userTypes) { assert configurationDirectory != null; assert configurationDirectory.exists(); assert configurationDirectory.isDirectory(); this.configurationDirectory = configurationDirectory; + this.userTypes = userTypes; } private File configurationDirectory; + private Collection userTypes; + + public Collection getUserTypes() throws AccessControlException { + + if (userTypes == null) + throw new AccessControlException("User types not initialized"); + return userTypes; + } + /** * Returns the configuration directory. @@ -120,6 +137,53 @@ } } + protected static final String A_M_TAG = "accreditable-manager"; + protected static final String U_M_CHILD_TAG = "user-manager"; + protected static final String U_T_CHILD_TAG = "user-type"; + protected static final String U_T_CLASS_ATTRIBUTE = "class"; + protected static final String U_T_CREATE_ATTRIBUTE = "create-use-case"; + // provided for backward compatibility + protected static final String DEFAULT_USER_TYPE_CLASS = "org.apache.lenya.ac.file.FileUser"; + protected static final String DEFAULT_USER_TYPE_KEY = "Local User"; + protected static final String DEFAULT_USER_CREATE_USE_CASE = "userAddUser"; + + /** + * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) + * added to read new user-manager block within accreditable-manager + */ + public void configure(Configuration configuration) throws ConfigurationException { + // note: + // we need to distinguish the case where configure is called from + // somewhere else (i.e. not due to the reading of ac.xconf), + // from the case where the child user-manager does not exist, + // for instance when reading an old ac.xconf which does not yet + // have this configuration. So for backward compatibility, we need + // to distinguish the 2 cases + if (A_M_TAG.equals(configuration.getName())) { + userTypes = new HashSet(); + Configuration umConf = configuration.getChild(U_M_CHILD_TAG, false); + if (umConf != null) { + Configuration[] typeConfs = umConf.getChildren(); + for (int i = 0; i < typeConfs.length; i++) { + userTypes.add(new UserType(typeConfs[i].getValue(), + typeConfs[i].getAttribute(U_T_CLASS_ATTRIBUTE), + typeConfs[i].getAttribute(U_T_CREATE_ATTRIBUTE) + )); + } + } + else { + getLogger().debug("FileAccreditableManager: using default configuration for user types"); + // no "user-manager" block in access control: provide + // a default for backward compatibility + userTypes.add(new UserType(DEFAULT_USER_TYPE_KEY, + DEFAULT_USER_TYPE_CLASS, + DEFAULT_USER_CREATE_USE_CASE)); + } + // maybe todo (or is it overkill?) : validate the parametrized user + // types, for example, check if the classes are in the classpath ? + } + } + private String configurationDirectoryPath; /** @@ -183,7 +247,7 @@ * @see org.apache.lenya.ac.impl.AbstractAccreditableManager#initializeUserManager() */ protected UserManager initializeUserManager() throws AccessControlException { - return FileUserManager.instance(getConfigurationDirectory()); + return FileUserManager.instance(getConfigurationDirectory(), userTypes); } } Index: src/java/org/apache/lenya/ac/file/FileUserManager.java =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/java/org/apache/lenya/ac/file/FileUserManager.java,v retrieving revision 1.4 diff -u -r1.4 FileUserManager.java --- src/java/org/apache/lenya/ac/file/FileUserManager.java 16 Aug 2004 15:59:51 -0000 1.4 +++ src/java/org/apache/lenya/ac/file/FileUserManager.java 10 Sep 2004 13:35:04 -0000 @@ -18,6 +18,7 @@ package org.apache.lenya.ac.file; import java.io.File; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -33,6 +34,7 @@ public class FileUserManager extends FileItemManager implements UserManager { private static Map instances = new HashMap(); + private Collection userTypes; /** * Create a UserManager @@ -41,8 +43,9 @@ * @throws AccessControlException if the UserManager could not be * instantiated. */ - protected FileUserManager(File configurationDirectory) throws AccessControlException { + protected FileUserManager(File configurationDirectory, Collection userTypes) throws AccessControlException { super(configurationDirectory); + this.userTypes = userTypes; } /** @@ -52,7 +55,7 @@ * @return an UserManager value * @exception AccessControlException if an error occurs */ - public static FileUserManager instance(File configurationDirectory) throws AccessControlException { + public static FileUserManager instance(File configurationDirectory, Collection userTypes) throws AccessControlException { assert configurationDirectory != null; if (!configurationDirectory.isDirectory()) { @@ -61,7 +64,7 @@ } if (!instances.containsKey(configurationDirectory)) { - instances.put(configurationDirectory, new FileUserManager(configurationDirectory)); + instances.put(configurationDirectory, new FileUserManager(configurationDirectory, userTypes)); } return (FileUserManager) instances.get(configurationDirectory); @@ -104,6 +107,10 @@ */ public User getUser(String userId) { return (User) getItem(userId); + } + + public Collection getUserTypes() { + return userTypes; } protected static final String SUFFIX = ".iml"; Index: src/webapp/lenya/content/admin/users/users.xsp =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/webapp/lenya/content/admin/users/users.xsp,v retrieving revision 1.7 diff -u -r1.7 users.xsp --- src/webapp/lenya/content/admin/users/users.xsp 30 Apr 2004 16:34:23 -0000 1.7 +++ src/webapp/lenya/content/admin/users/users.xsp 10 Sep 2004 13:35:05 -0000 @@ -27,6 +27,7 @@ org.apache.lenya.ac.UserManager org.apache.lenya.ac.User + org.apache.lenya.ac.UserType org.apache.lenya.ac.Group java.io.File java.util.Iterator @@ -73,6 +74,23 @@ } + + + + Iterator types = userManager.getUserTypes().iterator(); + while (types.hasNext()) { + UserType type = (UserType)types.next(); + + + type.getClassName() + type.getCreateUseCase() + type.getKey() + + + } + + + Index: src/webapp/lenya/pubs/default/config/ac/ac.xconf =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/webapp/lenya/pubs/default/config/ac/ac.xconf,v retrieving revision 1.5 diff -u -r1.5 ac.xconf --- src/webapp/lenya/pubs/default/config/ac/ac.xconf 13 Mar 2004 12:34:17 -0000 1.5 +++ src/webapp/lenya/pubs/default/config/ac/ac.xconf 10 Sep 2004 13:35:05 -0000 @@ -21,6 +21,12 @@ + + + Local User + + + Index: src/webapp/lenya/resources/i18n/cmsui.xml =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/webapp/lenya/resources/i18n/cmsui.xml,v retrieving revision 1.62 diff -u -r1.62 cmsui.xml --- src/webapp/lenya/resources/i18n/cmsui.xml 23 May 2004 20:34:29 -0000 1.62 +++ src/webapp/lenya/resources/i18n/cmsui.xml 10 Sep 2004 13:35:06 -0000 @@ -182,6 +182,10 @@ Group Affiliation Change Password Edit Group Affiliation + + + LDAP User + CMS User IP Range Index: src/webapp/lenya/resources/i18n/cmsui_de.xml =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/webapp/lenya/resources/i18n/cmsui_de.xml,v retrieving revision 1.65 diff -u -r1.65 cmsui_de.xml --- src/webapp/lenya/resources/i18n/cmsui_de.xml 23 May 2004 20:34:29 -0000 1.65 +++ src/webapp/lenya/resources/i18n/cmsui_de.xml 10 Sep 2004 13:35:06 -0000 @@ -183,6 +183,10 @@ Passwort ändern Mitgliedschaften ändern + + LDAP Benutzer + CMS Benutzer + IP Bereich IP Bereichs-ID Index: src/webapp/lenya/xslt/admin/users/profile.xsl =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/webapp/lenya/xslt/admin/users/profile.xsl,v retrieving revision 1.16 diff -u -r1.16 profile.xsl --- src/webapp/lenya/xslt/admin/users/profile.xsl 28 Apr 2004 15:00:05 -0000 1.16 +++ src/webapp/lenya/xslt/admin/users/profile.xsl 10 Sep 2004 13:35:06 -0000 @@ -118,7 +118,7 @@ LDAP ID * - + Index: src/webapp/lenya/xslt/admin/users/users.xsl =================================================================== RCS file: /home/cvspublic/cocoon-lenya/src/webapp/lenya/xslt/admin/users/users.xsl,v retrieving revision 1.11 diff -u -r1.11 users.xsl --- src/webapp/lenya/xslt/admin/users/users.xsl 1 Jun 2004 14:29:23 -0000 1.11 +++ src/webapp/lenya/xslt/admin/users/users.xsl 10 Sep 2004 13:35:06 -0000 @@ -101,10 +101,27 @@ -
- - -
+ + + + + + + +
+ Add User:  + +
+ + + + + + +
+
Index: src/java/org/apache/lenya/ac/UserType.java =================================================================== RCS file: src/java/org/apache/lenya/ac/UserType.java diff -N src/java/org/apache/lenya/ac/UserType.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/java/org/apache/lenya/ac/UserType.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ +/* + * Copyright 1999-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* $Id: $ */ + +package org.apache.lenya.ac; + +/** + * A user type to be supported by the UserManager + * Note: the types are configured through access control (ac.xconf) + */ +public class UserType { + private String key; + private String className; + private String createUseCase; + + public UserType() { + } + + public UserType(String key, String className, String createUseCase) { + this.key = key; + this.className = className; + this.createUseCase = createUseCase; + } + + /** + * Get the key + * + * @return a String + */ + public String getKey() { + return key; + } + + /** + * Set the key + * + * @param key the new key + */ + public void setKey(String key) { + this.key = key; + } + + /** + * Get the className + * + * @return a String + */ + public String getClassName() { + return className; + } + + /** + * Set the className + * + * @param className the new className + */ + public void setClassName(String className) { + this.className = className; + } + + /** + * Get the createUseCase + * + * @return a String + */ + public String getCreateUseCase() { + return createUseCase; + } + + /** + * Set the createUseCase + * + * @param createUseCase the new createUseCase + */ + public void setCreateUseCase(String createUseCase) { + this.createUseCase = createUseCase; + } + +}