package io.beid.beidk; import android.os.Parcel; import android.os.Parcelable; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.concurrent.TimeUnit; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import okhttp3.OkHttpClient; /* loaded from: classes5.dex */ public class BEIDConfigurationFactory implements Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { // from class: io.beid.beidk.BEIDConfigurationFactory.2 /* JADX WARN: Can't rename method to resolve collision */ @Override // android.os.Parcelable.Creator public final BEIDConfigurationFactory[] newArray(int i) { return new BEIDConfigurationFactory[i]; } /* JADX WARN: Can't rename method to resolve collision */ @Override // android.os.Parcelable.Creator public final BEIDConfigurationFactory createFromParcel(Parcel parcel) { return new BEIDConfigurationFactory(parcel); } }; private String a; private TrustManager[] b; private String c; private Boolean d; private String e; private OkHttpClient f; private InputStream h; private String i; private Integer j; @Override // android.os.Parcelable public int describeContents() { return 0; } @Override // android.os.Parcelable public void writeToParcel(Parcel parcel, int i) { byte[] bArr; try { InputStream inputStream = this.h; if (inputStream != null) { inputStream.reset(); bArr = new byte[this.h.available()]; ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bArr2 = new byte[4096]; while (this.h.read(bArr2) != -1) { byteArrayOutputStream.write(bArr2); } byteArrayOutputStream.write(bArr); } else { bArr = null; } parcel.writeString(this.e); parcel.writeString(this.c); parcel.writeString(this.a); parcel.writeInt(this.d.booleanValue() ? 1 : 0); parcel.writeInt(this.j.intValue()); parcel.writeString(this.i); if (bArr != null) { parcel.writeInt(bArr.length); parcel.writeByteArray(bArr); } else { parcel.writeInt(0); parcel.writeByteArray(new byte[0]); } } catch (Exception unused) { } } public void setBaseUrl(String str) { this.e = str; } public String getUserAgent() { return this.i; } public Boolean getUseSSL() { return this.d; } /* loaded from: classes5.dex */ public static class Builder { private String d; private InputStream i; private String e = ""; private String a = ""; private Boolean c = Boolean.FALSE; private Integer b = 30; private String f = "Swagger-Codegen/1.0.0/java"; public Builder setUserAgent(String str) { this.f = str; return this; } public Builder setUseSSL(Boolean bool) { this.c = bool; return this; } public Builder setSSLPublicKey(String str) { this.a = str; return this; } public Builder setHostname(String str) { this.e = str; return this; } public Builder setCertificate(InputStream inputStream) { this.i = inputStream; return this; } public Builder setBaseUrl(String str) throws URISyntaxException { URI uri = new URI(str); this.d = str; this.e = uri.getHost(); return this; } public Builder setApiTimeOut(Integer num) { this.b = num; return this; } public BEIDConfigurationFactory Build() { return new BEIDConfigurationFactory(this.d, this.e, this.a, this.c, this.b, this.i, this.f); } } public String getSslPublicKey() { return this.a; } public OkHttpClient getHttpClient() throws MissingParameterException, NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, KeyManagementException { if (this.f == null) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); getUseSSL(); builder.connectTimeout(getApiTimeOut().intValue(), TimeUnit.SECONDS).readTimeout(getApiTimeOut().intValue(), TimeUnit.SECONDS).writeTimeout(getApiTimeOut().intValue(), TimeUnit.SECONDS); this.f = builder.build(); } return this.f; } public String getHostname() { return this.c; } public String getBaseUrl() { return this.e; } public Integer getApiTimeOut() { return this.j; } public static Builder Builder() { return new Builder(); } public BEIDConfigurationFactory(String str, String str2, String str3, Boolean bool, Integer num, InputStream inputStream, String str4) { this.b = new TrustManager[]{new X509TrustManager(this) { // from class: io.beid.beidk.BEIDConfigurationFactory.1 private BEIDConfigurationFactory b; @Override // javax.net.ssl.X509TrustManager public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str5) throws CertificateException { } @Override // javax.net.ssl.X509TrustManager public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str5) throws CertificateException { } @Override // javax.net.ssl.X509TrustManager public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } { this.b = this; } }}; this.e = str; this.c = str2; this.a = str3; this.d = bool; this.j = num; this.h = inputStream; this.i = str4; } /* renamed from: io.beid.beidk.BEIDConfigurationFactory$3, reason: invalid class name */ /* loaded from: classes5.dex */ class AnonymousClass3 implements HostnameVerifier { private BEIDConfigurationFactory d; @Override // javax.net.ssl.HostnameVerifier public boolean verify(String str, SSLSession sSLSession) { HttpsURLConnection.getDefaultHostnameVerifier(); throw null; } } /* loaded from: classes5.dex */ public static class MissingParameterException extends Exception { public MissingParameterException(String str) { super(str); } } protected BEIDConfigurationFactory(Parcel parcel) { this.b = new TrustManager[]{new X509TrustManager(this) { // from class: io.beid.beidk.BEIDConfigurationFactory.1 private BEIDConfigurationFactory b; @Override // javax.net.ssl.X509TrustManager public void checkClientTrusted(X509Certificate[] x509CertificateArr, String str5) throws CertificateException { } @Override // javax.net.ssl.X509TrustManager public void checkServerTrusted(X509Certificate[] x509CertificateArr, String str5) throws CertificateException { } @Override // javax.net.ssl.X509TrustManager public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } { this.b = this; } }}; this.e = parcel.readString(); this.c = parcel.readString(); this.a = parcel.readString(); this.d = Boolean.valueOf(parcel.readInt() == 1); this.j = Integer.valueOf(parcel.readInt()); this.i = parcel.readString(); int readInt = parcel.readInt(); byte[] bArr = new byte[readInt]; parcel.readByteArray(bArr); if (readInt > 0) { this.h = new ByteArrayInputStream(bArr); } } }