1 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>HttpClientFactory.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">vfc-nfvo-driver-ems-ems-boco</a> > <a href="index.source.html" class="el_package">org.onap.vfc.nfvo.emsdriver.northbound.client</a> > <span class="el_source">HttpClientFactory.java</span></div><h1>HttpClientFactory.java</h1><pre class="source lang-java linenums">/**
 
   2  * Copyright 2017 BOCO Corporation.  CMCC Technologies Co., Ltd
 
   4  * Licensed under the Apache License, Version 2.0 (the "License");
 
   5  * you may not use this file except in compliance with the License.
 
   6  * You may obtain a copy of the License at
 
   8  *     http://www.apache.org/licenses/LICENSE-2.0
 
  10  * Unless required by applicable law or agreed to in writing, software
 
  11  * distributed under the License is distributed on an "AS IS" BASIS,
 
  12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  13  * See the License for the specific language governing permissions and
 
  14  * limitations under the License.
 
  16 package org.onap.vfc.nfvo.emsdriver.northbound.client;
 
  18 import java.security.cert.CertificateException;
 
  19 import java.security.cert.X509Certificate;
 
  21 import javax.net.ssl.SSLContext;
 
  23 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 
  24 import org.apache.http.conn.ssl.TrustStrategy;
 
  25 import org.apache.http.impl.client.CloseableHttpClient;
 
  26 import org.apache.http.impl.client.HttpClients;
 
  27 import org.apache.http.ssl.SSLContextBuilder;
 
  32 <span class="nc" id="L32">public class HttpClientFactory{</span>
 
  35         public static CloseableHttpClient getSSLClientFactory() throws Exception {
 
  37 <span class="fc" id="L37">              SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {</span>
 
  39              public boolean isTrusted(X509Certificate[] chain,
 
  40                              String authType) throws CertificateException {
 
  41 <span class="nc" id="L41">                 return true;</span>
 
  43 <span class="fc" id="L43">         }).build();</span>
 
  44 <span class="fc" id="L44">         SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);</span>
 
  45 <span class="fc" id="L45">         CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();</span>
 
  47 <span class="fc" id="L47">         return httpclient;</span>
 
  51 </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html>