cmlenz 2003/06/15 09:28:00
Modified: framework/src/java/share/org/apache/cactus/client/connector/http
HttpClientConnectionHelper.java
JdkConnectionHelper.java
documentation/docs/xdocs changes.xml
framework/src/java/share/org/apache/cactus/client/authentication
AbstractAuthentication.java
documentation/docs/xdocs/writing howto_security.xml
framework/src/java/share/org/apache/cactus
BaseWebRequest.java
Added: framework/src/java/share/org/apache/cactus/client/authentication
Authentication.java
Log:
Add an Authentication interface which AbstractAuthentication implements.
Update the docs about testing with authentication.
Revision Changes Path
1.5 +3 -3
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/HttpClientConnectionHelper.java
Index: HttpClientConnectionHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/HttpClientConnectionHelper.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- HttpClientConnectionHelper.java 5 May 2003 19:14:07 -0000 1.4
+++ HttpClientConnectionHelper.java 15 Jun 2003 16:27:59 -0000 1.5
@@ -66,7 +66,7 @@
import java.util.List;
import org.apache.cactus.WebRequest;
-import org.apache.cactus.client.authentication.AbstractAuthentication;
+import org.apache.cactus.client.authentication.Authentication;
import org.apache.cactus.configuration.Configuration;
import org.apache.cactus.util.UrlUtil;
import org.apache.commons.httpclient.HostConfiguration;
@@ -117,7 +117,7 @@
// Add Authentication headers, if necessary. This is the first
// step to allow authentication to add extra headers, HTTP parameters,
// etc.
- AbstractAuthentication authentication = theRequest.getAuthentication();
+ Authentication authentication = theRequest.getAuthentication();
if (authentication != null)
{
1.4 +3 -4
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/JdkConnectionHelper.java
Index: JdkConnectionHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/JdkConnectionHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JdkConnectionHelper.java 26 May 2003 11:45:26 -0000 1.3
+++ JdkConnectionHelper.java 15 Jun 2003 16:27:59 -0000 1.4
@@ -69,7 +69,7 @@
import java.util.Enumeration;
import org.apache.cactus.WebRequest;
-import org.apache.cactus.client.authentication.AbstractAuthentication;
+import org.apache.cactus.client.authentication.Authentication;
import org.apache.cactus.configuration.Configuration;
import org.apache.cactus.util.ChainedRuntimeException;
import org.apache.commons.logging.Log;
@@ -124,13 +124,12 @@
// Add Authentication headers, if necessary. This is the first
// step to allow authentication to add extra headers, HTTP parameters,
// etc.
- AbstractAuthentication authentication = theRequest.getAuthentication();
+ Authentication authentication = theRequest.getAuthentication();
if (authentication != null)
{
authentication.configure(theRequest, theConfiguration);
}
-
// Add the parameters that need to be passed as part of the URL
url = addParametersGet(theRequest, url);
1.106 +5 -0 jakarta-cactus/documentation/docs/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- changes.xml 11 Jun 2003 12:39:26 -0000 1.105
+++ changes.xml 15 Jun 2003 16:28:00 -0000 1.106
@@ -65,6 +65,11 @@
</devs>
<release version="1.5" date="- in CVS">
+ <action dev="CML" type="update">
+ Refactored the authentication support by introducing the interface
+ <code>Authentication</code>, which the class
+ <code>AbstractAuthentication</code> now implements.
+ </action>
<action dev="VMA" type="add">
Added a quick tutorial for Cactus developers who want to
<a href="site:integration_eclipse_dev">set up their Eclipse
1.10 +14 -28
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/AbstractAuthentication.java
Index: AbstractAuthentication.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/AbstractAuthentication.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AbstractAuthentication.java 26 May 2003 11:45:26 -0000 1.9
+++ AbstractAuthentication.java 15 Jun 2003 16:28:00 -0000 1.10
@@ -56,9 +56,6 @@
*/
package org.apache.cactus.client.authentication;
-import org.apache.cactus.WebRequest;
-import org.apache.cactus.configuration.Configuration;
-
/**
* This class was designed with the simple assumption that ALL authentication
* implementations will have a String <code>Name</code> and a String
@@ -72,12 +69,13 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Robertson</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
*
* @since 1.3
*
* @version $Id$
*/
-public abstract class AbstractAuthentication
+public abstract class AbstractAuthentication implements Authentication
{
/**
* User name part of the Credential
@@ -104,7 +102,7 @@
*
* @param theName user name of the Credential
*/
- public void setName(String theName)
+ public final void setName(String theName)
{
validateName(theName);
this.name = theName;
@@ -113,7 +111,7 @@
/**
* @return the user name of the Credential
*/
- public String getName()
+ public final String getName()
{
return this.name;
}
@@ -123,13 +121,21 @@
*
* @param thePassword the user password of the Credential
*/
- public void setPassword(String thePassword)
+ public final void setPassword(String thePassword)
{
validatePassword(thePassword);
this.password = thePassword;
}
/**
+ * @return the user password of the Credential
+ */
+ protected final String getPassword()
+ {
+ return this.password;
+ }
+
+ /**
* Verify that the user name passed as parameter is a valid user name
* for the current authentication scheme.
*
@@ -145,24 +151,4 @@
*/
protected abstract void validatePassword(String thePassword);
- /**
- * Modify the <code>WebRequest</code> passed as parameter so
- * that it will carry authentication information.
- *
- * @param theRequest the request object that will be sent to the Cactus
- * Redirector over HTTP
- * @param theConfiguration the Cactus configuration so that
- * authentication methods can get access to Cactus configuration
- * properties
- */
- public abstract void configure(WebRequest theRequest,
- Configuration theConfiguration);
-
- /**
- * @return the user password of the Credential
- */
- protected String getPassword()
- {
- return this.password;
- }
}
1.1
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/authentication/Authentication.java
Index: Authentication.java
===================================================================
/*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus" 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 [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* 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/>.
*
*/
package org.apache.cactus.client.authentication;
import org.apache.cactus.WebRequest;
import org.apache.cactus.configuration.Configuration;
/**
* Interface for different authentication modules. An authentication class is
* invoked on the client side to perform the actual authentication, for example
* by modifying the request to includes credentials.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Robertson</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Christopher Lenz</a>
*
* @since 1.5
*
* @version $Id: Authentication.java,v 1.1 2003/06/15 16:28:00 cmlenz Exp $
*/
public interface Authentication
{
/**
* Modifies the request so that it will carry authentication information.
*
* @param theRequest The request object that will be sent to the Cactus
* Redirector over HTTP
* @param theConfiguration The Cactus configuration so that
* authentication methods can get access to Cactus configuration
* properties
*/
void configure(WebRequest theRequest, Configuration theConfiguration);
}
1.4 +8 -8
jakarta-cactus/documentation/docs/xdocs/writing/howto_security.xml
Index: howto_security.xml
===================================================================
RCS file:
/home/cvs/jakarta-cactus/documentation/docs/xdocs/writing/howto_security.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- howto_security.xml 18 Jan 2003 00:08:34 -0000 1.3
+++ howto_security.xml 15 Jun 2003 16:28:00 -0000 1.4
@@ -17,6 +17,7 @@
Beginning with version 1.3, Cactus is able to unit test Servlet code
that uses the Servlet Security API (<code>getRemoteUser()</code>,
<code>isUserInRole()</code>, <code>getUserPrincipal()</code>).
+ Cactus supports the BASIC and FORM authentication methods.
</p>
<p>
The way to perform this is by securing a Servlet Redirector defined
@@ -25,11 +26,6 @@
</p>
<note>
- The only currently supported authentication mechanism in Cactus 1.3 is
- the BASIC authentication.
- </note>
-
- <note>
The Cactus sample application demonstrates how to unit test everything
that is explained here.
</note>
@@ -78,9 +74,13 @@
</li>
<li>
<code>WebRequest.setAuthentication()</code> is used to pass
- credentials to the server. It takes a parameter which is a
- <code>BasicAuthentication</code> object (the only type of
- authentication currently supported by Cactus).
+ credentials to the server. It takes an implementation of the
+ <code>Authentication</code> interface as argument. In this example,
+ we pass in a <code>BasicAuthentication</code> which corresponds to
+ the BASIC authentication method. Testing with form-based
+ authentication just involves using the
+ <code>FormAuthentication</code> class instead of
+ <code>BasicAuthentication</code>.
</li>
</ul>
1.6 +8 -9
jakarta-cactus/framework/src/java/share/org/apache/cactus/BaseWebRequest.java
Index: BaseWebRequest.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/BaseWebRequest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- BaseWebRequest.java 26 May 2003 11:45:23 -0000 1.5
+++ BaseWebRequest.java 15 Jun 2003 16:28:00 -0000 1.6
@@ -62,7 +62,7 @@
import java.util.Hashtable;
import java.util.Vector;
-import org.apache.cactus.client.authentication.AbstractAuthentication;
+import org.apache.cactus.client.authentication.Authentication;
import org.apache.cactus.configuration.Configuration;
import org.apache.cactus.util.ChainedRuntimeException;
@@ -126,7 +126,7 @@
/**
* The Authentication Object that will configure the http request
*/
- private AbstractAuthentication authentication;
+ private Authentication authentication;
/**
* Default constructor that requires that
@@ -674,18 +674,17 @@
/**
* Sets the authentication object that will configure the http request
*
- * @param theAuthenticationObject the authentication object
+ * @param theAuthentication the authentication object
*/
- public void setAuthentication(
- AbstractAuthentication theAuthenticationObject)
+ public void setAuthentication(Authentication theAuthentication)
{
- this.authentication = theAuthenticationObject;
+ this.authentication = theAuthentication;
}
/**
- * @return the authentication object that will configure the http request
+ * @return the authentication that will configure the http request
*/
- public AbstractAuthentication getAuthentication()
+ public Authentication getAuthentication()
{
return this.authentication;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]