1package org.apache.harmony.xnet.tests.support; 2 3import java.security.KeyManagementException; 4import java.security.SecureRandom; 5 6import javax.net.ssl.KeyManager; 7//import javax.net.ssl.SSLContextSpi; 8import javax.net.ssl.SSLEngine; 9/*import javax.net.ssl.SSLEngineResult; 10import javax.net.ssl.SSLException; 11import javax.net.ssl.SSLSession;*/ 12import javax.net.ssl.SSLSessionContext; 13import javax.net.ssl.SSLServerSocketFactory; 14import javax.net.ssl.SSLSocketFactory; 15import javax.net.ssl.TrustManager; 16 17public class SSLContextSpiImpl extends MySSLContextSpi { 18 19 private boolean init = false; 20 21 public void engineInit(KeyManager[] km, TrustManager[] tm, 22 SecureRandom sr) throws KeyManagementException { 23 if (sr == null) { 24 throw new KeyManagementException( 25 "secureRandom is null"); 26 } 27 init = true; 28 } 29 30 public SSLSocketFactory engineGetSocketFactory() { 31 if (!init) { 32 throw new RuntimeException("Not initialiazed"); 33 } 34 return null; 35 } 36 37 public SSLServerSocketFactory engineGetServerSocketFactory() { 38 if (!init) { 39 throw new RuntimeException("Not initialiazed"); 40 } 41 return null; 42 } 43 44 public SSLSessionContext engineGetServerSessionContext() { 45 if (!init) { 46 throw new RuntimeException("Not initialiazed"); 47 } 48 return null; 49 } 50 51 public SSLSessionContext engineGetClientSessionContext() { 52 if (!init) { 53 throw new RuntimeException("Not initialiazed"); 54 } 55 return null; 56 } 57 58 /* 59 * FIXME: add these methods 60 */ 61 public SSLEngine engineCreateSSLEngine(String host, int port) { 62 int max = 65535; 63 64 if (port < 0 || port > max) { 65 throw new IllegalArgumentException("Illegal port"); 66 } 67 68 if (!init) { 69 throw new RuntimeException("Not initialiazed"); 70 } 71 return new tmpSSLEngine(host, port); 72 } 73 74 public SSLEngine engineCreateSSLEngine() { 75 if (!init) { 76 throw new RuntimeException("Not initialiazed"); 77 } 78 return new tmpSSLEngine(); 79 } 80} 81 82