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