crafterm 2003/07/09 02:51:29
Modified: sourceresolve build.xml default.properties
sourceresolve/src/java/org/apache/excalibur/source/impl
HTTPClientSourceFactory.java
Added: sourceresolve/src/java/org/apache/excalibur/source/impl
HTTPSClientSourceFactory.java
Log:
Initial commit of HTTPSClientSourceFactory, a SourceFactory that
can create Source objects capable of supporting HTTPS URI's.
HTTPSClientSourceFactory is conditionally compiled in based on the
presence of the jsse jar (included by default in JDK 1.4, extra
jar required for JDK 1.3).
It accepts 2 configuration parameters, the SSL provider
(eg. com.sun.net.ssl.internal.ssl.Provider), and
optionally an SSL socket factory depending on your security
requirements.
The underlying implementation uses the Commons HTTP Client
library via the HTTPClientSourceFactory.
Revision Changes Path
1.46 +8 -2 avalon-excalibur/sourceresolve/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/avalon-excalibur/sourceresolve/build.xml,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- build.xml 7 Jul 2003 16:50:42 -0000 1.45
+++ build.xml 9 Jul 2003 09:51:28 -0000 1.46
@@ -16,6 +16,7 @@
<pathelement location="${avalon-framework.jar}"/>
<pathelement location="${checkstyle.jar}"/>
<pathelement location="${commons-httpclient.jar}"/>
+ <pathelement location="${jsse.jar}"/>
<pathelement path="${java.class.path}"/>
</path>
@@ -45,6 +46,9 @@
<available property="commons-logging.present"
classname="org.apache.commons.logging.LogSource">
<classpath refid="test.class.path"/>
</available>
+ <available property="jsse.present"
classname="com.sun.net.ssl.internal.ssl.Provider">
+ <classpath refid="project.class.path"/>
+ </available>
</target>
<target name="dependencies" description="Check dependencies"
unless="skip.dependencies">
@@ -74,8 +78,10 @@
target="1.2">
<classpath refid="project.class.path" />
<include name="**/*.java"/>
- <exclude name="**/HTTPClient*"
+ <exclude name="**/HTTPClient*"
unless="commons-httpclient.present"/>
+ <exclude name="**/HTTPSClient*"
+ unless="jsse.present"/>
</javac>
<!-- copy resources to same location as .class files -->
@@ -198,7 +204,7 @@
<classpath refid="test.class.path"/>
<formatter type="xml"/> <!-- xml reports for junitreport -->
- <formatter type="plain" usefile="false"/> <!-- text reports for humans
-->
+ <formatter type="plain" usefile="true"/> <!-- text reports for humans
-->
<batchtest todir="${build.tests}">
<fileset dir="${build.testclasses}">
1.17 +2 -0 avalon-excalibur/sourceresolve/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/avalon-excalibur/sourceresolve/default.properties,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- default.properties 2 Jul 2003 13:23:45 -0000 1.16
+++ default.properties 9 Jul 2003 09:51:28 -0000 1.17
@@ -83,5 +83,7 @@
# commons logging (required by commons http client)
commons-logging.jar = ../lib/commons-logging-1.0.3.jar
+jsse.jar = ../lib/jsse-1.0.3_02.jar
+
depchecker.prefix=.
1.4 +2 -2
avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/HTTPClientSourceFactory.java
Index: HTTPClientSourceFactory.java
===================================================================
RCS file:
/home/cvs/avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/HTTPClientSourceFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- HTTPClientSourceFactory.java 3 Jul 2003 14:40:48 -0000 1.3
+++ HTTPClientSourceFactory.java 9 Jul 2003 09:51:29 -0000 1.4
@@ -80,7 +80,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id$
*/
-public final class HTTPClientSourceFactory extends AbstractLogEnabled
+public class HTTPClientSourceFactory extends AbstractLogEnabled
implements SourceFactory, Parameterizable, ThreadSafe
{
/**
1.1
avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/HTTPSClientSourceFactory.java
Index: HTTPSClientSourceFactory.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 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 "Jakarta", "Avalon", 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 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/>.
*/
package org.apache.excalibur.source.impl;
import java.security.Provider;
import java.security.Security;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
import org.apache.excalibur.source.SourceFactory;
/**
* [EMAIL PROTECTED] HTTPSClientSource} Factory class.
*
* @avalon.component
* @avalon.service type=SourceFactory
* @x-avalon.info name=httpsclient-source
* @x-avalon.lifestyle type=singleton
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: HTTPSClientSourceFactory.java,v 1.1 2003/07/09 09:51:29
crafterm Exp $
*/
public class HTTPSClientSourceFactory extends HTTPClientSourceFactory
{
/**
* SSL implementation provider.
*/
public static final String SSL_PROVIDER = "provider";
/**
* SSL socket factory.
*/
public static final String SOCKET_FACTORY = "socket-factory";
/**
* HTTPS constant.
*/
public static final String HTTPS = "https";
/**
* Parameterize this [EMAIL PROTECTED] SourceFactory}.
*
* @param params [EMAIL PROTECTED] Parameters} instance
* @exception ParameterException if an error occurs
*/
public void parameterize( final Parameters params )
throws ParameterException
{
super.parameterize( params );
setProvider( params );
setSocketFactory( params );
}
/**
* Method to set up the SSL provider for this factory
* instance.
*
* @param params configuration [EMAIL PROTECTED] Parameters}
* @exception ParameterException if an error occurs
*/
private void setProvider( final Parameters params )
throws ParameterException
{
Security.addProvider(
(Provider) getInstance( params.getParameter( SSL_PROVIDER ) )
);
}
/**
* Method to set up the SSL socket factory for this
* source factory instance.
*
* @param params configuration [EMAIL PROTECTED] Parameters}
* @exception ParameterException if an error occurs
*/
private void setSocketFactory( final Parameters params )
throws ParameterException
{
String factoryName = null;
try
{
factoryName = params.getParameter( SOCKET_FACTORY );
}
catch ( final ParameterException e )
{
return; // this is ok, means no custom socket factory
}
final Protocol protocol =
new Protocol(
HTTPS,
( SecureProtocolSocketFactory ) getInstance( factoryName ),
443
);
Protocol.registerProtocol( HTTPS, protocol );
}
/**
* Helper method to create a single instance from a class name. Assumes
* given class name has a no-parameter constructor.
*
* @param className class name to instantiate
* @return instantiated class
* @exception Exception if an error occurs
*/
private Object getInstance( final String className )
throws ParameterException
{
try
{
return Class.forName( className ).newInstance();
}
catch ( final Exception e )
{
throw new ParameterException(
"Unable to instantiate: " + className, e
);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]