Skip to Content.
Sympa Menu

notify-dpml - r1394 - in trunk/main: central/src/docs metro/component/src/main/net/dpml/component metro/model/src/main/net/dpml/metro/data metro/runtime/src/main/net/dpml/metro/runtime planet/http/impl planet/http/impl/etc planet/http/impl/src/main/net/dpml/http planet/http/impl/src/test/net/dpml/http planet/http/server planet/http/server/prefs transit/core/src/main/net/dpml/util

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1394 - in trunk/main: central/src/docs metro/component/src/main/net/dpml/component metro/model/src/main/net/dpml/metro/data metro/runtime/src/main/net/dpml/metro/runtime planet/http/impl planet/http/impl/etc planet/http/impl/src/main/net/dpml/http planet/http/impl/src/test/net/dpml/http planet/http/server planet/http/server/prefs transit/core/src/main/net/dpml/util
  • Date: Sun, 23 Apr 2006 18:06:52 +0200

Author: mcconnell
Date: 2006-04-23 18:06:50 +0200 (Sun, 23 Apr 2006)
New Revision: 1394

Added:

trunk/main/planet/http/impl/src/test/net/dpml/http/BoundedThreadPoolTestCase.java

trunk/main/planet/http/impl/src/test/net/dpml/http/HashUserRealmTestCase.java
trunk/main/planet/http/server/build.xml
trunk/main/planet/http/server/etc/
trunk/main/planet/http/server/prefs/
trunk/main/planet/http/server/prefs/keystores/

trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
Removed:
trunk/main/planet/http/impl/etc/prefs/
trunk/main/planet/http/impl/src/test/net/dpml/http/ErrorStreamReader.java
trunk/main/planet/http/impl/src/test/net/dpml/http/OutputStreamReader.java
trunk/main/planet/http/impl/src/test/net/dpml/http/SSLTest.java
trunk/main/planet/http/impl/src/test/net/dpml/http/StreamReader.java
trunk/main/planet/http/server/prefs/keystores/
Modified:
trunk/main/central/src/docs/index.xml
trunk/main/metro/component/src/main/net/dpml/component/Composition.java
trunk/main/metro/model/src/main/net/dpml/metro/data/Composite.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComposition.java
trunk/main/planet/http/impl/build.xml
trunk/main/planet/http/impl/src/main/net/dpml/http/BoundedThreadPool.java
trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
trunk/main/planet/http/impl/src/main/net/dpml/http/SslSocketConnector.java
trunk/main/planet/http/server/project.xml
Log:
move prefs from http/impl to http/server

Modified: trunk/main/central/src/docs/index.xml
===================================================================
--- trunk/main/central/src/docs/index.xml 2006-04-23 13:39:10 UTC (rev
1393)
+++ trunk/main/central/src/docs/index.xml 2006-04-23 16:06:50 UTC (rev
1394)
@@ -17,20 +17,20 @@

<ul>
<li>
- <a href="/transit/index.html">Transit</a> resource management
framework.
+ <a href="transit/concepts/index.html">Transit</a> resource
management framework.
</li>
<li>
- <a href="/depot/index.html">Depot</a> tools
+ <a href="depot/concepts/index.html">Depot</a> tools
for build automation in complex multi-project environments.
</li>
<li>
- <a href="/metro/index.html">Metro</a> context-driven IOC runtime
container.
+ <a href="metro/concepts/index.html">Metro</a> context-driven IOC
runtime container.
</li>
<li>
- <a href="/station/index.html">Station</a> multi-appplication
management system.
+ <a href="station/concepts/index.html">Station</a>
multi-appplication management system.
</li>
<li>
- <a href="/util/index.html">Util</a> supporting utilities.
+ <a href="util/concepts/index.html">Util</a> supporting utilities.
</li>
</ul>


Modified:
trunk/main/metro/component/src/main/net/dpml/component/Composition.java
===================================================================
--- trunk/main/metro/component/src/main/net/dpml/component/Composition.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/metro/component/src/main/net/dpml/component/Composition.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -163,6 +163,7 @@

/**
* Return true if this object is equal to the supplied object.
+ * @param other the object to evaluate
* @return the equality status
*/
public boolean equals( Object other )

Modified: trunk/main/metro/model/src/main/net/dpml/metro/data/Composite.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/data/Composite.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/metro/model/src/main/net/dpml/metro/data/Composite.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -65,6 +65,7 @@

/**
* Return true if this object is equal to the supplied object.
+ * @param other the object to evaluate
* @return the equality status
*/
public boolean equals( Object other )

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComposition.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComposition.java
2006-04-23 13:39:10 UTC (rev 1393)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComposition.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -84,6 +84,7 @@

/**
* Return true if this object is equal to the supplied object.
+ * @param other the object to evaluate
* @return the equality status
*/
public boolean equals( Object other )

Modified: trunk/main/planet/http/impl/build.xml
===================================================================
--- trunk/main/planet/http/impl/build.xml 2006-04-23 13:39:10 UTC (rev
1393)
+++ trunk/main/planet/http/impl/build.xml 2006-04-23 16:06:50 UTC (rev
1394)
@@ -124,15 +124,5 @@

</target>

- <target name="install" depends="standard.install">
- <property name="prefs" location="${dpml.prefs}/dpml/planet/http"/>
- <mkdir dir="${prefs}"/>
- <copy toDir="${prefs}" filtering="false">
- <fileset dir="target/prefs">
- <include name="**/*"/>
- </fileset>
- </copy>
- </target>
-
</project>


Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/BoundedThreadPool.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/BoundedThreadPool.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/BoundedThreadPool.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -98,5 +98,6 @@
setDaemon( daemon );
setThreadsPriority( priority );
setName( name );
+ setMaxIdleTimeMs( idle );
}
}

Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/NCSARequestLog.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -17,8 +17,6 @@
package net.dpml.http;

import java.io.File;
-import java.util.ArrayList;
-import java.util.StringTokenizer;

import net.dpml.util.PropertyResolver;

@@ -36,9 +34,10 @@
{
/**
* Get the array of ignore paths.
+ * @param value the default value
* @return the ignore path array
*/
- //String[] getIgnorePaths();
+ String[] getIgnorePaths( String[] value );

/**
* Return the append policy.
@@ -76,13 +75,6 @@
String getLogDateFormat( String value );

/**
- * Return the ignore paths value.
- * @param value the default value
- * @return the resolved value
- */
- String getIgnorePaths( String value );
-
- /**
* Return the log time zone.
* @param value the default value
* @return the resolved value
@@ -144,11 +136,10 @@
setLogDateFormat( dateformat );
}

- String ignorepaths = context.getIgnorePaths( null );
+ String[] ignorepaths = context.getIgnorePaths( null );
if( ignorepaths != null )
{
- String[] paths = tokenize( ignorepaths );
- setIgnorePaths( paths );
+ setIgnorePaths( ignorepaths );
}

String timezone = context.getLogTimeZone( null );
@@ -169,22 +160,4 @@
boolean useProxyAddressPolicy = context.getUseProxyPreference( false
);
setPreferProxiedForAddress( useProxyAddressPolicy );
}
-
- /**
- * Tokenize the supplied string using a ' ,' delimiter.
- * @param string the string to tokenize
- * @return the array of values
- */
- private static String[] tokenize( String string )
- {
- ArrayList result = new ArrayList();
- StringTokenizer st = new StringTokenizer( string, " ,", false );
- while( st.hasMoreTokens() )
- {
- result.add( st.nextToken() );
- }
- String[] retVal = new String[ result.size() ];
- result.toArray( retVal );
- return retVal;
- }
}

Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/SslSocketConnector.java
===================================================================
---
trunk/main/planet/http/impl/src/main/net/dpml/http/SslSocketConnector.java
2006-04-23 13:39:10 UTC (rev 1393)
+++
trunk/main/planet/http/impl/src/main/net/dpml/http/SslSocketConnector.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -15,17 +15,12 @@
*/
package net.dpml.http;

-import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.security.SecureRandom;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
-import java.security.KeyStoreException;
-import java.security.cert.CertificateException;
-import java.security.UnrecoverableKeyException;
import java.security.NoSuchProviderException;

import javax.net.ssl.KeyManager;
@@ -74,6 +69,7 @@
/**
* Set the cipher suites.
* @param suites the default suites argument
+ * @return the cipher suites
*/
String[] getCipherSuites( String[] suites );

@@ -276,16 +272,18 @@
}
}

+ /**
+ * Create a new SSLServerSocketFactory.
+ * @return the factory
+ */
protected SSLServerSocketFactory createFactory()
throws Exception
{
final SSLContext context = getSSLContext();
KeyManager[] keyManagers = getKeyManagers();
TrustManager[] trustManagers = getTrustManagers();
- System.out.println( "# TRUST: " + trustManagers.length );
SecureRandom random = new SecureRandom();
context.init( keyManagers, trustManagers, random );
- //context.init( keyManagers, null, random );
return context.getServerSocketFactory();
}

@@ -341,7 +339,7 @@
}
else
{
- return null;
+ return new TrustManager[0];
}
}


Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/BoundedThreadPoolTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/BoundedThreadPoolTestCase.java
2006-04-23 13:39:10 UTC (rev 1393)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/BoundedThreadPoolTestCase.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.http;
+
+import java.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.http.BoundedThreadPool.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import junit.framework.TestCase;
+
+/**
+ * BoundedThreadPool Test.
+ */
+public class BoundedThreadPoolTestCase extends TestCase
+{
+ private static final int MIN_THREADS = 10;
+ private static final int MAX_THREADS = 100;
+ private static final String NAME = "test";
+ private static final int PRIORITY = 5;
+ private static final int IDLE = 1000;
+
+ private BoundedThreadPool m_pool;
+
+ /**
+ * Test context value handling integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ Map map = new Hashtable();
+ map.put( "min", new Integer( MIN_THREADS ) );
+ map.put( "max", new Integer( MAX_THREADS ) );
+ map.put( "daemon", new Boolean( true ) );
+ map.put( "name", NAME );
+ map.put( "priority", new Integer( PRIORITY ) );
+ map.put( "idle", new Integer( IDLE ) );
+ Class clazz = Context.class;
+ Context context = (Context)
ContextInvocationHandler.getProxiedInstance( clazz, map );
+ m_pool = new BoundedThreadPool( context );
+ }
+
+
+ /**
+ * Test min-thread assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testMinimumThreads() throws Exception
+ {
+ assertEquals( "min", MIN_THREADS, m_pool.getMinThreads() );
+ }
+
+ /**
+ * Test max-thread assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testMaximumThreads() throws Exception
+ {
+ assertEquals( "max", MAX_THREADS, m_pool.getMaxThreads() );
+ }
+
+ /**
+ * Test daemon policy assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testDaemon() throws Exception
+ {
+ assertTrue( "daemon", m_pool.isDaemon() );
+ }
+
+ /**
+ * Test name assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testName() throws Exception
+ {
+ assertEquals( "name", NAME, m_pool.getName() );
+ }
+
+ /**
+ * Test priority assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testPriority() throws Exception
+ {
+ assertEquals( "priority", PRIORITY, m_pool.getThreadsPriority() );
+ }
+
+ /**
+ * Test idle assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testIdle() throws Exception
+ {
+ assertEquals( "idle", IDLE, m_pool.getMaxIdleTimeMs() );
+ }
+}
+

Deleted:
trunk/main/planet/http/impl/src/test/net/dpml/http/ErrorStreamReader.java
===================================================================
--- trunk/main/planet/http/impl/src/test/net/dpml/http/ErrorStreamReader.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/planet/http/impl/src/test/net/dpml/http/ErrorStreamReader.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -1,64 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.http;
-
-import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * Stream reader utility class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ErrorStreamReader extends StreamReader
-{
- /**
- * Creation of a process output reader.
- * @param logger the assigned logging channel
- * @param input the subprocess input stream
- */
- public ErrorStreamReader( InputStream input )
- {
- super( input );
- }
-
- /**
- * Start the stream reader.
- */
- public void run()
- {
- try
- {
- InputStreamReader isr = new InputStreamReader( getInputStream()
);
- BufferedReader reader = new BufferedReader( isr );
- String line = null;
- while( ( line = reader.readLine() ) != null )
- {
- System.out.println( "# " + line );
- }
- }
- catch( IOException e )
- {
- e.printStackTrace();
- }
- }
-}

Added:
trunk/main/planet/http/impl/src/test/net/dpml/http/HashUserRealmTestCase.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/HashUserRealmTestCase.java
2006-04-23 13:39:10 UTC (rev 1393)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/HashUserRealmTestCase.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2006 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.http;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Map;
+import java.util.Hashtable;
+
+import net.dpml.http.HashUserRealm.Context;
+
+import net.dpml.util.ContextInvocationHandler;
+
+import junit.framework.TestCase;
+
+/**
+ * BoundedThreadPool Test.
+ */
+public class HashUserRealmTestCase extends TestCase
+{
+ private HashUserRealm m_realm;
+ private String m_config;
+
+ /**
+ * Test context value handling integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void setUp() throws Exception
+ {
+ Map map = new Hashtable();
+ map.put( "name", "test" );
+ File test = new File( System.getProperty( "project.test.dir" ) );
+ File properties = new File( test, "realm.properties" );
+ URI uri = properties.toURI();
+ m_config = uri.toASCIIString();
+ map.put( "URI", uri );
+ Class clazz = Context.class;
+ Context context = (Context)
ContextInvocationHandler.getProxiedInstance( clazz, map );
+ m_realm = new HashUserRealm( context );
+ }
+
+ /**
+ * Test name assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testName() throws Exception
+ {
+ assertEquals( "name", "test", m_realm.getName() );
+ }
+
+ /**
+ * Test priority assignment integrity.
+ * @throws Exception if an error occurs during test execution
+ */
+ public void testConfig() throws Exception
+ {
+ assertEquals( "config", m_config, m_realm.getConfig() );
+ }
+}
+

Deleted:
trunk/main/planet/http/impl/src/test/net/dpml/http/OutputStreamReader.java
===================================================================
---
trunk/main/planet/http/impl/src/test/net/dpml/http/OutputStreamReader.java
2006-04-23 13:39:10 UTC (rev 1393)
+++
trunk/main/planet/http/impl/src/test/net/dpml/http/OutputStreamReader.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -1,64 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.http;
-
-import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * Stream reader utility class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class OutputStreamReader extends StreamReader
-{
- /**
- * Creation of a process output reader.
- * @param logger the assigned logging channel
- * @param input the subprocess input stream
- */
- public OutputStreamReader( InputStream input )
- {
- super( input );
- }
-
- /**
- * Start the stream reader.
- */
- public void run()
- {
- try
- {
- InputStreamReader isr = new InputStreamReader( getInputStream()
);
- BufferedReader reader = new BufferedReader( isr );
- String line = null;
- while( ( line = reader.readLine() ) != null )
- {
- System.out.println( "$ " + line );
- }
- }
- catch( IOException e )
- {
- e.printStackTrace();
- }
- }
-}

Deleted: trunk/main/planet/http/impl/src/test/net/dpml/http/SSLTest.java
===================================================================
--- trunk/main/planet/http/impl/src/test/net/dpml/http/SSLTest.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/planet/http/impl/src/test/net/dpml/http/SSLTest.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -1,582 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.http;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.File;
-import java.net.URI;
-import java.net.Socket;
-import java.util.Arrays;
-import java.util.Random;
-
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-
-import net.dpml.http.SslSocketConnector;
-
-import junit.framework.TestCase;
-
-/**
- * SLL Test.
- */
-public class SSLTest
- extends TestCase
-{
-
- //~ Static fields/initializers
---------------------------------------------
-
- /** The request. */
- private static final String REQUEST1_HEADER=
- "POST / HTTP/1.0\n"
- + "Host: localhost\n"
- + "Content-Type: text/xml\n"
- + "Connection: close\n"
- + "Content-Length: ";
- private static final String REQUEST1_CONTENT=
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
- + "<nimbus xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
- + " xsi:noNamespaceSchemaLocation=\"nimbus.xsd\"
version=\"1.0\">\n"
- + "</nimbus>";
- private static final String REQUEST1=
-
REQUEST1_HEADER+REQUEST1_CONTENT.getBytes().length+"\n\n"+REQUEST1_CONTENT;
-
- /** The expected response. */
- private static final String RESPONSE1 = "HTTP/1.1 200 OK\n"
- + "Connection: close\n"
- + "Server: Jetty(6.0.x)\n"
- + "\n"
- + "Hello world\n";
-
- // Useful constants
- private static final long PAUSE = 10L;
- private static final String HOST = "localhost";
- private static final int PORT = 0;
-
- private File m_keystore;
- private File m_truststore;
- private int m_port;
-
- public void setUp() throws Exception
- {
- // create server keystore
-
- File test = new File( System.getProperty( "project.test.dir" ) );
- String name = "test.keystore";
- m_keystore = setupKeystore( test, name );
-
- // export trust certificate for use by the client
-
- String cname = "test.cer";
- File cert = setupTrustCertificate( test, name, cname );
-
- // create clients truststore and add trusted cert
-
- String tname = "trust.keystore";
- m_truststore = setupTrustStore( test, tname, cname );
-
- String keystore = m_keystore.toString();
- String truststore = m_truststore.toString();
-
- // setup client properties
-
- System.setProperty( "javax.net.ssl.trustStore", truststore );
- System.setProperty( "javax.net.ssl.trustStorePassword", "password" );
- System.setProperty( "javax.net.ssl.keyStore", keystore );
- System.setProperty( "javax.net.ssl.keyStorePassword", "password" );
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- Thread.sleep( 1000 );
- }
-
- //~ Methods
----------------------------------------------------------------
-
- /**
- * Test request/response under SSL connector.
- * @throws Exception
- * @throws InterruptedException
- */
- public void testSSL() throws Exception, InterruptedException
- {
- Server server = startServer( new HelloWorldHandler() );
-
- SSLSocketFactory factory = (SSLSocketFactory)
SSLSocketFactory.getDefault();
- SSLSocket client = (SSLSocket) factory.createSocket( HOST, m_port );
- client.startHandshake();
-
- OutputStream os = client.getOutputStream();
- os.write( REQUEST1.getBytes() );
- os.flush();
- String response = readResponse( client );
- client.close();
- server.stop();
- assertEquals( "response", RESPONSE1, response );
- }
-
- private Server startServer( Handler handler ) throws Exception
- {
- Server server = new Server();
- net.dpml.http.SslSocketConnector.Context context = new
LocalContext();
- SslSocketConnector connector = new SslSocketConnector( context );
- server.setConnectors(new Connector[] {connector});
- server.setHandler(handler);
- server.start();
- m_port = connector.getLocalPort();
- return server;
- }
-
- private static class HelloWorldHandler
- extends AbstractHandler
- {
- public boolean handle(String target, HttpServletRequest request,
- HttpServletResponse response, int dispatch)
- throws IOException, ServletException
- {
- response.getOutputStream().print("Hello world");
- return true;
- }
- }
-
- private static String readResponse(Socket client) throws IOException
- {
- BufferedReader br = null;
- try
- {
- br = new BufferedReader( new InputStreamReader(
client.getInputStream() ) );
- StringBuffer sb = new StringBuffer();
- String line;
- while( ( line = br.readLine() ) != null )
- {
- sb.append( line );
- sb.append( '\n' );
- }
- return sb.toString();
- }
- finally
- {
- if( br != null )
- {
- br.close();
- }
- }
- }
-
- private static File setupKeystore( File test, String name ) throws
Exception
- {
- File keystore = new File( test, name );
- if( !keystore.exists() )
- {
- String[] args =
- new String[]
- {
- "keytool",
- "-genkey",
- "-alias",
- "jetty",
- "-keyalg",
- "RSA",
- "-keypass",
- "password",
- "-storepass",
- "password",
- "-dname",
- "cn=Test ou=Test o=Test c=AU",
- "-keystore",
- name
- };
-
- System.out.println( "Creating keystore" );
- Process process = Runtime.getRuntime().exec( args, new
String[0], test );
- handleProcess( process );
- process.waitFor();
- }
- else
- {
- System.out.println( "Using keystore: " + keystore );
- }
- return keystore;
- }
-
- private static File setupTrustCertificate( File test, String keystore,
String certNname ) throws Exception
- {
- File cert = new File( test, certNname );
- if( !cert.exists() )
- {
- String[] args =
- new String[]
- {
- "keytool",
- "-export",
- "-rfc",
- "-alias",
- "jetty",
- "-storepass",
- "password",
- "-keystore",
- keystore,
- "-file",
- certNname
- };
-
- System.out.println( "Exporting trusted certificate" );
- Process process = Runtime.getRuntime().exec( args, new
String[0], test );
- handleProcess( process );
- process.waitFor();
- }
- else
- {
- System.out.println( "Using certificate: " + cert );
- }
- return cert;
- }
-
- private static File setupTrustStore( File test, String truststore,
String cert ) throws Exception
- {
- File trust = new File( test, truststore );
- if( !trust.exists() )
- {
- String[] args =
- new String[]
- {
- "keytool",
- "-import",
- "-file",
- cert,
- "-noprompt",
- "-alias",
- "jettycert",
- "-storepass",
- "password",
- "-keypass",
- "password",
- "-keystore",
- truststore
- };
-
- System.out.println( "Creating trust keystore" );
- Process process = Runtime.getRuntime().exec( args, new
String[0], test );
- handleProcess( process );
- process.waitFor();
- }
- else
- {
- System.out.println( "Using trust store: " + trust );
- }
- return trust;
- }
-
- private static void handleProcess( Process process )
- {
- OutputStreamReader output = new OutputStreamReader(
process.getInputStream() );
- ErrorStreamReader err = new ErrorStreamReader(
process.getErrorStream() );
- output.setDaemon( true );
- err.setDaemon( true );
- output.start();
- err.start();
- }
-
- /**
- * SSL connector context definition.
- */
- public class LocalContext implements SslSocketConnector.Context
- {
- /**
- * Return the connector host name.
- * @param host implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getHost( String host )
- {
- return HOST;
- }
-
- /**
- * Return the connector port.
- * @return the assigned connector port
- */
- public int getPort()
- {
- return PORT;
- }
-
- /**
- * Return the connector header buffer size.
- * @param size implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getHeaderBufferSize( int size )
- {
- return size;
- }
-
- /**
- * Return the maximum idle time in milliseconds.
- * @param time implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getMaxIdleTime( int time )
- {
- return time;
- }
-
- /**
- * Return the request buffer size.
- * @param size implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getRequestBufferSize( int size )
- {
- return size;
- }
-
- /**
- * Return the response buffer size.
- * @param size implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getResponseBufferSize( int size )
- {
- return size;
- }
-
- /**
- * Return the accept queue size.
- * @param size implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getAcceptQueueSize( int size )
- {
- return size;
- }
-
- /**
- * Return the number of inital acceptors.
- * @param size implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getAcceptors( int size )
- {
- return size;
- }
-
- /**
- * Return the soLingerTime parameter value.
- * @param time implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getSoLingerTime( int time )
- {
- return time;
- }
-
- /**
- * Return the confidential port.
- * @param port implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getConfidentialPort( int port )
- {
- return port;
- }
-
- /**
- * Return the confidential scheme (http or https).
- * @param scheme implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getConfidentialScheme( String scheme )
- {
- return scheme;
- }
-
- /**
- * Return the integral port.
- * @param port implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public int getIntegralPort( int port )
- {
- return port;
- }
-
- /**
- * Return the integral scheme (http or https).
- * @param scheme implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getIntegralScheme( String scheme )
- {
- return scheme;
- }
-
- /**
- * Set the cipher suites.
- * @param suites the default suites argument
- */
- public String[] getCipherSuites( String[] suites )
- {
- return suites;
- }
-
- /**
- * Return the certificate password.
- * @param password implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getCertificatePassword( String password )
- {
- return "password";
- }
-
- /**
- * Return the keystore password.
- * @param password implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getKeyStorePassword( String password )
- {
- return "password";
- }
-
- /**
- * Return the keystore algorithm.
- * @param algorithm implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getAlgorithm( String algorithm )
- {
- return algorithm;
- }
-
- /**
- * Return the keystore protocol.
- * @param protocol implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getProtocol( String protocol )
- {
- return protocol;
- }
-
- /**
- * Return the keystore location uri.
- * @param keystore implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public URI getKeyStore( URI keystore )
- {
- return m_keystore.toURI();
- }
-
- /**
- * Return the keystore type.
- * @param type implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getKeyStoreType( String type )
- {
- return type;
- }
-
- /**
- * Return the 'want-client-authentication' policy.
- * @param flag implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public boolean getWantClientAuth( boolean flag )
- {
- return flag;
- }
-
- /**
- * Return the 'need-client-authentication' policy.
- * @param flag implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public boolean getNeedClientAuth( boolean flag )
- {
- return flag;
- }
-
- /**
- * Return the SSL context provider.
- * @param provider implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getProvider( String provider )
- {
- return provider;
- }
-
- /**
- * Return the keystore algorithm.
- * @param algorithm implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getTrustAlgorithm( String algorithm )
- {
- return algorithm;
- }
-
- /**
- * Return the keystore location uri.
- * @param uri implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public URI getTrustStore( URI uri )
- {
- return m_truststore.toURI();
- }
-
- /**
- * Return the keystore type.
- * @param type implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getTrustStoreType( String type )
- {
- return type;
- }
-
- /**
- * Return the trust store password.
- * @param password implementation defined default value
- * @return the supplied value unless overriden in the deployment
configuration
- */
- public String getTrustStorePassword( String password )
- {
- return "password";
- }
- }
-}
-

Deleted: trunk/main/planet/http/impl/src/test/net/dpml/http/StreamReader.java
===================================================================
--- trunk/main/planet/http/impl/src/test/net/dpml/http/StreamReader.java
2006-04-23 13:39:10 UTC (rev 1393)
+++ trunk/main/planet/http/impl/src/test/net/dpml/http/StreamReader.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006 Stephen J. McConnell.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- *
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.dpml.http;
-
-import java.io.InputStream;
-
-/**
- * Stream reader utility class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-abstract class StreamReader extends Thread
-{
- private final InputStream m_input;
-
- /**
- * Creation of a new reader.
- * @param logger the assigned logging channel
- * @param input the subprocess input stream
- */
- public StreamReader( InputStream input )
- {
- m_input = input;
- }
-
- /**
- * Return the input stream.
- * @return the subprocess input stream
- */
- protected InputStream getInputStream()
- {
- return m_input;
- }
-
-}

Added: trunk/main/planet/http/server/build.xml
===================================================================
--- trunk/main/planet/http/server/build.xml 2006-04-23 13:39:10 UTC (rev
1393)
+++ trunk/main/planet/http/server/build.xml 2006-04-23 16:06:50 UTC (rev
1394)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ * Copyright 2004-2005 Stephen J. McConnell.
+ * Copyright 2004 Niclas Hedman.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.dpml.net/central/about/legal/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<project default="install"
+ xmlns:transit="antlib:net.dpml.transit" xmlns:depot="dpml:depot">
+
+ <transit:import uri="local:template:dpml/tools/standard"/>
+
+ <target name="install" depends="standard.install">
+ <property name="prefs" location="${dpml.prefs}/dpml/planet/http"/>
+ <mkdir dir="${prefs}"/>
+ <copy toDir="${prefs}" filtering="false">
+ <fileset dir="target/prefs">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+ </target>
+
+</project>
+

Copied: trunk/main/planet/http/server/prefs (from rev 1382,
trunk/main/planet/http/impl/etc/prefs)

Copied: trunk/main/planet/http/server/prefs/keystores (from rev 1393,
trunk/main/planet/http/impl/etc/prefs/keystores)

Modified: trunk/main/planet/http/server/project.xml
===================================================================
--- trunk/main/planet/http/server/project.xml 2006-04-23 13:39:10 UTC (rev
1393)
+++ trunk/main/planet/http/server/project.xml 2006-04-23 16:06:50 UTC (rev
1394)
@@ -23,10 +23,10 @@
<context>
<entry key="port" value="8443"/>
<entry key="maxIdleTime" value="30000"/>
- <entry key="keyStore"
value="local:keystore:dpml/planet/http/demo"/>
+ <entry key="keyStore"
value="local:keystore:dpml/planet/http/sample"/>
<entry key="keyStorePassword" value="password"/>
<entry key="certificatePassword" value="password"/>
- <entry key="trustStore"
value="local:keystore:dpml/planet/http/trust"/>
+ <entry key="trustStore"
value="local:keystore:dpml/planet/http/certs"/>
<entry key="trustStorePassword" value="password"/>
<!--
<entry key="keystore"
value="local:keystore:dpml/planet/http/jetty"/>

Added:
trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
2006-04-23 13:39:10 UTC (rev 1393)
+++
trunk/main/transit/core/src/main/net/dpml/util/ContextInvocationHandler.java
2006-04-23 16:06:50 UTC (rev 1394)
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.dpml.util;
+
+import java.util.Map;
+import java.beans.Introspector;
+import java.beans.Expression;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+/**
+ * Invoication handler utility for a Context inner-class.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class ContextInvocationHandler implements InvocationHandler
+{
+ //-------------------------------------------------------------------
+ // static
+ //-------------------------------------------------------------------
+
+ /**
+ * Construct a new context instance implementing the supplied class
+ * and backed by entries in the supplied map.
+ *
+ * @param clazz the context inner class
+ * @param map a map of context entry keys to values
+ * @return the proxied context instance
+ */
+ public static Object getProxiedInstance( Class clazz, Map map )
+ {
+ ClassLoader classloader = clazz.getClassLoader();
+ ContextInvocationHandler handler = new ContextInvocationHandler( map
);
+ return Proxy.newProxyInstance( classloader, new Class[]{clazz},
handler );
+ }
+
+ //-------------------------------------------------------------------
+ // state
+ //-------------------------------------------------------------------
+
+ /**
+ * A map containing key values.
+ */
+ private final Map m_map;
+
+ //-------------------------------------------------------------------
+ // constructor
+ //-------------------------------------------------------------------
+
+ /**
+ * Create a context invocation handler.
+ *
+ * @param provider the provider
+ */
+ private ContextInvocationHandler( Map map )
+ {
+ m_map = map;
+ }
+
+ //-------------------------------------------------------------------
+ // implementation
+ //-------------------------------------------------------------------
+
+ /**
+ * Invoke the specified method on underlying object.
+ * This is called by the proxy object.
+ *
+ * @param proxy the proxy object
+ * @param method the method invoked on proxy object
+ * @param args the arguments supplied to method
+ * @return the return value of method
+ * @throws Throwable if an error occurs
+ */
+ public Object invoke( final Object proxy, final Method method, final
Object[] args ) throws Throwable
+ {
+ Class source = method.getDeclaringClass();
+ if( Object.class == source )
+ {
+ return method.invoke( this, args );
+ }
+ else
+ {
+ String name = method.getName();
+ if( name.startsWith( "get" ) )
+ {
+ String key = Introspector.decapitalize( name.substring( 3 )
);
+ Object value = m_map.get( key );
+ if( null != value )
+ {
+ Class clazz = method.getReturnType();
+ if( isAssignableFrom( clazz, value.getClass() ) )
+ {
+ return value;
+ }
+ else
+ {
+ Expression expression = new Expression( clazz,
"new", new Object[]{value} );
+ return expression.getValue();
+ }
+ }
+ else if( ( null != args ) && args.length > 0 )
+ {
+ return args[0];
+ }
+ else
+ {
+ final String error =
+ "Unable to resolve a context entry value for the key
[" + key + "].";
+ throw new IllegalStateException( error );
+ }
+ }
+ throw new UnsupportedOperationException( name );
+ }
+ }
+
+ private static boolean isAssignableFrom( Class clazz, Class c )
+ {
+ if( clazz.isPrimitive() )
+ {
+ if( Integer.TYPE == clazz )
+ {
+ return Integer.class.isAssignableFrom( c );
+ }
+ else if( Boolean.TYPE == clazz )
+ {
+ return Boolean.class.isAssignableFrom( c );
+ }
+ else if( Byte.TYPE == clazz )
+ {
+ return Byte.class.isAssignableFrom( c );
+ }
+ else if( Short.TYPE == clazz )
+ {
+ return Short.class.isAssignableFrom( c );
+ }
+ else if( Long.TYPE == clazz )
+ {
+ return Long.class.isAssignableFrom( c );
+ }
+ else if( Float.TYPE == clazz )
+ {
+ return Float.class.isAssignableFrom( c );
+ }
+ else if( Double.TYPE == clazz )
+ {
+ return Double.class.isAssignableFrom( c );
+ }
+ else
+ {
+ final String error =
+ "Primitive type ["
+ + c.getName()
+ + "] not supported.";
+ throw new RuntimeException( error );
+ }
+ }
+ else
+ {
+ return clazz.isAssignableFrom( c );
+ }
+ }
+}




  • r1394 - in trunk/main: central/src/docs metro/component/src/main/net/dpml/component metro/model/src/main/net/dpml/metro/data metro/runtime/src/main/net/dpml/metro/runtime planet/http/impl planet/http/impl/etc planet/http/impl/src/main/net/dpml/http planet/http/impl/src/test/net/dpml/http planet/http/server planet/http/server/prefs transit/core/src/main/net/dpml/util, mcconnell at BerliOS, 04/23/2006

Archive powered by MHonArc 2.6.24.

Top of Page