View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2006 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon.util;
20  
21  import javax.net.ssl.X509TrustManager;
22  
23  import java.security.KeyStore;
24  import java.security.KeyStoreException;
25  import java.security.NoSuchAlgorithmException;
26  import java.security.cert.CertificateException;
27  import java.security.cert.X509Certificate;
28  
29  /***
30   * A X509TrustManager that trusts everything. This is used for those sites where the 
31   * SSL is known to be invalid.
32   */
33  public class X509TrustEverythingManager implements X509TrustManager {
34  
35      /***
36       * Constructor for EasyX509TrustManager.
37       */
38      public X509TrustEverythingManager() {
39      }
40  
41      /***
42       * Constructor for EasyX509TrustManager.
43       */
44      public X509TrustEverythingManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException {
45      }
46  
47      public boolean isClientTrusted(X509Certificate[] chain){ 
48          return true;
49      }
50  
51      public boolean isServerTrusted(X509Certificate[] chain){
52          return true;
53      }
54  
55      public X509Certificate[] getAcceptedIssuers() {
56          return new X509Certificate[0];
57      }
58  
59      public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
60          //Yes the server is trusted
61      }                
62  
63      public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
64          //Yes the client is trusted
65      }            
66  }