1 45 package org.exolab.jms.net.http.connector; 46 47 import java.security.Principal ; 48 import java.io.IOException ; 49 50 import junit.framework.Test; 51 import junit.framework.TestSuite; 52 53 import org.exolab.jms.net.connector.Authenticator; 54 import org.exolab.jms.net.connector.ConnectionRequestInfo; 55 import org.exolab.jms.net.connector.ManagedConnectionAcceptor; 56 import org.exolab.jms.net.connector.ManagedConnectionFactory; 57 import org.exolab.jms.net.connector.ManagedConnectionTestCase; 58 import org.exolab.jms.net.connector.TestAuthenticator; 59 import org.exolab.jms.net.http.HTTPRequestInfo; 60 import org.exolab.jms.net.http.HTTPSManagedConnectionFactory; 61 import org.exolab.jms.net.socket.SocketRequestInfo; 62 import org.exolab.jms.net.uri.URI; 63 import org.exolab.jms.net.util.SSLProperties; 64 import org.exolab.jms.net.util.SSLUtil; 65 66 67 73 public class HTTPSManagedConnectionTest extends ManagedConnectionTestCase { 74 75 80 public HTTPSManagedConnectionTest(String name) { 81 super(name); 82 } 83 84 89 public static Test suite() { 90 return new TestSuite(HTTPSManagedConnectionTest.class); 91 } 92 93 98 public static void main(String [] args) { 99 junit.textui.TestRunner.run(suite()); 100 } 101 102 108 protected ManagedConnectionFactory createManagedConnectionFactory() 109 throws Exception { 110 return new HTTPSManagedConnectionFactory(); 111 } 112 113 120 protected ConnectionRequestInfo getManagedConnectionRequestInfo() 121 throws Exception { 122 HTTPRequestInfo result = new HTTPRequestInfo( 123 new URI("https://localhost:8443/openjms-tunnel/tunnel")); 124 125 result.setSSLProperties(getSSLProperties()); 126 return result; 127 } 128 129 137 protected ConnectionRequestInfo getAcceptorConnectionRequestInfo() 138 throws Exception { 139 SocketRequestInfo result = new SocketRequestInfo( 140 new URI("https-server://localhost:3030")); 141 return result; 142 } 143 144 150 protected ManagedConnectionAcceptor createAcceptor(Principal principal) 151 throws Exception { 152 ConnectionRequestInfo info = getAcceptorConnectionRequestInfo(); 153 Authenticator authenticator = new TestAuthenticator(principal); 154 ManagedConnectionFactory factory = new HTTPSManagedConnectionFactory(); 155 return factory.createManagedConnectionAcceptor(authenticator, info); 156 } 157 158 164 private SSLProperties getSSLProperties() throws IOException { 165 return SSLUtil.getSSLProperties("test.keystore", "secret"); 166 } 167 } 168 | Popular Tags |