Coverage report

  %line %branch
org.apache.jetspeed.security.util.GullibleSSLSocketFactory
0% 
0% 

 1  
 /* 
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.security.util;
 18  
 
 19  
 import java.io.IOException;
 20  
 import java.net.InetAddress;
 21  
 import java.net.Socket;
 22  
 import java.net.UnknownHostException;
 23  
 import java.security.KeyManagementException;
 24  
 import java.security.NoSuchAlgorithmException;
 25  
 import java.security.SecureRandom;
 26  
 import java.security.cert.CertificateException;
 27  
 import java.security.cert.X509Certificate;
 28  
 import javax.net.ssl.X509TrustManager;
 29  
 import javax.net.SocketFactory;
 30  
 import javax.net.ssl.SSLContext;
 31  
 import javax.net.ssl.SSLSocketFactory;
 32  
 import javax.net.ssl.TrustManager;
 33  
 
 34  
 /**
 35  
  * Socket Factory for SSL connections which do not provide an authentication
 36  
  * This is used to connect to servers where we are just interested in
 37  
  * an encypted tunnel, and not to verify that both parties trust each other.
 38  
  *
 39  
  * @author <a href="mailto:b.vanhalderen@hippo.nl">Berry van Halderen</a>
 40  
  * @version $Id: GullibleSSLSocketFactory.java 516448 2007-03-09 16:25:47Z ate $
 41  
  *
 42  
  */
 43  
 public class GullibleSSLSocketFactory extends SSLSocketFactory {
 44  
 
 45  
   class GullibleTrustManager implements X509TrustManager
 46  
   {
 47  
     GullibleTrustManager() { }
 48  
     public void checkClientTrusted(final X509Certificate[] chain, class="keyword">final String authType) throws CertificateException {
 49  
     }
 50  
 
 51  
     public void checkServerTrusted(final X509Certificate[] chain, class="keyword">final String authType) throws CertificateException {
 52  
     }
 53  
   
 54  
     public X509Certificate[] getAcceptedIssuers() {
 55  
       return new X509Certificate[0];
 56  
     }
 57  
   }
 58  
 
 59  
    private SSLSocketFactory factory;
 60  0
    protected GullibleSSLSocketFactory() {
 61  
       try {
 62  0
          SSLContext context = SSLContext.getInstance("TLS");
 63  0
          context.init(null, new TrustManager[] {class="keyword">new GullibleTrustManager()},
 64  
             new SecureRandom());
 65  0
          factory = context.getSocketFactory();
 66  0
       } catch (NoSuchAlgorithmException e) {
 67  0
          e.printStackTrace();
 68  0
       } catch (KeyManagementException e) {
 69  0
          e.printStackTrace();
 70  0
       }
 71  0
    }
 72  
    public static SocketFactory getDefault() {
 73  0
       return new GullibleSSLSocketFactory();
 74  
    }
 75  
    public String[] getDefaultCipherSuites() {
 76  0
       return factory.getDefaultCipherSuites();
 77  
    }
 78  
    public String[] getSupportedCipherSuites() {
 79  0
       return factory.getSupportedCipherSuites();
 80  
    }
 81  
    public Socket createSocket(final Socket s, class="keyword">final String host, class="keyword">final int port, class="keyword">final boolean autoClose) throws IOException {
 82  0
       return factory.createSocket(s, host, port, autoClose);
 83  
    }
 84  
    public Socket createSocket(final String host, class="keyword">final int port) throws IOException, UnknownHostException {
 85  0
       return factory.createSocket(host, port);
 86  
    }
 87  
    public Socket createSocket(final String host, class="keyword">final int port, class="keyword">final InetAddress localAddress, class="keyword">final int localPort) throws IOException, UnknownHostException {
 88  0
       return factory.createSocket(host, port, localAddress, localPort);
 89  
    }
 90  
    public Socket createSocket(final InetAddress host, class="keyword">final int port) throws IOException {
 91  0
       return factory.createSocket(host, port);
 92  
    }
 93  
    public Socket createSocket(final InetAddress address, class="keyword">final int port, class="keyword">final InetAddress localAddress, class="keyword">final int localPort) throws IOException {
 94  0
       return factory.createSocket(address, port, localAddress, localPort);
 95  
    }
 96  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.