123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- .class public Lokhttp3/internal/tls/SslClient$Builder;
- .super Ljava/lang/Object;
- .source ""
- # annotations
- .annotation system Ldalvik/annotation/EnclosingClass;
- value = Lokhttp3/internal/tls/SslClient;
- .end annotation
- .annotation system Ldalvik/annotation/InnerClass;
- accessFlags = 0x9
- name = "Builder"
- .end annotation
- # instance fields
- .field private final certificates:Ljava/util/List;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/List<",
- "Ljava/security/cert/X509Certificate;",
- ">;"
- }
- .end annotation
- .end field
- .field private final chainCertificates:Ljava/util/List;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/List<",
- "Ljava/security/cert/X509Certificate;",
- ">;"
- }
- .end annotation
- .end field
- .field private keyPair:Ljava/security/KeyPair;
- .field private keyStoreType:Ljava/lang/String;
- # direct methods
- .method public constructor <init>()V
- .locals 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- new-instance v0, Ljava/util/ArrayList;
- invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/tls/SslClient$Builder;->chainCertificates:Ljava/util/List;
- new-instance v0, Ljava/util/ArrayList;
- invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/tls/SslClient$Builder;->certificates:Ljava/util/List;
- invoke-static {}, Ljava/security/KeyStore;->getDefaultType()Ljava/lang/String;
- move-result-object v0
- iput-object v0, p0, Lokhttp3/internal/tls/SslClient$Builder;->keyStoreType:Ljava/lang/String;
- return-void
- .end method
- .method private newEmptyKeyStore([C)Ljava/security/KeyStore;
- .locals 2
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/security/GeneralSecurityException;
- }
- .end annotation
- :try_start_0
- iget-object v0, p0, Lokhttp3/internal/tls/SslClient$Builder;->keyStoreType:Ljava/lang/String;
- invoke-static {v0}, Ljava/security/KeyStore;->getInstance(Ljava/lang/String;)Ljava/security/KeyStore;
- move-result-object v0
- const/4 v1, 0x0
- invoke-virtual {v0, v1, p1}, Ljava/security/KeyStore;->load(Ljava/io/InputStream;[C)V
- :try_end_0
- .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
- return-object v0
- :catch_0
- move-exception p1
- new-instance v0, Ljava/lang/AssertionError;
- invoke-direct {v0, p1}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
- throw v0
- .end method
- # virtual methods
- .method public addTrustedCertificate(Ljava/security/cert/X509Certificate;)Lokhttp3/internal/tls/SslClient$Builder;
- .locals 1
- iget-object v0, p0, Lokhttp3/internal/tls/SslClient$Builder;->certificates:Ljava/util/List;
- invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
- return-object p0
- .end method
- .method public build()Lokhttp3/internal/tls/SslClient;
- .locals 6
- :try_start_0
- const-string v0, "password"
- invoke-virtual {v0}, Ljava/lang/String;->toCharArray()[C
- move-result-object v0
- invoke-direct {p0, v0}, Lokhttp3/internal/tls/SslClient$Builder;->newEmptyKeyStore([C)Ljava/security/KeyStore;
- move-result-object v1
- iget-object v2, p0, Lokhttp3/internal/tls/SslClient$Builder;->keyPair:Ljava/security/KeyPair;
- if-eqz v2, :cond_0
- iget-object v2, p0, Lokhttp3/internal/tls/SslClient$Builder;->chainCertificates:Ljava/util/List;
- iget-object v3, p0, Lokhttp3/internal/tls/SslClient$Builder;->chainCertificates:Ljava/util/List;
- invoke-interface {v3}, Ljava/util/List;->size()I
- move-result v3
- new-array v3, v3, [Ljava/security/cert/Certificate;
- invoke-interface {v2, v3}, Ljava/util/List;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;
- move-result-object v2
- check-cast v2, [Ljava/security/cert/Certificate;
- const-string v3, "private"
- iget-object v4, p0, Lokhttp3/internal/tls/SslClient$Builder;->keyPair:Ljava/security/KeyPair;
- invoke-virtual {v4}, Ljava/security/KeyPair;->getPrivate()Ljava/security/PrivateKey;
- move-result-object v4
- invoke-virtual {v1, v3, v4, v0, v2}, Ljava/security/KeyStore;->setKeyEntry(Ljava/lang/String;Ljava/security/Key;[C[Ljava/security/cert/Certificate;)V
- :cond_0
- const/4 v2, 0x0
- const/4 v3, 0x0
- :goto_0
- iget-object v4, p0, Lokhttp3/internal/tls/SslClient$Builder;->certificates:Ljava/util/List;
- invoke-interface {v4}, Ljava/util/List;->size()I
- move-result v4
- if-ge v3, v4, :cond_1
- new-instance v4, Ljava/lang/StringBuilder;
- invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
- const-string v5, "cert_"
- invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v4, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
- invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v4
- iget-object v5, p0, Lokhttp3/internal/tls/SslClient$Builder;->certificates:Ljava/util/List;
- invoke-interface {v5, v3}, Ljava/util/List;->get(I)Ljava/lang/Object;
- move-result-object v5
- check-cast v5, Ljava/security/cert/Certificate;
- invoke-virtual {v1, v4, v5}, Ljava/security/KeyStore;->setCertificateEntry(Ljava/lang/String;Ljava/security/cert/Certificate;)V
- add-int/lit8 v3, v3, 0x1
- goto :goto_0
- :cond_1
- invoke-static {}, Ljavax/net/ssl/KeyManagerFactory;->getDefaultAlgorithm()Ljava/lang/String;
- move-result-object v3
- invoke-static {v3}, Ljavax/net/ssl/KeyManagerFactory;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/KeyManagerFactory;
- move-result-object v3
- invoke-virtual {v3, v1, v0}, Ljavax/net/ssl/KeyManagerFactory;->init(Ljava/security/KeyStore;[C)V
- invoke-static {}, Ljavax/net/ssl/TrustManagerFactory;->getDefaultAlgorithm()Ljava/lang/String;
- move-result-object v0
- invoke-static {v0}, Ljavax/net/ssl/TrustManagerFactory;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/TrustManagerFactory;
- move-result-object v0
- invoke-virtual {v0, v1}, Ljavax/net/ssl/TrustManagerFactory;->init(Ljava/security/KeyStore;)V
- invoke-virtual {v0}, Ljavax/net/ssl/TrustManagerFactory;->getTrustManagers()[Ljavax/net/ssl/TrustManager;
- move-result-object v0
- array-length v1, v0
- const/4 v4, 0x1
- if-ne v1, v4, :cond_2
- aget-object v1, v0, v2
- instance-of v1, v1, Ljavax/net/ssl/X509TrustManager;
- if-eqz v1, :cond_2
- const-string v1, "TLS"
- invoke-static {v1}, Ljavax/net/ssl/SSLContext;->getInstance(Ljava/lang/String;)Ljavax/net/ssl/SSLContext;
- move-result-object v1
- invoke-virtual {v3}, Ljavax/net/ssl/KeyManagerFactory;->getKeyManagers()[Ljavax/net/ssl/KeyManager;
- move-result-object v3
- new-instance v4, Ljava/security/SecureRandom;
- invoke-direct {v4}, Ljava/security/SecureRandom;-><init>()V
- invoke-virtual {v1, v3, v0, v4}, Ljavax/net/ssl/SSLContext;->init([Ljavax/net/ssl/KeyManager;[Ljavax/net/ssl/TrustManager;Ljava/security/SecureRandom;)V
- new-instance v3, Lokhttp3/internal/tls/SslClient;
- aget-object v0, v0, v2
- check-cast v0, Ljavax/net/ssl/X509TrustManager;
- const/4 v2, 0x0
- invoke-direct {v3, v1, v0, v2}, Lokhttp3/internal/tls/SslClient;-><init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/X509TrustManager;Lokhttp3/internal/tls/SslClient$1;)V
- return-object v3
- :cond_2
- new-instance v1, Ljava/lang/IllegalStateException;
- new-instance v2, Ljava/lang/StringBuilder;
- invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
- const-string v3, "Unexpected default trust managers:"
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-static {v0}, Ljava/util/Arrays;->toString([Ljava/lang/Object;)Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v0
- invoke-direct {v1, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
- throw v1
- :try_end_0
- .catch Ljava/security/GeneralSecurityException; {:try_start_0 .. :try_end_0} :catch_0
- :catch_0
- move-exception v0
- new-instance v1, Ljava/lang/AssertionError;
- invoke-direct {v1, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
- goto :goto_2
- :goto_1
- throw v1
- :goto_2
- goto :goto_1
- .end method
- .method public varargs certificateChain(Ljava/security/KeyPair;Ljava/security/cert/X509Certificate;[Ljava/security/cert/X509Certificate;)Lokhttp3/internal/tls/SslClient$Builder;
- .locals 0
- iput-object p1, p0, Lokhttp3/internal/tls/SslClient$Builder;->keyPair:Ljava/security/KeyPair;
- iget-object p1, p0, Lokhttp3/internal/tls/SslClient$Builder;->chainCertificates:Ljava/util/List;
- invoke-interface {p1, p2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
- iget-object p1, p0, Lokhttp3/internal/tls/SslClient$Builder;->chainCertificates:Ljava/util/List;
- invoke-static {p3}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
- move-result-object p2
- invoke-interface {p1, p2}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z
- iget-object p1, p0, Lokhttp3/internal/tls/SslClient$Builder;->certificates:Ljava/util/List;
- invoke-static {p3}, Ljava/util/Arrays;->asList([Ljava/lang/Object;)Ljava/util/List;
- move-result-object p2
- invoke-interface {p1, p2}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z
- return-object p0
- .end method
- .method public varargs certificateChain(Lokhttp3/internal/tls/HeldCertificate;[Lokhttp3/internal/tls/HeldCertificate;)Lokhttp3/internal/tls/SslClient$Builder;
- .locals 3
- array-length v0, p2
- new-array v0, v0, [Ljava/security/cert/X509Certificate;
- const/4 v1, 0x0
- :goto_0
- array-length v2, p2
- if-ge v1, v2, :cond_0
- aget-object v2, p2, v1
- iget-object v2, v2, Lokhttp3/internal/tls/HeldCertificate;->certificate:Ljava/security/cert/X509Certificate;
- aput-object v2, v0, v1
- add-int/lit8 v1, v1, 0x1
- goto :goto_0
- :cond_0
- iget-object p2, p1, Lokhttp3/internal/tls/HeldCertificate;->keyPair:Ljava/security/KeyPair;
- iget-object p1, p1, Lokhttp3/internal/tls/HeldCertificate;->certificate:Ljava/security/cert/X509Certificate;
- invoke-virtual {p0, p2, p1, v0}, Lokhttp3/internal/tls/SslClient$Builder;->certificateChain(Ljava/security/KeyPair;Ljava/security/cert/X509Certificate;[Ljava/security/cert/X509Certificate;)Lokhttp3/internal/tls/SslClient$Builder;
- move-result-object p1
- return-object p1
- .end method
- .method public keyStoreType(Ljava/lang/String;)Lokhttp3/internal/tls/SslClient$Builder;
- .locals 0
- iput-object p1, p0, Lokhttp3/internal/tls/SslClient$Builder;->keyStoreType:Ljava/lang/String;
- return-object p0
- .end method
|