CertificatePinner$Pin.smali 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. .class final Lokhttp3/CertificatePinner$Pin;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/CertificatePinner;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x18
  10. name = "Pin"
  11. .end annotation
  12. # static fields
  13. .field private static final WILDCARD:Ljava/lang/String; = "*."
  14. # instance fields
  15. .field final canonicalHostname:Ljava/lang/String;
  16. .field final hash:Lokio/ByteString;
  17. .field final hashAlgorithm:Ljava/lang/String;
  18. .field final pattern:Ljava/lang/String;
  19. # direct methods
  20. .method constructor <init>(Ljava/lang/String;Ljava/lang/String;)V
  21. .locals 2
  22. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  23. iput-object p1, p0, Lokhttp3/CertificatePinner$Pin;->pattern:Ljava/lang/String;
  24. const-string v0, "*."
  25. invoke-virtual {p1, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  26. move-result v0
  27. const-string v1, "http://"
  28. if-eqz v0, :cond_0
  29. new-instance v0, Ljava/lang/StringBuilder;
  30. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  31. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  32. const/4 v1, 0x2
  33. invoke-virtual {p1, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  34. move-result-object p1
  35. goto :goto_0
  36. :cond_0
  37. new-instance v0, Ljava/lang/StringBuilder;
  38. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  39. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  40. :goto_0
  41. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  42. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  43. move-result-object p1
  44. invoke-static {p1}, Lokhttp3/HttpUrl;->parse(Ljava/lang/String;)Lokhttp3/HttpUrl;
  45. move-result-object p1
  46. invoke-virtual {p1}, Lokhttp3/HttpUrl;->host()Ljava/lang/String;
  47. move-result-object p1
  48. iput-object p1, p0, Lokhttp3/CertificatePinner$Pin;->canonicalHostname:Ljava/lang/String;
  49. const-string p1, "sha1/"
  50. invoke-virtual {p2, p1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  51. move-result v0
  52. if-eqz v0, :cond_1
  53. iput-object p1, p0, Lokhttp3/CertificatePinner$Pin;->hashAlgorithm:Ljava/lang/String;
  54. const/4 p1, 0x5
  55. :goto_1
  56. invoke-virtual {p2, p1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  57. move-result-object p1
  58. invoke-static {p1}, Lokio/ByteString;->decodeBase64(Ljava/lang/String;)Lokio/ByteString;
  59. move-result-object p1
  60. iput-object p1, p0, Lokhttp3/CertificatePinner$Pin;->hash:Lokio/ByteString;
  61. goto :goto_2
  62. :cond_1
  63. const-string p1, "sha256/"
  64. invoke-virtual {p2, p1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  65. move-result v0
  66. if-eqz v0, :cond_3
  67. iput-object p1, p0, Lokhttp3/CertificatePinner$Pin;->hashAlgorithm:Ljava/lang/String;
  68. const/4 p1, 0x7
  69. goto :goto_1
  70. :goto_2
  71. iget-object p1, p0, Lokhttp3/CertificatePinner$Pin;->hash:Lokio/ByteString;
  72. if-eqz p1, :cond_2
  73. return-void
  74. :cond_2
  75. new-instance p1, Ljava/lang/IllegalArgumentException;
  76. new-instance v0, Ljava/lang/StringBuilder;
  77. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  78. const-string v1, "pins must be base64: "
  79. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  80. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  81. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  82. move-result-object p2
  83. invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  84. throw p1
  85. :cond_3
  86. new-instance p1, Ljava/lang/IllegalArgumentException;
  87. new-instance v0, Ljava/lang/StringBuilder;
  88. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  89. const-string v1, "pins must start with \'sha256/\' or \'sha1/\': "
  90. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  91. invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  92. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  93. move-result-object p2
  94. invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  95. goto :goto_4
  96. :goto_3
  97. throw p1
  98. :goto_4
  99. goto :goto_3
  100. .end method
  101. # virtual methods
  102. .method public equals(Ljava/lang/Object;)Z
  103. .locals 2
  104. instance-of v0, p1, Lokhttp3/CertificatePinner$Pin;
  105. if-eqz v0, :cond_0
  106. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->pattern:Ljava/lang/String;
  107. check-cast p1, Lokhttp3/CertificatePinner$Pin;
  108. iget-object v1, p1, Lokhttp3/CertificatePinner$Pin;->pattern:Ljava/lang/String;
  109. invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  110. move-result v0
  111. if-eqz v0, :cond_0
  112. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->hashAlgorithm:Ljava/lang/String;
  113. iget-object v1, p1, Lokhttp3/CertificatePinner$Pin;->hashAlgorithm:Ljava/lang/String;
  114. invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  115. move-result v0
  116. if-eqz v0, :cond_0
  117. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->hash:Lokio/ByteString;
  118. iget-object p1, p1, Lokhttp3/CertificatePinner$Pin;->hash:Lokio/ByteString;
  119. invoke-virtual {v0, p1}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
  120. move-result p1
  121. if-eqz p1, :cond_0
  122. const/4 p1, 0x1
  123. goto :goto_0
  124. :cond_0
  125. const/4 p1, 0x0
  126. :goto_0
  127. return p1
  128. .end method
  129. .method public hashCode()I
  130. .locals 2
  131. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->pattern:Ljava/lang/String;
  132. invoke-virtual {v0}, Ljava/lang/String;->hashCode()I
  133. move-result v0
  134. const/16 v1, 0x20f
  135. add-int/2addr v1, v0
  136. mul-int/lit8 v1, v1, 0x1f
  137. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->hashAlgorithm:Ljava/lang/String;
  138. invoke-virtual {v0}, Ljava/lang/String;->hashCode()I
  139. move-result v0
  140. add-int/2addr v1, v0
  141. mul-int/lit8 v1, v1, 0x1f
  142. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->hash:Lokio/ByteString;
  143. invoke-virtual {v0}, Lokio/ByteString;->hashCode()I
  144. move-result v0
  145. add-int/2addr v1, v0
  146. return v1
  147. .end method
  148. .method matches(Ljava/lang/String;)Z
  149. .locals 10
  150. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->pattern:Ljava/lang/String;
  151. const-string v1, "*."
  152. invoke-virtual {v0, v1}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  153. move-result v0
  154. if-eqz v0, :cond_1
  155. const/16 v0, 0x2e
  156. invoke-virtual {p1, v0}, Ljava/lang/String;->indexOf(I)I
  157. move-result v0
  158. invoke-virtual {p1}, Ljava/lang/String;->length()I
  159. move-result v1
  160. sub-int/2addr v1, v0
  161. const/4 v2, 0x1
  162. sub-int/2addr v1, v2
  163. iget-object v3, p0, Lokhttp3/CertificatePinner$Pin;->canonicalHostname:Ljava/lang/String;
  164. invoke-virtual {v3}, Ljava/lang/String;->length()I
  165. move-result v3
  166. if-ne v1, v3, :cond_0
  167. const/4 v5, 0x0
  168. add-int/lit8 v6, v0, 0x1
  169. iget-object v7, p0, Lokhttp3/CertificatePinner$Pin;->canonicalHostname:Ljava/lang/String;
  170. const/4 v8, 0x0
  171. invoke-virtual {v7}, Ljava/lang/String;->length()I
  172. move-result v9
  173. move-object v4, p1
  174. invoke-virtual/range {v4 .. v9}, Ljava/lang/String;->regionMatches(ZILjava/lang/String;II)Z
  175. move-result p1
  176. if-eqz p1, :cond_0
  177. goto :goto_0
  178. :cond_0
  179. const/4 v2, 0x0
  180. :goto_0
  181. return v2
  182. :cond_1
  183. iget-object v0, p0, Lokhttp3/CertificatePinner$Pin;->canonicalHostname:Ljava/lang/String;
  184. invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  185. move-result p1
  186. return p1
  187. .end method
  188. .method public toString()Ljava/lang/String;
  189. .locals 2
  190. new-instance v0, Ljava/lang/StringBuilder;
  191. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  192. iget-object v1, p0, Lokhttp3/CertificatePinner$Pin;->hashAlgorithm:Ljava/lang/String;
  193. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  194. iget-object v1, p0, Lokhttp3/CertificatePinner$Pin;->hash:Lokio/ByteString;
  195. invoke-virtual {v1}, Lokio/ByteString;->base64()Ljava/lang/String;
  196. move-result-object v1
  197. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  198. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  199. move-result-object v0
  200. return-object v0
  201. .end method