--- /dev/null
+/*
+ * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/Constants.java,v 1.1 2003/06/09 10:59:42 maxcooper Exp $
+ * $Revision: 1.1 $
+ * $Date: 2003/06/09 10:59:42 $
+ *
+ * ====================================================================
+ * 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 SECURITY FILTER PROJECT 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.example;
+
+/**
+ * Constants - constants for the example applications to facilitate testing
+ *
+ * @author Max Cooper (max@maxcooper.com)
+ * @version $Revision: 1.1 $ $Date: 2003/06/09 10:59:42 $
+ */
+public interface Constants {
+
+ // shared constants
+ public static final String COMMON_TITLE_BASE = "SecurityFilter Example Application: ";
+ public static final String VALID_USERNAME = "username";
+ public static final String VALID_PASSWORD = "password";
+ public static final String VALID_ROLE = "inthisrole";
+
+ // login form constants
+ public static final String LOGIN_TITLE = COMMON_TITLE_BASE + "Login Page";
+ public static final String LOGIN_FORM_ID = "login";
+ public static final String LOGIN_FORM_ACTION = "j_security_check";
+ public static final String LOGIN_USERNAME_FIELD = "j_username";
+ public static final String LOGIN_PASSWORD_FIELD = "j_password";
+
+ // secure page constants
+ public static final String SECURE_TITLE = COMMON_TITLE_BASE + "Secure Page";
+}
/*
- * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/Attic/TrivialSecurityRealm.java,v 1.7 2003/02/07 11:17:23 maxcooper Exp $
- * $Revision: 1.7 $
- * $Date: 2003/02/07 11:17:23 $
+ * $Header: /cvsroot/securityfilter/securityfilter/src/example/org/securityfilter/example/Attic/TrivialSecurityRealm.java,v 1.8 2003/06/09 10:59:42 maxcooper Exp $
+ * $Revision: 1.8 $
+ * $Date: 2003/06/09 10:59:42 $
*
* ====================================================================
* The SecurityFilter Software License, Version 1.1
* And this user is in one role: 'inthisrole'
*
* @author Max Cooper (max@maxcooper.com)
- * @version $Revision: 1.7 $ $Date: 2003/02/07 11:17:23 $
+ * @version $Revision: 1.8 $ $Date: 2003/06/09 10:59:42 $
*/
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";
private String exampleProperty;
-
+
/**
* Authenticate a user.
*
* @return null if the user cannot be authenticated, otherwise a Pricipal object is returned
*/
public boolean booleanAuthenticate(String username, String password) {
- return THE_USERNAME.equals(username) && THE_PASSWORD.equals(password);
+ return Constants.VALID_USERNAME.equals(username) && Constants.VALID_PASSWORD.equals(password);
}
/**
* @return true if the user is in the role, false otherwise
*/
public boolean isUserInRole(String username, String role) {
- return THE_USERNAME.equals(username) && THE_ROLE.equals(role);
+ return Constants.VALID_USERNAME.equals(username) && Constants.VALID_ROLE.equals(role);
}
/**
+<%@ page import="org.securityfilter.example.Constants"%>
+
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-<title>SecurityFilter Example Application: Login Form</title>
+<title><%=Constants.LOGIN_TITLE%></title>
</head>
<body>
-<h1>SecurityFilter Example Application: Login Form</h1>
+
+<h1><%=Constants.LOGIN_TITLE%></h1>
+
<%@include file="/menu.jsp" %>
-Login with username=<i>username</i> and password=<i>password</i>.
-<form action="logMeIn" method="POST">
-Username: <input type="text" name="j_username" value="username"><p>
-Password: <input type="password" name="j_password" value="password"><p>
+
+Login with username=<i><%=Constants.VALID_USERNAME%></i>
+and password=<i><%=Constants.VALID_PASSWORD%></i>.
+
+<form id="<%=Constants.LOGIN_FORM_ID%>" action="<%=Constants.LOGIN_FORM_ACTION%>" method="POST">
+
+Username:
+<input type="text"
+ name="<%=Constants.LOGIN_USERNAME_FIELD%>"
+ value="<%=Constants.VALID_USERNAME%>"
+><p>
+
+Password:
+<input type="password"
+ name="<%=Constants.LOGIN_PASSWORD_FIELD%>"
+ value="<%=Constants.VALID_PASSWORD%>"
+><p>
+
<input type="Submit">
+
</form>
</body>
</html>
\ No newline at end of file