// Path: src/android/com/silkimen/http/KeyChainKeyManager.java
// public class KeyChainKeyManager extends X509ExtendedKeyManager {
//   private final String alias;
//   private final X509Certificate[] chain;
//   private final PrivateKey key;
// 
//   public KeyChainKeyManager(String alias, PrivateKey key, X509Certificate[] chain) {
//     this.alias = alias;
//     this.key = key;
//     this.chain = chain;
//   }
// 
//   @Override
//   public String chooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket) {
//     return this.alias;
//   }
// 
//   @Override
//   public X509Certificate[] getCertificateChain(String alias) {
//     return chain;
//   }
// 
//   @Override
//   public PrivateKey getPrivateKey(String alias) {
//     return key;
//   }
// 
//   @Override
//   public final String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
//     // not a client SSLSocket callback
//     throw new UnsupportedOperationException();
//   }
// 
//   @Override
//   public final String[] getClientAliases(String keyType, Principal[] issuers) {
//     // not a client SSLSocket callback
//     throw new UnsupportedOperationException();
//   }
// 
//   @Override
//   public final String[] getServerAliases(String keyType, Principal[] issuers) {
//     // not a client SSLSocket callback
//     throw new UnsupportedOperationException();
//   }
// }
// 
// Path: src/android/com/silkimen/http/TLSConfiguration.java
// public class TLSConfiguration {
//   private TrustManager[] trustManagers = null;
//   private KeyManager[] keyManagers = null;
//   private HostnameVerifier hostnameVerifier = null;
//   private String[] blacklistedProtocols = {};
// 
//   private SSLSocketFactory socketFactory;
// 
//   public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
//     this.hostnameVerifier = hostnameVerifier;
//   }
// 
//   public void setKeyManagers(KeyManager[] keyManagers) {
//     this.keyManagers = keyManagers;
//     this.socketFactory = null;
//   }
// 
//   public void setTrustManagers(TrustManager[] trustManagers) {
//     this.trustManagers = trustManagers;
//     this.socketFactory = null;
//   }
// 
//   public void setBlacklistedProtocols(String[] protocols) {
//     this.blacklistedProtocols = protocols;
//     this.socketFactory = null;
//   }
// 
//   public HostnameVerifier getHostnameVerifier() {
//     return this.hostnameVerifier;
//   }
// 
//   public SSLSocketFactory getTLSSocketFactory() throws IOException {
//     if (this.socketFactory != null) {
//       return this.socketFactory;
//     }
// 
//     try {
//       SSLContext context = SSLContext.getInstance("TLS");
// 
//       context.init(this.keyManagers, this.trustManagers, new SecureRandom());
//       this.socketFactory = new TLSSocketFactory(context, this.blacklistedProtocols);
// 
//       return this.socketFactory;
//     } catch (GeneralSecurityException e) {
//       IOException ioException = new IOException("Security exception occured while configuring TLS context");
//       ioException.initCause(e);
//       throw ioException;
//     }
//   }
// }


import android.app.Activity;
import android.content.Context;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import org.apache.cordova.CallbackContext;
import com.silkimen.http.KeyChainKeyManager;
import com.silkimen.http.TLSConfiguration;
package com.silkimen.cordovahttp;






class CordovaClientAuth implements Runnable, KeyChainAliasCallback {
  private static final String TAG = "Cordova-Plugin-HTTP";

  private String mode;
  private String aliasString;
  private byte[] rawPkcs;
  private String pkcsPassword;
  private Activity activity;
  private Context context;
// Path: src/android/com/silkimen/http/KeyChainKeyManager.java
// public class KeyChainKeyManager extends X509ExtendedKeyManager {
//   private final String alias;
//   private final X509Certificate[] chain;
//   private final PrivateKey key;
// 
//   public KeyChainKeyManager(String alias, PrivateKey key, X509Certificate[] chain) {
//     this.alias = alias;
//     this.key = key;
//     this.chain = chain;
//   }
// 
//   @Override
//   public String chooseClientAlias(String[] keyTypes, Principal[] issuers, Socket socket) {
//     return this.alias;
//   }
// 
//   @Override
//   public X509Certificate[] getCertificateChain(String alias) {
//     return chain;
//   }
// 
//   @Override
//   public PrivateKey getPrivateKey(String alias) {
//     return key;
//   }
// 
//   @Override
//   public final String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
//     // not a client SSLSocket callback
//     throw new UnsupportedOperationException();
//   }
// 
//   @Override
//   public final String[] getClientAliases(String keyType, Principal[] issuers) {
//     // not a client SSLSocket callback
//     throw new UnsupportedOperationException();
//   }
// 
//   @Override
//   public final String[] getServerAliases(String keyType, Principal[] issuers) {
//     // not a client SSLSocket callback
//     throw new UnsupportedOperationException();
//   }
// }
// 
// Path: src/android/com/silkimen/http/TLSConfiguration.java
// public class TLSConfiguration {
//   private TrustManager[] trustManagers = null;
//   private KeyManager[] keyManagers = null;
//   private HostnameVerifier hostnameVerifier = null;
//   private String[] blacklistedProtocols = {};
// 
//   private SSLSocketFactory socketFactory;
// 
//   public void setHostnameVerifier(HostnameVerifier hostnameVerifier) {
//     this.hostnameVerifier = hostnameVerifier;
//   }
// 
//   public void setKeyManagers(KeyManager[] keyManagers) {
//     this.keyManagers = keyManagers;
//     this.socketFactory = null;
//   }
// 
//   public void setTrustManagers(TrustManager[] trustManagers) {
//     this.trustManagers = trustManagers;
//     this.socketFactory = null;
//   }
// 
//   public void setBlacklistedProtocols(String[] protocols) {
//     this.blacklistedProtocols = protocols;
//     this.socketFactory = null;
//   }
// 
//   public HostnameVerifier getHostnameVerifier() {
//     return this.hostnameVerifier;
//   }
// 
//   public SSLSocketFactory getTLSSocketFactory() throws IOException {
//     if (this.socketFactory != null) {
//       return this.socketFactory;
//     }
// 
//     try {
//       SSLContext context = SSLContext.getInstance("TLS");
// 
//       context.init(this.keyManagers, this.trustManagers, new SecureRandom());
//       this.socketFactory = new TLSSocketFactory(context, this.blacklistedProtocols);
// 
//       return this.socketFactory;
//     } catch (GeneralSecurityException e) {
//       IOException ioException = new IOException("Security exception occured while configuring TLS context");
//       ioException.initCause(e);
//       throw ioException;
//     }
//   }
// }


// Path: src/android/com/silkimen/cordovahttp/CordovaClientAuth.java
import android.app.Activity;
import android.content.Context;
import android.security.KeyChain;
import android.security.KeyChainAliasCallback;
import android.util.Log;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.URI;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import org.apache.cordova.CallbackContext;
import com.silkimen.http.KeyChainKeyManager;
import com.silkimen.http.TLSConfiguration;

package com.silkimen.cordovahttp;






class CordovaClientAuth implements Runnable, KeyChainAliasCallback {
  private static final String TAG = "Cordova-Plugin-HTTP";

  private String mode;
  private String aliasString;
  private byte[] rawPkcs;
  private String pkcsPassword;
  private Activity activity;
  private Context context;
  private TLSConfiguration tlsConfiguration;