View Javadoc
1   /**
2    * This Source Code Form is subject to the terms of the Mozilla Public
3    * License, v. 2.0. If a copy of the MPL was not distributed with this
4    * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5    *
6    * If it is not possible or desirable to put the notice in a particular
7    * file, then You may include the notice in a location (such as a LICENSE
8    * file in a relevant directory) where a recipient would be likely to look
9    * for such a notice.
10  
11   * 
12   */
13   
14  /*  ---------------------------------------------------------------------------
15   *  U.S. Government, Department of the Army
16   *  Army Materiel Command
17   *  Research Development Engineering Command
18   *  Communications Electronics Research Development and Engineering Center
19   *  ---------------------------------------------------------------------------
20   */
21  
22  package org.miloss.fgsms.agentcore;
23  
24  import javax.net.ssl.TrustManager;
25  import javax.net.ssl.X509TrustManager;
26  import java.security.cert.X509Certificate;
27  
28  import javax.net.ssl.X509TrustManager;
29  import java.security.cert.CertificateException;
30  
31  
32  /**
33   *
34   * @author AO
35   */
36  class AuthSSLX509TrustManager implements TrustManager {
37  
38  private X509TrustManager defaultTrustManager = null;
39  
40      /** Log object for this class. */
41      
42  
43      /**
44       * Constructor for AuthSSLX509TrustManager.
45       */
46      public AuthSSLX509TrustManager(final X509TrustManager defaultTrustManager) {
47          super();
48          if (defaultTrustManager == null) {
49              throw new IllegalArgumentException("Trust manager may not be null");
50          }
51          this.defaultTrustManager = defaultTrustManager;
52      }
53  
54      /**
55       * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType)
56       */
57      public void checkClientTrusted(X509Certificate[] certificates,String authType) throws CertificateException {
58          defaultTrustManager.checkClientTrusted(certificates,authType);
59      }
60  
61      /**
62       * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType)
63       */
64      public void checkServerTrusted(X509Certificate[] certificates,String authType) throws CertificateException {
65          defaultTrustManager.checkServerTrusted(certificates,authType);
66      }
67  
68      /**
69       * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
70       */
71      public X509Certificate[] getAcceptedIssuers() {
72          return this.defaultTrustManager.getAcceptedIssuers();
73      }
74      
75  }