123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392 |
- .class public final Lokhttp3/internal/tls/HeldCertificate$Builder;
- .super Ljava/lang/Object;
- .source ""
- # annotations
- .annotation system Ldalvik/annotation/EnclosingClass;
- value = Lokhttp3/internal/tls/HeldCertificate;
- .end annotation
- .annotation system Ldalvik/annotation/InnerClass;
- accessFlags = 0x19
- name = "Builder"
- .end annotation
- # instance fields
- .field private altNames:Ljava/util/List;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/List<",
- "Ljava/lang/String;",
- ">;"
- }
- .end annotation
- .end field
- .field private final duration:J
- .field private hostname:Ljava/lang/String;
- .field private issuedBy:Lokhttp3/internal/tls/HeldCertificate;
- .field private keyPair:Ljava/security/KeyPair;
- .field private maxIntermediateCas:I
- .field private serialNumber:Ljava/lang/String;
- # direct methods
- .method static constructor <clinit>()V
- .locals 1
- new-instance v0, Lorg/bouncycastle/jce/provider/BouncyCastleProvider;
- invoke-direct {v0}, Lorg/bouncycastle/jce/provider/BouncyCastleProvider;-><init>()V
- invoke-static {v0}, Ljava/security/Security;->addProvider(Ljava/security/Provider;)I
- return-void
- .end method
- .method public constructor <init>()V
- .locals 2
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- const-wide/32 v0, 0x5265c00
- iput-wide v0, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->duration:J
- new-instance v0, Ljava/util/ArrayList;
- invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->altNames:Ljava/util/List;
- const-string v0, "1"
- iput-object v0, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->serialNumber:Ljava/lang/String;
- return-void
- .end method
- # virtual methods
- .method public build()Lokhttp3/internal/tls/HeldCertificate;
- .locals 10
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/security/GeneralSecurityException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->keyPair:Ljava/security/KeyPair;
- if-eqz v0, :cond_0
- goto :goto_0
- :cond_0
- invoke-virtual {p0}, Lokhttp3/internal/tls/HeldCertificate$Builder;->generateKeyPair()Ljava/security/KeyPair;
- move-result-object v0
- :goto_0
- iget-object v1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->hostname:Ljava/lang/String;
- const-string v2, "CN="
- if-eqz v1, :cond_1
- new-instance v1, Ljavax/security/auth/x500/X500Principal;
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- iget-object v2, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->hostname:Ljava/lang/String;
- invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v2
- invoke-direct {v1, v2}, Ljavax/security/auth/x500/X500Principal;-><init>(Ljava/lang/String;)V
- goto :goto_1
- :cond_1
- new-instance v1, Ljavax/security/auth/x500/X500Principal;
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;
- move-result-object v2
- invoke-virtual {v3, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v2
- invoke-direct {v1, v2}, Ljavax/security/auth/x500/X500Principal;-><init>(Ljava/lang/String;)V
- :goto_1
- iget-object v2, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->issuedBy:Lokhttp3/internal/tls/HeldCertificate;
- if-eqz v2, :cond_2
- iget-object v3, v2, Lokhttp3/internal/tls/HeldCertificate;->keyPair:Ljava/security/KeyPair;
- iget-object v2, v2, Lokhttp3/internal/tls/HeldCertificate;->certificate:Ljava/security/cert/X509Certificate;
- invoke-virtual {v2}, Ljava/security/cert/X509Certificate;->getSubjectX500Principal()Ljavax/security/auth/x500/X500Principal;
- move-result-object v2
- goto :goto_2
- :cond_2
- move-object v3, v0
- move-object v2, v1
- :goto_2
- invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
- move-result-wide v4
- new-instance v6, Lorg/bouncycastle/x509/i;
- invoke-direct {v6}, Lorg/bouncycastle/x509/i;-><init>()V
- new-instance v7, Ljava/math/BigInteger;
- iget-object v8, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->serialNumber:Ljava/lang/String;
- invoke-direct {v7, v8}, Ljava/math/BigInteger;-><init>(Ljava/lang/String;)V
- invoke-virtual {v6, v7}, Lorg/bouncycastle/x509/i;->a(Ljava/math/BigInteger;)V
- invoke-virtual {v6, v2}, Lorg/bouncycastle/x509/i;->a(Ljavax/security/auth/x500/X500Principal;)V
- new-instance v2, Ljava/util/Date;
- invoke-direct {v2, v4, v5}, Ljava/util/Date;-><init>(J)V
- invoke-virtual {v6, v2}, Lorg/bouncycastle/x509/i;->b(Ljava/util/Date;)V
- new-instance v2, Ljava/util/Date;
- const-wide/32 v7, 0x5265c00
- add-long/2addr v4, v7
- invoke-direct {v2, v4, v5}, Ljava/util/Date;-><init>(J)V
- invoke-virtual {v6, v2}, Lorg/bouncycastle/x509/i;->a(Ljava/util/Date;)V
- invoke-virtual {v6, v1}, Lorg/bouncycastle/x509/i;->b(Ljavax/security/auth/x500/X500Principal;)V
- invoke-virtual {v0}, Ljava/security/KeyPair;->getPublic()Ljava/security/PublicKey;
- move-result-object v1
- invoke-virtual {v6, v1}, Lorg/bouncycastle/x509/i;->a(Ljava/security/PublicKey;)V
- const-string v1, "SHA256WithRSAEncryption"
- invoke-virtual {v6, v1}, Lorg/bouncycastle/x509/i;->a(Ljava/lang/String;)V
- iget v1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->maxIntermediateCas:I
- const/4 v2, 0x1
- if-lez v1, :cond_3
- sget-object v4, Lorg/bouncycastle/asn1/k2/e0;->T0:Lorg/bouncycastle/asn1/l;
- new-instance v5, Lorg/bouncycastle/asn1/k2/h;
- invoke-direct {v5, v1}, Lorg/bouncycastle/asn1/k2/h;-><init>(I)V
- invoke-virtual {v6, v4, v2, v5}, Lorg/bouncycastle/x509/i;->a(Lorg/bouncycastle/asn1/a1;ZLorg/bouncycastle/asn1/d;)V
- :cond_3
- iget-object v1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->altNames:Ljava/util/List;
- invoke-interface {v1}, Ljava/util/List;->isEmpty()Z
- move-result v1
- if-nez v1, :cond_6
- iget-object v1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->altNames:Ljava/util/List;
- invoke-interface {v1}, Ljava/util/List;->size()I
- move-result v1
- new-array v1, v1, [Lorg/bouncycastle/asn1/d;
- const/4 v4, 0x0
- iget-object v5, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->altNames:Ljava/util/List;
- invoke-interface {v5}, Ljava/util/List;->size()I
- move-result v5
- :goto_3
- if-ge v4, v5, :cond_5
- iget-object v7, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->altNames:Ljava/util/List;
- invoke-interface {v7, v4}, Ljava/util/List;->get(I)Ljava/lang/Object;
- move-result-object v7
- check-cast v7, Ljava/lang/String;
- invoke-static {v7}, Lokhttp3/internal/Util;->verifyAsIpAddress(Ljava/lang/String;)Z
- move-result v8
- if-eqz v8, :cond_4
- const/4 v8, 0x7
- goto :goto_4
- :cond_4
- const/4 v8, 0x2
- :goto_4
- new-instance v9, Lorg/bouncycastle/asn1/k2/m;
- invoke-direct {v9, v8, v7}, Lorg/bouncycastle/asn1/k2/m;-><init>(ILjava/lang/String;)V
- aput-object v9, v1, v4
- add-int/lit8 v4, v4, 0x1
- goto :goto_3
- :cond_5
- sget-object v4, Lorg/bouncycastle/asn1/k2/e0;->S0:Lorg/bouncycastle/asn1/l;
- new-instance v5, Lorg/bouncycastle/asn1/f1;
- invoke-direct {v5, v1}, Lorg/bouncycastle/asn1/f1;-><init>([Lorg/bouncycastle/asn1/d;)V
- invoke-virtual {v6, v4, v2, v5}, Lorg/bouncycastle/x509/i;->a(Lorg/bouncycastle/asn1/a1;ZLorg/bouncycastle/asn1/d;)V
- :cond_6
- invoke-virtual {v3}, Ljava/security/KeyPair;->getPrivate()Ljava/security/PrivateKey;
- move-result-object v1
- const-string v2, "BC"
- invoke-virtual {v6, v1, v2}, Lorg/bouncycastle/x509/i;->a(Ljava/security/PrivateKey;Ljava/lang/String;)Ljava/security/cert/X509Certificate;
- move-result-object v1
- new-instance v2, Lokhttp3/internal/tls/HeldCertificate;
- invoke-direct {v2, v1, v0}, Lokhttp3/internal/tls/HeldCertificate;-><init>(Ljava/security/cert/X509Certificate;Ljava/security/KeyPair;)V
- return-object v2
- .end method
- .method public ca(I)Lokhttp3/internal/tls/HeldCertificate$Builder;
- .locals 0
- iput p1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->maxIntermediateCas:I
- return-object p0
- .end method
- .method public commonName(Ljava/lang/String;)Lokhttp3/internal/tls/HeldCertificate$Builder;
- .locals 0
- iput-object p1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->hostname:Ljava/lang/String;
- return-object p0
- .end method
- .method public generateKeyPair()Ljava/security/KeyPair;
- .locals 3
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/security/GeneralSecurityException;
- }
- .end annotation
- const-string v0, "RSA"
- const-string v1, "BC"
- invoke-static {v0, v1}, Ljava/security/KeyPairGenerator;->getInstance(Ljava/lang/String;Ljava/lang/String;)Ljava/security/KeyPairGenerator;
- move-result-object v0
- new-instance v1, Ljava/security/SecureRandom;
- invoke-direct {v1}, Ljava/security/SecureRandom;-><init>()V
- const/16 v2, 0x400
- invoke-virtual {v0, v2, v1}, Ljava/security/KeyPairGenerator;->initialize(ILjava/security/SecureRandom;)V
- invoke-virtual {v0}, Ljava/security/KeyPairGenerator;->generateKeyPair()Ljava/security/KeyPair;
- move-result-object v0
- return-object v0
- .end method
- .method public issuedBy(Lokhttp3/internal/tls/HeldCertificate;)Lokhttp3/internal/tls/HeldCertificate$Builder;
- .locals 0
- iput-object p1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->issuedBy:Lokhttp3/internal/tls/HeldCertificate;
- return-object p0
- .end method
- .method public keyPair(Ljava/security/KeyPair;)Lokhttp3/internal/tls/HeldCertificate$Builder;
- .locals 0
- iput-object p1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->keyPair:Ljava/security/KeyPair;
- return-object p0
- .end method
- .method public serialNumber(Ljava/lang/String;)Lokhttp3/internal/tls/HeldCertificate$Builder;
- .locals 0
- iput-object p1, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->serialNumber:Ljava/lang/String;
- return-object p0
- .end method
- .method public subjectAlternativeName(Ljava/lang/String;)Lokhttp3/internal/tls/HeldCertificate$Builder;
- .locals 1
- iget-object v0, p0, Lokhttp3/internal/tls/HeldCertificate$Builder;->altNames:Ljava/util/List;
- invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
- return-object p0
- .end method
|