View Javadoc
1   /*
2    * Copyright 2016 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty5.handler.ssl.util;
17  
18  import javax.net.ssl.SSLEngine;
19  import javax.net.ssl.X509ExtendedTrustManager;
20  import javax.net.ssl.X509TrustManager;
21  import java.net.Socket;
22  import java.security.cert.CertificateException;
23  import java.security.cert.X509Certificate;
24  
25  import static java.util.Objects.requireNonNull;
26  
27  final class X509TrustManagerWrapper extends X509ExtendedTrustManager {
28  
29      private final X509TrustManager delegate;
30  
31      X509TrustManagerWrapper(X509TrustManager delegate) {
32          this.delegate = requireNonNull(delegate, "delegate");
33      }
34  
35      @Override
36      public void checkClientTrusted(X509Certificate[] chain, String s) throws CertificateException {
37          delegate.checkClientTrusted(chain, s);
38      }
39  
40      @Override
41      public void checkClientTrusted(X509Certificate[] chain, String s, Socket socket)
42              throws CertificateException {
43          delegate.checkClientTrusted(chain, s);
44      }
45  
46      @Override
47      public void checkClientTrusted(X509Certificate[] chain, String s, SSLEngine sslEngine)
48              throws CertificateException {
49          delegate.checkClientTrusted(chain, s);
50      }
51  
52      @Override
53      public void checkServerTrusted(X509Certificate[] chain, String s) throws CertificateException {
54          delegate.checkServerTrusted(chain, s);
55      }
56  
57      @Override
58      public void checkServerTrusted(X509Certificate[] chain, String s, Socket socket)
59              throws CertificateException {
60          delegate.checkServerTrusted(chain, s);
61      }
62  
63      @Override
64      public void checkServerTrusted(X509Certificate[] chain, String s, SSLEngine sslEngine)
65              throws CertificateException {
66          delegate.checkServerTrusted(chain, s);
67      }
68  
69      @Override
70      public X509Certificate[] getAcceptedIssuers() {
71          return delegate.getAcceptedIssuers();
72      }
73  }