Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/user/simple In directory sc8-pr-cvs1:/tmp/cvs-serv700/src/com/babeldoc/core/user/simple Modified Files: SimpleUserContext.java SimpleUserFactory.java SimpleUserResourceFactory.java Log Message: reformatted and updated license header Index: SimpleUserContext.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/user/simple/SimpleUserContext.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleUserContext.java 15 Mar 2003 22:54:13 -0000 1.2 --- SimpleUserContext.java 27 Jun 2003 02:20:00 -0000 1.3 *************** *** 1,22 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/21 17:01:20 $ * * ! * babeldoc: universal document processor * ! * This program is free software; you can redistribute it and/or ! * modify it under the terms of the GNU General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package com.babeldoc.core.user.simple; --- 1,66 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.user.simple; *************** *** 24,27 **** --- 68,72 ---- import com.babeldoc.core.user.UserContext; + /** * A very simplistic user context. *************** *** 30,38 **** * @version 1.0 */ ! public class SimpleUserContext ! extends UserContext { ! private SimpleUserFactory manager; public SimpleUserContext(SimpleUserFactory manager, String name) { this.manager = manager; --- 75,87 ---- * @version 1.0 */ ! public class SimpleUserContext extends UserContext { private SimpleUserFactory manager; + /** + * Creates a new SimpleUserContext object. + * + * @param manager DOCUMENT ME! + * @param name DOCUMENT ME! + */ public SimpleUserContext(SimpleUserFactory manager, String name) { this.manager = manager; *************** *** 47,49 **** super.setAuthenticated(authenticated); } ! } \ No newline at end of file --- 96,98 ---- super.setAuthenticated(authenticated); } ! } Index: SimpleUserFactory.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/user/simple/SimpleUserFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleUserFactory.java 15 Mar 2003 22:54:13 -0000 1.2 --- SimpleUserFactory.java 27 Jun 2003 02:20:00 -0000 1.3 *************** *** 1,22 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/21 17:01:20 $ * * ! * babeldoc: universal document processor * ! * This program is free software; you can redistribute it and/or ! * modify it under the terms of the GNU General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package com.babeldoc.core.user.simple; --- 1,66 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.user.simple; *************** *** 25,28 **** --- 69,73 ---- import com.babeldoc.core.user.*; + /** * Desperately simple user manager. This should not be used in any kind of *************** *** 32,72 **** * @version 1.0 */ ! public class SimpleUserFactory ! implements IUserFactory { ! /** constant: configuration name */ public static final String CONFIG_NAME = "user/simple/factory"; /** constant: the globalPreference prefix */ public static final String GLB_PREF_PREFIX = "globalPrefix."; /** constant: the orgPreference prefix */ public static final String ORG_PREF_PREFIX = "orgPrefix."; /** constant: the user Preference prefix */ public static final String USR_PREF_PREFIX = "usrPrefix."; /** constant: the glue */ public static final String GLUE = "."; /** ! * Get user context object. ! * get a user context object for the named user. This ! * opject is by default unauthenticated. * @param name the name of the user * @return usercontext */ ! public IUserContext getUserContext(String name) ! throws UserException { ! com.babeldoc.core.LogService.getInstance().logDebug( ! "[SimpleUserManager.getUserContext]: getting context for user: " + name); if (name.startsWith("z")) { throw new UserException("[getUserContext] invalid user"); } return new SimpleUserContext(this, name); } /** ! * Get user context object. ! * get a user context object for the named user. This ! * opject is by default unauthenticated. * @param name the name of the user * @return usercontext */ public IUserContext getUserContext(String name, IUserCredential credential) --- 77,180 ---- * @version 1.0 */ ! public class SimpleUserFactory implements IUserFactory { /** constant: configuration name */ public static final String CONFIG_NAME = "user/simple/factory"; + /** constant: the globalPreference prefix */ public static final String GLB_PREF_PREFIX = "globalPrefix."; + /** constant: the orgPreference prefix */ public static final String ORG_PREF_PREFIX = "orgPrefix."; + /** constant: the user Preference prefix */ public static final String USR_PREF_PREFIX = "usrPrefix."; + /** constant: the glue */ public static final String GLUE = "."; /** ! * Get the global preference string for the organization. This uses the ! * configuration data for the simple user factory. ! * ! * @param key ! * ! * @return preference string ! * ! * @throws UserException DOCUMENT ME! ! */ ! public String getGlobalPreference(String key) throws UserException { ! StringBuffer sbuf = new StringBuffer(ORG_PREF_PREFIX); ! sbuf.append(key); ! ! return ConfigService.getString(CONFIG_NAME, sbuf.toString()); ! } ! ! /** ! * Get organization object. get a user context object for the named user. ! * This object is by default unauthenticated. If the user is not found, the ! * context object is null. ! * ! * @param name the name of the organization ! * ! * @return usercontext - null if username not found. ! * ! * @throws UserException DOCUMENT ME! ! */ ! public IOrganization getOrganization(String name) throws UserException { ! throw new UserException("Not implemented"); ! } ! ! /** ! * Get the preference string for the organization. This uses the ! * configuration data for the simple user factory. ! * ! * @param org the org to get preference ! * @param key ! * ! * @return preference string ! * ! * @throws UserException DOCUMENT ME! ! */ ! public String getOrganizationPreference(IOrganization org, String key) ! throws UserException { ! StringBuffer sbuf = new StringBuffer(ORG_PREF_PREFIX); ! sbuf.append(org.toString()); ! sbuf.append(GLUE); ! sbuf.append(key); ! ! return ConfigService.getString(CONFIG_NAME, sbuf.toString()); ! } ! ! /** ! * Get user context object. get a user context object for the named user. ! * This opject is by default unauthenticated. ! * * @param name the name of the user + * * @return usercontext + * + * @throws UserException DOCUMENT ME! */ ! public IUserContext getUserContext(String name) throws UserException { ! com.babeldoc.core.LogService.getInstance().logDebug("[SimpleUserManager.getUserContext]: getting context for user: " + ! name); ! if (name.startsWith("z")) { throw new UserException("[getUserContext] invalid user"); } + return new SimpleUserContext(this, name); } /** ! * Get user context object. get a user context object for the named user. ! * This opject is by default unauthenticated. ! * * @param name the name of the user + * @param credential DOCUMENT ME! + * * @return usercontext + * + * @throws UserException DOCUMENT ME! */ public IUserContext getUserContext(String name, IUserCredential credential) *************** *** 78,86 **** --- 186,217 ---- /** + * Get the preference string for the user. This uses the configuration data + * for the simple user factory. + * + * @param user the user to get preference + * @param key the reference to the preference + * + * @return preference string + * + * @throws UserException DOCUMENT ME! + */ + public String getUserPreference(IUser user, String key) + throws UserException { + StringBuffer sbuf = new StringBuffer(USR_PREF_PREFIX); + sbuf.append(user.toString()); + sbuf.append(GLUE); + sbuf.append(key); + + return ConfigService.getString(CONFIG_NAME, sbuf.toString()); + } + + /** * Authenticate this user. Uses a simple password * * @param context * @param credential + * * @return + * * @throws UserException */ *************** *** 95,122 **** /** ! * <strong>createUser</strong> ! * ! * create a user with credentials. Migrate to Interface * ! * @param user the user ! * @param credential the users credentials ! * @throws com.babeldoc.core.user.UserException ! * @throws com.babeldoc.core.user.UserCreateException ! */ ! public IUserContext createUser(IUser user, IUserCredential credential) ! throws UserException, UserCreateException { ! throw new UserException("Not implemented"); ! } ! ! /** ! * Get organization object. ! * get a user context object for the named user. This ! * object is by default unauthenticated. If the user ! * is not found, the context object is null. * ! * @param name the name of the organization ! * @return usercontext - null if username not found. */ ! public IOrganization getOrganization(String name) throws UserException { throw new UserException("Not implemented"); --- 226,237 ---- /** ! * Create a name/value preference in the global list. * ! * @param key the preference key ! * @param value the preference value * ! * @throws UserException DOCUMENT ME! */ ! public void createGlobalPreference(String key, String value) throws UserException { throw new UserException("Not implemented"); *************** *** 124,212 **** /** ! * <strong>createOrganization</strong> ! * ! * create an organization - migrate to interface in due time. * * @param org the organization ! * @throws com.babeldoc.core.user.UserException ! */ ! public IOrganization createOrganization(IOrganization org, IOrganization parent) ! throws UserException, UserCreateException { ! throw new UserException("Not implemented"); ! } ! ! ! /** ! * <strong>deleteUser</strong> * ! * delete a user * ! * @param user the user ! * @throws com.babeldoc.core.user.UserException */ ! public void deleteUser(IUser user) ! throws UserException { throw new UserException("Not implemented"); } /** ! * <strong>deleteOrganization</strong> * ! * delete an organization * ! * @param organization the organization ! * @throws com.babeldoc.core.user.UserException */ ! public void deleteOrganization(IOrganization organization) ! throws UserException { throw new UserException("Not implemented"); } /** ! * Get the preference string for the user. This uses the configuration data for the ! * simple user factory. * ! * @param user the user to get preference ! * @param key the reference to the preference ! * @return preference string ! */ ! public String getUserPreference(IUser user, String key) ! throws UserException { ! StringBuffer sbuf = new StringBuffer(USR_PREF_PREFIX); ! sbuf.append(user.toString()); ! sbuf.append(GLUE); ! sbuf.append(key); ! return ConfigService.getString(CONFIG_NAME, sbuf.toString()); ! } ! ! /** ! * Get the preference string for the organization. This uses the configuration data for the ! * simple user factory. * ! * @param org the org to get preference ! * @param key ! * @return preference string ! */ ! public String getOrganizationPreference(IOrganization org, String key) ! throws UserException { ! StringBuffer sbuf = new StringBuffer(ORG_PREF_PREFIX); ! sbuf.append(org.toString()); ! sbuf.append(GLUE); ! sbuf.append(key); ! return ConfigService.getString(CONFIG_NAME, sbuf.toString()); ! } ! ! /** ! * Get the global preference string for the organization. This uses the configuration data for the ! * simple user factory. * ! * @param key ! * @return preference string */ ! public String getGlobalPreference(String key) ! throws UserException { ! StringBuffer sbuf = new StringBuffer(ORG_PREF_PREFIX); ! sbuf.append(key); ! return ConfigService.getString(CONFIG_NAME, sbuf.toString()); } --- 239,287 ---- /** ! * <strong>createOrganization</strong> create an organization - migrate to ! * interface in due time. * * @param org the organization ! * @param parent DOCUMENT ME! * ! * @return DOCUMENT ME! * ! * @throws UserException ! * @throws UserCreateException DOCUMENT ME! */ ! public IOrganization createOrganization(IOrganization org, ! IOrganization parent) throws UserException, UserCreateException { throw new UserException("Not implemented"); } /** ! * Create a name/value preference for this user. * ! * @param org the organization ! * @param key the preference key ! * @param value the preference value * ! * @throws UserException DOCUMENT ME! */ ! public void createOrganizationPreference(IOrganization org, String key, ! String value) throws UserException { throw new UserException("Not implemented"); } /** ! * <strong>createUser</strong> create a user with credentials. Migrate to ! * Interface * ! * @param user the user ! * @param credential the users credentials * ! * @return DOCUMENT ME! * ! * @throws UserException ! * @throws UserCreateException */ ! public IUserContext createUser(IUser user, IUserCredential credential) ! throws UserException, UserCreateException { ! throw new UserException("Not implemented"); } *************** *** 217,220 **** --- 292,297 ---- * @param key the preference key * @param value the preference value + * + * @throws UserException DOCUMENT ME! */ public void createUserPreference(IUser user, String key, String value) *************** *** 224,246 **** /** ! * Create a name/value preference for this user. * ! * @param org the organization ! * @param key the preference key ! * @param value the preference value */ ! public void createOrganizationPreference(IOrganization org, String key, String value) ! throws UserException { throw new UserException("Not implemented"); } /** ! * Create a name/value preference in the global list. * ! * @param key the preference key ! * @param value the preference value */ ! ! public void createGlobalPreference(String key, String value) throws UserException { throw new UserException("Not implemented"); --- 301,322 ---- /** ! * Delete the global preference string. * ! * @param key ! * ! * @throws UserException DOCUMENT ME! */ ! public void deleteGlobalPreference(String key) throws UserException { throw new UserException("Not implemented"); } /** ! * <strong>deleteOrganization</strong> delete an organization * ! * @param organization the organization ! * ! * @throws UserException */ ! public void deleteOrganization(IOrganization organization) throws UserException { throw new UserException("Not implemented"); *************** *** 248,257 **** /** ! * Delete the preference from the preferences table for user and key * ! * @param user the user to get preference ! * @param key the reference to the preference */ ! public void deleteUserPreference(IUser user, String key) throws UserException { throw new UserException("Not implemented"); --- 324,335 ---- /** ! * delete the preference string for the organization. * ! * @param org the organization ! * @param key to delete ! * ! * @throws UserException DOCUMENT ME! */ ! public void deleteOrganizationPreference(IOrganization org, String key) throws UserException { throw new UserException("Not implemented"); *************** *** 259,278 **** /** ! * delete the preference string for the organization. * ! * @param org the organization ! * @param key to delete */ ! public void deleteOrganizationPreference(IOrganization org, String key) ! throws UserException { throw new UserException("Not implemented"); } /** ! * Delete the global preference string. * ! * @param key */ ! public void deleteGlobalPreference(String key) throws UserException { throw new UserException("Not implemented"); --- 337,359 ---- /** ! * <strong>deleteUser</strong> delete a user * ! * @param user the user ! * ! * @throws UserException */ ! public void deleteUser(IUser user) throws UserException { throw new UserException("Not implemented"); } /** ! * Delete the preference from the preferences table for user and key * ! * @param user the user to get preference ! * @param key the reference to the preference ! * ! * @throws UserException DOCUMENT ME! */ ! public void deleteUserPreference(IUser user, String key) throws UserException { throw new UserException("Not implemented"); Index: SimpleUserResourceFactory.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/user/simple/SimpleUserResourceFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SimpleUserResourceFactory.java 15 Mar 2003 22:54:13 -0000 1.2 --- SimpleUserResourceFactory.java 27 Jun 2003 02:20:00 -0000 1.3 *************** *** 1,22 **** ! /* ! * $Header$ ! * $DateTime: 2002/07/21 17:01:20 $ * * ! * babeldoc: universal document processor * ! * This program is free software; you can redistribute it and/or ! * modify it under the terms of the GNU General Public License ! * as published by the Free Software Foundation; either version 2 ! * of the License, or (at your option) any later version. * ! * This program is distributed in the hope that it will be useful, ! * but WITHOUT ANY WARRANTY; without even the implied warranty of ! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ! * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package com.babeldoc.core.user.simple; --- 1,66 ---- ! /* ==================================================================== ! * The Apache Software License, Version 1.1 * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: * ! * 1. Redistributions of source code must retain the above copyright ! * notice, this list of conditions and the following disclaimer. * ! * 2. Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in ! * the documentation and/or other materials provided with the ! * distribution. ! * ! * 3. The end-user documentation included with the redistribution, ! * if any, must include the following acknowledgment: ! * "This product includes software developed by the ! * Apache Software Foundation (http://www.apache.org/)." ! * Alternately, this acknowledgment may appear in the software itself, ! * if and wherever such third-party acknowledgments normally appear. ! * ! * 4. The names "Apache" and "Apache Software Foundation" must ! * not be used to endorse or promote products derived from this ! * software without prior written permission. For written ! * permission, please contact ap...@ap.... ! * ! * 5. Products derived from this software may not be called "Apache", ! * nor may "Apache" appear in their name, without prior written ! * permission of the Apache Software Foundation. ! * ! * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ! * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES ! * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ! * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ! * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ! * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ! * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ! * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ! * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ! * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ! * SUCH DAMAGE. ! * ==================================================================== ! * ! * This software consists of voluntary contributions made by many ! * individuals on behalf of the Apache Software Foundation. For more ! * information on the Apache Software Foundation, please see ! * <http://www.apache.org/>. ! * ! * Portions of this software are based upon public domain software ! * originally written at the National Center for Supercomputing Applications, ! * University of Illinois, Urbana-Champaign. ! * ==================================================================== ! * ! * Babeldoc: The Universal Document Processor ! * ! * $Header$ ! * $DateTime$ ! * $Author$ * */ package com.babeldoc.core.user.simple; *************** *** 24,27 **** --- 68,72 ---- import com.babeldoc.core.user.*; + /** * SimpleResourceManager - class to manager user resouces. *************** *** 30,78 **** * @version 1.0 */ ! public class SimpleUserResourceFactory ! implements IUserResourceFactory { ! ! /** ! * Get the named user resource ! * @param name the name of the resource ! * @return the associated resource. ! */ ! public UserResource getUserResource(String name) { ! return new UserResource(name); ! } ! /** ! * Must this resource be authenticated? This is a default operation - you will need ! * to provide a decent implementation. * ! * @param resource that may need to be authenticated ! * @return true - user needs to log on, false - access allowed. */ ! public boolean mustAuthenticate(UserResource resource) { ! ! // handle velocity macro pages. ! if (resource.getName().indexOf(".vm") > 0) { ! if (resource.getName().indexOf('/') == resource.getName().lastIndexOf('/')) { ! return false; ! } ! } return true; } /** ! * Can this user access this resource ! * @param user the user in question. ! * @param the resource in question. */ ! public boolean isAuthorized(IUserContext user, UserResource resource) { ! return true; } /** ! * addResource ! * Add a resource for a user. * * @param userResource * @param user */ public void addResource(UserResource userResource, IUser user) --- 75,109 ---- * @version 1.0 */ ! public class SimpleUserResourceFactory implements IUserResourceFactory { /** ! * Can this user access this resource * ! * @param user the user in question. ! * @param resource resource in question. ! * ! * @return DOCUMENT ME! */ ! public boolean isAuthorized(IUserContext user, UserResource resource) { return true; } /** ! * Get the named user resource ! * ! * @param name the name of the resource ! * ! * @return the associated resource. */ ! public UserResource getUserResource(String name) { ! return new UserResource(name); } /** ! * addResource Add a resource for a user. * * @param userResource * @param user + * + * @throws UserException DOCUMENT ME! */ public void addResource(UserResource userResource, IUser user) *************** *** 82,92 **** /** ! * addResource ! * Add a resource for an organization. * * @param userResource * @param organization */ - public void addResource(UserResource userResource, IOrganization organization) throws UserException { --- 113,123 ---- /** ! * addResource Add a resource for an organization. * * @param userResource * @param organization + * + * @throws UserException DOCUMENT ME! */ public void addResource(UserResource userResource, IOrganization organization) throws UserException { *************** *** 98,105 **** --- 129,157 ---- * * @param userResource + * + * @throws UserException DOCUMENT ME! */ public void deleteResource(UserResource userResource) throws UserException { throw new UserException("Not implemented"); + } + + /** + * Must this resource be authenticated? This is a default operation - you + * will need to provide a decent implementation. + * + * @param resource that may need to be authenticated + * + * @return true - user needs to log on, false - access allowed. + */ + public boolean mustAuthenticate(UserResource resource) { + // handle velocity macro pages. + if (resource.getName().indexOf(".vm") > 0) { + if (resource.getName().indexOf('/') == resource.getName().lastIndexOf('/')) { + return false; + } + } + + return true; } } |