From: maxcooper Date: Wed, 14 Aug 2002 11:26:31 +0000 (+0000) Subject: class name change: SecurityRealmBase --> SimpleSecurityRealmBase X-Git-Tag: REL-1_0_b2~7 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=53ef94127216b97b98afbdd78bf68267c4eed413;p=securityfilter.git class name change: SecurityRealmBase --> SimpleSecurityRealmBase --- diff --git a/README b/README index 51437e9..66f6208 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ -$Id: README,v 1.4 2002/08/12 02:53:54 maxcooper Exp $ -$Revision: 1.4 $ -$Date: 2002/08/12 02:53:54 $ +$Id: README,v 1.5 2002/08/14 11:26:31 maxcooper Exp $ +$Revision: 1.5 $ +$Date: 2002/08/14 11:26:31 $ Security Filter v1.0-b2-dev @@ -56,7 +56,7 @@ to it (with a url pattern like '/*' -- for examples, see web.xml in the example apps). 2. Create a SecurityRealmInterface implementation (from scratch, or by extending -SecurityRealmBase). You can also use a Tomcat (Catalina) realm with the +SimpleSecurityRealmBase). You can also use a Tomcat (Catalina) realm with the CatalinaRealmAdapter (see securityfilter-catalina-example app for details). If you create your own realm adapter class, be sure to include a setRealm(Object realm) method so the filter can properly nest your realms at run time. Only the diff --git a/src/example/org/securityfilter/example/TrivialSecurityRealm.java b/src/example/org/securityfilter/example/TrivialSecurityRealm.java index 486ad18..2e3f0d9 100644 --- a/src/example/org/securityfilter/example/TrivialSecurityRealm.java +++ b/src/example/org/securityfilter/example/TrivialSecurityRealm.java @@ -1,7 +1,7 @@ /* - * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/Attic/TrivialSecurityRealm.java,v 1.2 2002/08/09 08:36:08 maxcooper Exp $ - * $Revision: 1.2 $ - * $Date: 2002/08/09 08:36:08 $ + * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/Attic/TrivialSecurityRealm.java,v 1.3 2002/08/14 11:26:31 maxcooper Exp $ + * $Revision: 1.3 $ + * $Date: 2002/08/14 11:26:31 $ * * ==================================================================== * The SecurityFilter Software License, Version 1.1 @@ -55,7 +55,7 @@ package org.securityfilter.example; -import org.securityfilter.realm.SecurityRealmBase; +import org.securityfilter.realm.SimpleSecurityRealmBase; /** * Trivial implementation of the SecurityRealmInterface. @@ -64,9 +64,9 @@ import org.securityfilter.realm.SecurityRealmBase; * And this user is in one role: 'inthisrole' * * @author Max Cooper (max@maxcooper.com) - * @version $Revision: 1.2 $ $Date: 2002/08/09 08:36:08 $ + * @version $Revision: 1.3 $ $Date: 2002/08/14 11:26:31 $ */ -public class TrivialSecurityRealm extends SecurityRealmBase { +public class TrivialSecurityRealm extends SimpleSecurityRealmBase { private static final String THE_USERNAME = "username"; private static final String THE_PASSWORD = "password"; private static final String THE_ROLE = "inthisrole"; diff --git a/src/share/org/securityfilter/realm/SecurityRealmBase.java b/src/share/org/securityfilter/realm/SecurityRealmBase.java deleted file mode 100644 index bd909ac..0000000 --- a/src/share/org/securityfilter/realm/SecurityRealmBase.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/realm/Attic/SecurityRealmBase.java,v 1.2 2002/08/09 08:36:07 maxcooper Exp $ - * $Revision: 1.2 $ - * $Date: 2002/08/09 08:36:07 $ - * - * ==================================================================== - * The SecurityFilter Software License, Version 1.1 - * - * (this license is derived and fully compatible with the Apache Software - * License - see http://www.apache.org/LICENSE.txt) - * - * Copyright (c) 2002 SecurityFilter.org. 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 - * SecurityFilter.org (http://www.securityfilter.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The name "SecurityFilter" must not be used to endorse or promote - * products derived from this software without prior written permission. - * For written permission, please contact license@securityfilter.org . - * - * 5. Products derived from this software may not be called "SecurityFilter", - * nor may "SecurityFilter" appear in their name, without prior written - * permission of SecurityFilter.org. - * - * 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. - * ==================================================================== - */ - -package org.securityfilter.realm; - -import java.security.Principal; - -/** - * Security realm base class. This class insulates you from having to create or process Principal - * objects. You can implement a realm by overriding the two methods that neither take or return - * a Principal object and this class does the conversions for you. - * - * @author Max Cooper (max@maxcooper.com) - */ -public class SecurityRealmBase implements SecurityRealmInterface { - - /** - * Authenticate a user. - * - * Override this method in a subclass to avoid dealing with Principal objects. - * - * @param username a username - * @param password a plain text password, as entered by the user - * - * @return true if the username/password combination is valid, false otherwise - */ - public boolean booleanAuthenticate(String username, String password) { - return false; - } - - /** - * Test for role membership. - * - * Override this method in a subclass to avoid dealing with Principal objects. - * - * @param username a username - * @param rolename name of a role to test for membership - * - * @return true if the user is in the role, false otherwise - */ - public boolean isUserInRole(String username, String rolename) { - return false; - } - - /** - * Authenticate a user. - * - * @param username a username - * @param password a plain text password, as entered by the user - * - * @return a Principal object representing the user if successful, false otherwise - */ - public Principal authenticate(final String username, String password) { - if (booleanAuthenticate(username, password)) { - return new Principal() { - public String getName() { - return username; - } - }; - } else { - return null; - } - } - - /** - * Test for role membership. - * - * Use Principal.getName() to get the username from the principal object. - * - * @param principal Principal object representing a user - * @param rolename name of a role to test for membership - * - * @return true if the user is in the role, false otherwise - */ - public boolean isUserInRole(Principal principal, String rolename) { - return isUserInRole(principal.getName(), rolename); - } -} - -// ---------------------------------------------------------------------------- -// EOF \ No newline at end of file diff --git a/src/share/org/securityfilter/realm/SimpleSecurityRealmBase.java b/src/share/org/securityfilter/realm/SimpleSecurityRealmBase.java new file mode 100644 index 0000000..9032951 --- /dev/null +++ b/src/share/org/securityfilter/realm/SimpleSecurityRealmBase.java @@ -0,0 +1,133 @@ +/* + * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/realm/SimpleSecurityRealmBase.java,v 1.1 2002/08/14 11:26:31 maxcooper Exp $ + * $Revision: 1.1 $ + * $Date: 2002/08/14 11:26:31 $ + * + * ==================================================================== + * The SecurityFilter Software License, Version 1.1 + * + * (this license is derived and fully compatible with the Apache Software + * License - see http://www.apache.org/LICENSE.txt) + * + * Copyright (c) 2002 SecurityFilter.org. 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 + * SecurityFilter.org (http://www.securityfilter.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The name "SecurityFilter" must not be used to endorse or promote + * products derived from this software without prior written permission. + * For written permission, please contact license@securityfilter.org . + * + * 5. Products derived from this software may not be called "SecurityFilter", + * nor may "SecurityFilter" appear in their name, without prior written + * permission of SecurityFilter.org. + * + * 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. + * ==================================================================== + */ + +package org.securityfilter.realm; + +import java.security.Principal; + +/** + * Security realm base class. This class insulates you from having to create or process Principal + * objects. You can implement a realm by overriding the two methods that neither take or return + * a Principal object and this class does the conversions for you. + * + * @author Max Cooper (max@maxcooper.com) + */ +public class SimpleSecurityRealmBase implements SecurityRealmInterface { + + /** + * Authenticate a user. + * + * Override this method in a subclass to avoid dealing with Principal objects. + * + * @param username a username + * @param password a plain text password, as entered by the user + * + * @return true if the username/password combination is valid, false otherwise + */ + public boolean booleanAuthenticate(String username, String password) { + return false; + } + + /** + * Test for role membership. + * + * Override this method in a subclass to avoid dealing with Principal objects. + * + * @param username a username + * @param rolename name of a role to test for membership + * + * @return true if the user is in the role, false otherwise + */ + public boolean isUserInRole(String username, String rolename) { + return false; + } + + /** + * Authenticate a user. + * + * @param username a username + * @param password a plain text password, as entered by the user + * + * @return a Principal object representing the user if successful, false otherwise + */ + public Principal authenticate(final String username, String password) { + if (booleanAuthenticate(username, password)) { + return new Principal() { + public String getName() { + return username; + } + }; + } else { + return null; + } + } + + /** + * Test for role membership. + * + * Use Principal.getName() to get the username from the principal object. + * + * @param principal Principal object representing a user + * @param rolename name of a role to test for membership + * + * @return true if the user is in the role, false otherwise + */ + public boolean isUserInRole(Principal principal, String rolename) { + return isUserInRole(principal.getName(), rolename); + } +} + +// ---------------------------------------------------------------------------- +// EOF \ No newline at end of file