/*
- * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/config/SecurityConfig.java,v 1.13 2003/10/25 11:58:55 maxcooper Exp $
- * $Revision: 1.13 $
- * $Date: 2003/10/25 11:58:55 $
+ * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/config/SecurityConfig.java,v 1.14 2003/11/25 10:15:47 maxcooper Exp $
+ * $Revision: 1.14 $
+ * $Date: 2003/11/25 10:15:47 $
*
* ====================================================================
* The SecurityFilter Software License, Version 1.1
package org.securityfilter.config;
import org.apache.commons.digester.Digester;
+import org.securityfilter.persistent.PersistentLoginManagerInterface;
import org.securityfilter.realm.SecurityRealmInterface;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
+import org.xml.sax.*;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
+import java.lang.reflect.*;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
/**
* SecurityConfig gathers information from the security-config.xml file to be used by the filter.
* @author Torgeir Veimo (torgeir@pobox.com)
* @author Max Cooper (max@maxcooper.com)
* @author Daya Sharma (iamdaya@yahoo.com, billydaya@sbcglobal.net)
- * @version $Revision: 1.13 $ $Date: 2003/10/25 11:58:55 $
+ * @author David Reed (dreed10@neo.rr.com)
+ * @version $Revision: 1.14 $ $Date: 2003/11/25 10:15:47 $
*/
public class SecurityConfig {
private String loginPage = null;
private String errorPage = null;
+ private String logoutPage = null;
private String defaultPage = null;
private ArrayList securityConstraints = null;
private SecurityRealmInterface realm = null;
+ private PersistentLoginManagerInterface persistentLoginManager;
private Object lastRealm = null;
private boolean validating;
private String authMethod;
}
/**
+ * Return the logout page URL.
+ */
+ public String getLogoutPage() {
+ return logoutPage;
+ }
+
+ /**
+ * Set the logout page URL.
+ *
+ * @param logoutPage The logout page url (relative to site root)
+ */
+ public void setLogoutPage(String logoutPage) {
+ this.logoutPage = logoutPage;
+ }
+
+ /**
* Return the default page URL.
*/
public String getDefaultPage() {
*
* @return BASIC or FORM
*/
- public String getAuthMethod() {
- return authMethod;
- }
+ public String getAuthMethod() {
+ return authMethod;
+ }
/**
* Set the authentication method being used to challenge the user.
* @param authMethod The authentication method to be used by the filter
*/
public void setAuthMethod(String authMethod) {
- this.authMethod = authMethod;
+ this.authMethod = authMethod;
}
/**
*
* @return the realm-name configured by the application developer
*/
- public String getRealmName() {
- return realmName;
- }
+ public String getRealmName() {
+ return realmName;
+ }
/**
* Set the authentication realm name.
* @param realmName the realm name to be used for BASIC authentication
*/
public void setRealmName(String realmName) {
- this.realmName = realmName;
+ this.realmName = realmName;
}
/**
} else {
// TODO: allow addRealm signaure to take types besides Object -- will commons-beanutils help?
// call lastRealm.setRealm(realm)
- Method addMethod = lastRealm.getClass().getMethod("setRealm", new Class[] { Object.class });
- addMethod.invoke(lastRealm, new Object[] { realm });
+ Method addMethod = lastRealm.getClass().getMethod("setRealm", new Class[]{Object.class});
+ addMethod.invoke(lastRealm, new Object[]{realm});
lastRealm = realm;
}
}
}
/**
+ * Adds a StickyLoginManager to be used for persisting logins.
+ *
+ * @param loginManager StickyLoginManager to use for this implementation
+ */
+ public synchronized void addStickyLoginManager(
+ Object loginManager
+ ) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ this.persistentLoginManager = (PersistentLoginManagerInterface) loginManager;
+ }
+
+ /**
+ * Return the StickyLoginManager used for this implementation
+ */
+ public PersistentLoginManagerInterface getPersistentLoginManager() {
+ return persistentLoginManager;
+ }
+
+ /**
* Loads configuration from the specifued configURL.
*
* @param configURL The url to load.
digester.addSetProperty("securityfilter-config/realm/realm-param", "name", "value");
digester.addSetNext("securityfilter-config/realm", "addRealm", "java.lang.Object");
- // login and error pages
+ // auth method, realm name
digester.addCallMethod("securityfilter-config/login-config/auth-method", "setAuthMethod", 0);
digester.addCallMethod("securityfilter-config/login-config/realm-name", "setRealmName", 0);
+
+ // login, error, logout, and default pages
digester.addCallMethod("securityfilter-config/login-config/form-login-config/form-login-page", "setLoginPage", 0);
digester.addCallMethod("securityfilter-config/login-config/form-login-config/form-error-page", "setErrorPage", 0);
digester.addCallMethod(
+ "securityfilter-config/login-config/form-login-config/form-logout-page",
+ "setLogoutPage",
+ 0
+ );
+ digester.addCallMethod(
"securityfilter-config/login-config/form-login-config/form-default-page",
"setDefaultPage",
0
);
+ // remember me plugin
+ digester.addObjectCreate("securityfilter-config/login-config/remember-me", null, "className");
+ digester.addSetProperty("securityfilter-config/login-config/remember-me/remember-me-param", "name", "value");
+ digester.addSetNext(
+ "securityfilter-config/login-config/remember-me",
+ "addPersistentLoginManager",
+ "java.lang.Object"
+ );
+
// security-constraint
digester.addObjectCreate(
"securityfilter-config/security-constraint",
if (dtd1_1 != null) {
digester.register("-//SecurityFilter.org//DTD Security Filter Configuration 1.1//EN", dtd1_1.toString());
}
+
+ // register the local version of the 2.0 DTD, if it is available
+ URL dtd2_0 = this.getClass().getResource("/org/securityfilter/resources/securityfilter-config_2_0.dtd");
+ if (dtd2_0 != null) {
+ digester.register("-//SecurityFilter.org//DTD Security Filter Configuration 2.0//EN", dtd2_0.toString());
+ }
}
}