Coverage Report - org.apache.maven.wagon.providers.http.LightweightHttpsWagon
 
Classes in this File Line Coverage Branch Coverage Complexity
LightweightHttpsWagon
84 %
16/19
50 %
1/2
1,333
 
 1  
 package org.apache.maven.wagon.providers.http;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.wagon.ConnectionException;
 23  
 import org.apache.maven.wagon.authentication.AuthenticationException;
 24  
 import org.apache.maven.wagon.proxy.ProxyInfo;
 25  
 
 26  
 /**
 27  
  * LightweightHttpsWagon, using JDK's HttpURLConnection.
 28  
  *
 29  
  * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
 30  
  * @version $Id: LightweightHttpsWagon.java 1173334 2011-09-20 20:17:48Z hboutemy $
 31  
  * 
 32  
  * @plexus.component role="org.apache.maven.wagon.Wagon" 
 33  
  *   role-hint="https"
 34  
  *   instantiation-strategy="per-lookup"
 35  
  */
 36  
 public class LightweightHttpsWagon
 37  
     extends LightweightHttpWagon
 38  
 {
 39  
     private String previousHttpsProxyHost;
 40  
     
 41  
     private String previousHttpsProxyPort;
 42  
 
 43  
     private String previousHttpsProxyExclusions;
 44  
 
 45  
     public LightweightHttpsWagon()
 46  
     {
 47  59
         super();
 48  59
     }
 49  
 
 50  
     public void openConnection()
 51  
         throws ConnectionException, AuthenticationException
 52  
     {
 53  55
         previousHttpsProxyHost = System.getProperty( "https.proxyHost" );
 54  55
         previousHttpsProxyPort = System.getProperty( "https.proxyPort" );
 55  55
         previousHttpsProxyExclusions = System.getProperty( "https.nonProxyHosts" );
 56  
         
 57  55
         final ProxyInfo proxyInfo = getProxyInfo( "https", getRepository().getHost() );
 58  55
         if ( proxyInfo != null )
 59  
         {
 60  0
             setSystemProperty( "https.proxyHost", proxyInfo.getHost() );
 61  0
             setSystemProperty( "https.proxyPort", String.valueOf( proxyInfo.getPort() ) );
 62  0
             setSystemProperty( "https.nonProxyHosts", proxyInfo.getNonProxyHosts() );
 63  
         }
 64  
         else
 65  
         {
 66  55
             setSystemProperty( "https.proxyHost", null );
 67  55
             setSystemProperty( "https.proxyPort", null );
 68  
         }
 69  
         
 70  55
         super.openConnection();
 71  55
     }
 72  
 
 73  
     public void closeConnection()
 74  
         throws ConnectionException
 75  
     {
 76  55
         super.closeConnection();
 77  
 
 78  55
         setSystemProperty( "https.proxyHost", previousHttpsProxyHost );
 79  55
         setSystemProperty( "https.proxyPort", previousHttpsProxyPort );
 80  55
         setSystemProperty( "https.nonProxyHosts", previousHttpsProxyExclusions );
 81  55
     }
 82  
 }