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.2 diff -u -r1.2 UserManager.java --- src/java/org/apache/lenya/ac/UserManager.java 3 Mar 2004 12:56:31 -0000 1.2 +++ src/java/org/apache/lenya/ac/UserManager.java 28 Jul 2004 07:42:27 -0000 @@ -19,6 +19,8 @@ package org.apache.lenya.ac; +import java.util.Collection; + public interface UserManager extends ItemManager { /** @@ -28,6 +30,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.4 diff -u -r1.4 FileAccreditableManager.java --- src/java/org/apache/lenya/ac/file/FileAccreditableManager.java 8 Mar 2004 16:48:21 -0000 1.4 +++ src/java/org/apache/lenya/ac/file/FileAccreditableManager.java 28 Jul 2004 07:42:27 -0000 @@ -21,7 +21,11 @@ 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,14 +39,17 @@ 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. + * + * Note: added Configurable as interface for user-type structure */ public class FileAccreditableManager extends AbstractAccreditableManager - implements Serviceable, Parameterizable { + implements Serviceable, Configurable, Parameterizable { /** * Creates a new FileAccreditableManager. If you use this constructor, you have to set the @@ -56,15 +63,25 @@ * 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. @@ -110,17 +127,65 @@ } protected static final String DIRECTORY = "directory"; - /** * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration) */ public void parameterize(Parameters parameters) throws ParameterException { + if (parameters.isParameter(DIRECTORY)) { configurationDirectoryPath = parameters.getParameter(DIRECTORY); getLogger().debug("Configuration directory: [" + configurationDirectoryPath + "]"); } } + + 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)); + } + // TO DO (maybe, or overkill?) : validate the parametrized user + // types, for example, check if the classes are in the classpath ? + } + } + private String configurationDirectoryPath; /** @@ -185,7 +250,9 @@ * @see org.apache.lenya.ac.impl.AbstractAccreditableManager#initializeUserManager() */ protected UserManager initializeUserManager() throws AccessControlException { - return FileUserManager.instance(getConfigurationDirectory()); + getLogger().debug("FileAccreditableManager: initializing UserManager"); + + 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.3 diff -u -r1.3 FileUserManager.java --- src/java/org/apache/lenya/ac/file/FileUserManager.java 3 Mar 2004 12:56:32 -0000 1.3 +++ src/java/org/apache/lenya/ac/file/FileUserManager.java 28 Jul 2004 07:42:27 -0000 @@ -20,6 +20,7 @@ package org.apache.lenya.ac.file; import java.io.File; +import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -32,7 +33,7 @@ * Describe class UserManager here. */ public class FileUserManager extends FileItemManager implements UserManager { - + private static Map instances = new HashMap(); /** @@ -42,10 +43,13 @@ * @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; } + private Collection userTypes; + /** * Describe instance method here. * @@ -53,7 +57,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()) { @@ -62,7 +66,7 @@ } if (!instances.containsKey(configurationDirectory)) { - instances.put(configurationDirectory, new FileUserManager(configurationDirectory)); + instances.put(configurationDirectory, new FileUserManager(configurationDirectory, userTypes)); } return (FileUserManager) instances.get(configurationDirectory); @@ -119,5 +123,10 @@ protected String getSuffix() { return SUFFIX; } - + + public Collection getUserTypes() { + return userTypes; + } + + } 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 28 Jul 2004 07:42:29 -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 28 Jul 2004 07:42:29 -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 28 Jul 2004 07:42:30 -0000 @@ -182,6 +182,8 @@ 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 28 Jul 2004 07:42:30 -0000 @@ -182,6 +182,10 @@ Gruppenmitgliedschaften Passwort ändern Mitgliedschaften ändern + + + LDAP Benutzer + CMS Benutzer IP Bereich 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 28 Jul 2004 07:42:30 -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 28 Jul 2004 07:42:30 -0000 @@ -45,6 +45,7 @@ +
@@ -101,10 +102,28 @@ -
- - -
+ + + + + + + +
+ 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; + } + +}