1 7 8 9 import com.maverick.http.GetMethod; 10 import com.maverick.http.HttpClient; 11 import com.maverick.http.HttpResponse; 12 import com.maverick.http.PasswordCredentials; 13 import com.maverick.multiplex.Channel; 14 import com.maverick.multiplex.ChannelFactory; 15 import com.maverick.multiplex.MultiplexedConnection; 16 import com.maverick.multiplex.SocketChannel; 17 18 24 public class TestServer { 25 26 27 public void processRequest(String requestName, byte[] requestData) { 28 29 if(requestName.equals("authorizationTicket")) { 30 System.out.println("Received authorization ticket " + new String (requestData)); 31 } 32 } 33 34 MultiplexedConnection c; 35 36 37 public TestServer() { 38 39 40 41 try { 42 43 System.setProperty("com.maverick.ssl.allowUntrustedCertificates", "true"); 44 System.setProperty("com.maverick.ssl.allowInvalidCertificates", "true"); 45 46 HttpClient client = new HttpClient("127.0.0.1", 443, true); 47 GetMethod get = new GetMethod("AGENT", "/"); 48 client.setCredentials(new PasswordCredentials("lee", "xxxxxxxxxx")); 49 client.setPreemtiveAuthentication(true); 50 51 HttpResponse response = client.execute(get); 52 53 c = new MultiplexedConnection(new SocketChannelFactory()); 54 55 c.startProtocol(response.getConnection().getInputStream(), response.getConnection().getOutputStream(), false); 56 57 } catch (Exception ex) { 58 ex.printStackTrace(); 59 } 60 61 } 62 63 64 public static void main(String [] args) { 65 TestServer t = new TestServer(); 66 } 67 68 class SocketChannelFactory implements ChannelFactory { 69 70 public Channel createChannel(MultiplexedConnection connection, String type) { 71 72 if(type.equals(SocketChannel.CHANNEL_TYPE)) 73 return new SocketChannel(); 74 else 75 return null; 76 } 77 } 78 } 79 | Popular Tags |