查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
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.netty.handler.ssl.util;
17  
18  import io.netty.util.internal.SuppressJava6Requirement;
19  
20  import javax.net.ssl.SSLEngine;
21  import javax.net.ssl.X509ExtendedTrustManager;
22  import javax.net.ssl.X509TrustManager;
23  import java.net.Socket;
24  import java.security.cert.CertificateException;
25  import java.security.cert.X509Certificate;
26  
27  import static io.netty.util.internal.ObjectUtil.*;
28  
29  @SuppressJava6Requirement(reason = "Usage guarded by java version check")
30  final class X509TrustManagerWrapper extends X509ExtendedTrustManager {
31  
32      private final X509TrustManager delegate;
33  
34      X509TrustManagerWrapper(X509TrustManager delegate) {
35          this.delegate = checkNotNull(delegate, "delegate");
36      }
37  
38      @Override
39      public void checkClientTrusted(X509Certificate[] chain, String s) throws CertificateException {
40          delegate.checkClientTrusted(chain, s);
41      }
42  
43      @Override
44      public void checkClientTrusted(X509Certificate[] chain, String s, Socket socket)
45              throws CertificateException {
46          delegate.checkClientTrusted(chain, s);
47      }
48  
49      @Override
50      public void checkClientTrusted(X509Certificate[] chain, String s, SSLEngine sslEngine)
51              throws CertificateException {
52          delegate.checkClientTrusted(chain, s);
53      }
54  
55      @Override
56      public void checkServerTrusted(X509Certificate[] chain, String s) throws CertificateException {
57          delegate.checkServerTrusted(chain, s);
58      }
59  
60      @Override
61      public void checkServerTrusted(X509Certificate[] chain, String s, Socket socket)
62              throws CertificateException {
63          delegate.checkServerTrusted(chain, s);
64      }
65  
66      @Override
67      public void checkServerTrusted(X509Certificate[] chain, String s, SSLEngine sslEngine)
68              throws CertificateException {
69          delegate.checkServerTrusted(chain, s);
70      }
71  
72      @Override
73      public X509Certificate[] getAcceptedIssuers() {
74          return delegate.getAcceptedIssuers();
75      }
76  }