| 36 | import org.apache.tomcat.util.net.SSLContext; |
| 37 | |
| 38 | class JSSESSLContext implements SSLContext { |
| 39 | |
| 40 | private final javax.net.ssl.SSLContext context; |
| 41 | private KeyManager[] kms; |
| 42 | private TrustManager[] tms; |
| 43 | |
| 44 | JSSESSLContext(String protocol) throws NoSuchAlgorithmException { |
| 45 | context = javax.net.ssl.SSLContext.getInstance(protocol); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public void init(KeyManager[] kms, TrustManager[] tms, SecureRandom sr) throws KeyManagementException { |
| 50 | this.kms = kms; |
| 51 | this.tms = tms; |
| 52 | context.init(kms, tms, sr); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public void destroy() { |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public SSLSessionContext getServerSessionContext() { |
| 61 | return context.getServerSessionContext(); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public SSLEngine createSSLEngine() { |
| 66 | return context.createSSLEngine(); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public SSLServerSocketFactory getServerSocketFactory() { |
| 71 | return context.getServerSocketFactory(); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public SSLParameters getSupportedSSLParameters() { |
| 76 | return context.getSupportedSSLParameters(); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public X509Certificate[] getCertificateChain(String alias) { |
| 81 | X509Certificate[] result = null; |
| 82 | if (kms != null) { |
| 83 | for (int i = 0; i < kms.length && result == null; i++) { |
| 84 | if (kms[i] instanceof X509KeyManager) { |
| 85 | result = ((X509KeyManager) kms[i]).getCertificateChain(alias); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | return result; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public X509Certificate[] getAcceptedIssuers() { |
| 94 | Set<X509Certificate> certs = new HashSet<>(); |
| 95 | if (tms != null) { |
nothing calls this directly
no outgoing calls
no test coverage detected