1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17 package com.android.server.wifi.hotspot2.soap; 18 19 import android.annotation.NonNull; 20 import android.net.Network; 21 22 import org.ksoap2.transport.HttpTransportSE; 23 import org.ksoap2.transport.ServiceConnection; 24 25 import java.io.IOException; 26 import java.net.URL; 27 28 /** 29 * Https Transport Layer for SOAP message over the {@link HttpsServiceConnection}. 30 */ 31 public class HttpsTransport extends HttpTransportSE { 32 private Network mNetwork; 33 private URL mUrl; 34 private ServiceConnection mServiceConnection; 35 HttpsTransport(@onNull Network network, @NonNull URL url)36 private HttpsTransport(@NonNull Network network, @NonNull URL url) { 37 super(url.toString()); 38 mNetwork = network; 39 mUrl = url; 40 } 41 42 /** 43 * Create an instance of {@link HttpsTransport}. 44 * 45 * @param network instance of {@link Network} that indicates current connection. 46 * @param url server url used for HTTPS connection. 47 * @return instance of {@link HttpsTransport} 48 */ createInstance(@onNull Network network, @NonNull URL url)49 public static HttpsTransport createInstance(@NonNull Network network, @NonNull URL url) { 50 return new HttpsTransport(network, url); 51 } 52 53 @Override getServiceConnection()54 public ServiceConnection getServiceConnection() throws IOException { 55 if (mServiceConnection == null) { 56 mServiceConnection = new HttpsServiceConnection(mNetwork, mUrl); 57 } 58 return mServiceConnection; 59 } 60 } 61