package com.umeng.umverify.utils; import com.baidu.mobads.sdk.internal.ae; import com.mbridge.msdk.playercommon.exoplayer2.DefaultLoadControl; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; import java.security.SecureRandom; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import org.json.JSONObject; public final class d { public static String a(String str, JSONObject jSONObject) { try { HttpsURLConnection b = b(str, jSONObject); if (b == null || b.getResponseCode() != 200) { return null; } InputStreamReader inputStreamReader = new InputStreamReader(b.getInputStream()); StringBuffer stringBuffer = new StringBuffer(); while (true) { int read = inputStreamReader.read(); if (read == -1) { return stringBuffer.toString(); } stringBuffer.append((char) read); } } catch (Exception e) { e.printStackTrace(); return null; } } private static HttpsURLConnection b(String str, JSONObject jSONObject) { Exception e; HttpsURLConnection httpsURLConnection = null; try { HttpsURLConnection httpsURLConnection2 = (HttpsURLConnection) new URL(str).openConnection(); try { SSLContext instance = SSLContext.getInstance("TLS"); instance.init(null, null, new SecureRandom()); httpsURLConnection2.setSSLSocketFactory(instance.getSocketFactory()); httpsURLConnection2.setRequestMethod(ae.b); httpsURLConnection2.setConnectTimeout(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS); httpsURLConnection2.setDoOutput(true); httpsURLConnection2.setDoInput(true); httpsURLConnection2.setReadTimeout(DefaultLoadControl.DEFAULT_MIN_BUFFER_MS); httpsURLConnection2.setRequestProperty("Content-Type", "application/json"); httpsURLConnection2.connect(); httpsURLConnection2.setHostnameVerifier(new HostnameVerifier() { /* class com.umeng.umverify.utils.d.AnonymousClass1 */ public final boolean verify(String str, SSLSession sSLSession) { if ("ai.login.umeng.com".equalsIgnoreCase(str)) { return true; } return HttpsURLConnection.getDefaultHostnameVerifier().verify("ai.login.umeng.com", sSLSession); } }); String jSONObject2 = jSONObject.toString(); OutputStream outputStream = httpsURLConnection2.getOutputStream(); outputStream.write(jSONObject2.getBytes()); outputStream.flush(); outputStream.close(); return httpsURLConnection2; } catch (Exception e2) { e = e2; httpsURLConnection = httpsURLConnection2; } } catch (Exception e3) { e = e3; e.printStackTrace(); return httpsURLConnection; } } }