Jdk9Platform.smali 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .class final Lokhttp3/internal/platform/Jdk9Platform;
  2. .super Lokhttp3/internal/platform/Platform;
  3. .source ""
  4. # instance fields
  5. .field final getProtocolMethod:Ljava/lang/reflect/Method;
  6. .field final setProtocolMethod:Ljava/lang/reflect/Method;
  7. # direct methods
  8. .method constructor <init>(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)V
  9. .locals 0
  10. invoke-direct {p0}, Lokhttp3/internal/platform/Platform;-><init>()V
  11. iput-object p1, p0, Lokhttp3/internal/platform/Jdk9Platform;->setProtocolMethod:Ljava/lang/reflect/Method;
  12. iput-object p2, p0, Lokhttp3/internal/platform/Jdk9Platform;->getProtocolMethod:Ljava/lang/reflect/Method;
  13. return-void
  14. .end method
  15. .method public static buildIfSupported()Lokhttp3/internal/platform/Jdk9Platform;
  16. .locals 5
  17. :try_start_0
  18. const-class v0, Ljavax/net/ssl/SSLParameters;
  19. const-string v1, "setApplicationProtocols"
  20. const/4 v2, 0x1
  21. new-array v2, v2, [Ljava/lang/Class;
  22. const-class v3, [Ljava/lang/String;
  23. const/4 v4, 0x0
  24. aput-object v3, v2, v4
  25. invoke-virtual {v0, v1, v2}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
  26. move-result-object v0
  27. const-class v1, Ljavax/net/ssl/SSLSocket;
  28. const-string v2, "getApplicationProtocol"
  29. new-array v3, v4, [Ljava/lang/Class;
  30. invoke-virtual {v1, v2, v3}, Ljava/lang/Class;->getMethod(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
  31. move-result-object v1
  32. new-instance v2, Lokhttp3/internal/platform/Jdk9Platform;
  33. invoke-direct {v2, v0, v1}, Lokhttp3/internal/platform/Jdk9Platform;-><init>(Ljava/lang/reflect/Method;Ljava/lang/reflect/Method;)V
  34. :try_end_0
  35. .catch Ljava/lang/NoSuchMethodException; {:try_start_0 .. :try_end_0} :catch_0
  36. return-object v2
  37. :catch_0
  38. const/4 v0, 0x0
  39. return-object v0
  40. .end method
  41. # virtual methods
  42. .method public configureTlsExtensions(Ljavax/net/ssl/SSLSocket;Ljava/lang/String;Ljava/util/List;)V
  43. .locals 4
  44. .annotation system Ldalvik/annotation/Signature;
  45. value = {
  46. "(",
  47. "Ljavax/net/ssl/SSLSocket;",
  48. "Ljava/lang/String;",
  49. "Ljava/util/List<",
  50. "Lokhttp3/Protocol;",
  51. ">;)V"
  52. }
  53. .end annotation
  54. :try_start_0
  55. invoke-virtual {p1}, Ljavax/net/ssl/SSLSocket;->getSSLParameters()Ljavax/net/ssl/SSLParameters;
  56. move-result-object p2
  57. invoke-static {p3}, Lokhttp3/internal/platform/Platform;->alpnProtocolNames(Ljava/util/List;)Ljava/util/List;
  58. move-result-object p3
  59. iget-object v0, p0, Lokhttp3/internal/platform/Jdk9Platform;->setProtocolMethod:Ljava/lang/reflect/Method;
  60. const/4 v1, 0x1
  61. new-array v1, v1, [Ljava/lang/Object;
  62. const/4 v2, 0x0
  63. invoke-interface {p3}, Ljava/util/List;->size()I
  64. move-result v3
  65. new-array v3, v3, [Ljava/lang/String;
  66. invoke-interface {p3, v3}, Ljava/util/List;->toArray([Ljava/lang/Object;)[Ljava/lang/Object;
  67. move-result-object p3
  68. aput-object p3, v1, v2
  69. invoke-virtual {v0, p2, v1}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  70. invoke-virtual {p1, p2}, Ljavax/net/ssl/SSLSocket;->setSSLParameters(Ljavax/net/ssl/SSLParameters;)V
  71. :try_end_0
  72. .catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_1
  73. .catch Ljava/lang/reflect/InvocationTargetException; {:try_start_0 .. :try_end_0} :catch_0
  74. return-void
  75. :catch_0
  76. move-exception p1
  77. goto :goto_0
  78. :catch_1
  79. move-exception p1
  80. :goto_0
  81. const-string p2, "unable to set ssl parameters"
  82. invoke-static {p2, p1}, Lokhttp3/internal/Util;->assertionError(Ljava/lang/String;Ljava/lang/Exception;)Ljava/lang/AssertionError;
  83. move-result-object p1
  84. throw p1
  85. .end method
  86. .method public getSelectedProtocol(Ljavax/net/ssl/SSLSocket;)Ljava/lang/String;
  87. .locals 2
  88. :try_start_0
  89. iget-object v0, p0, Lokhttp3/internal/platform/Jdk9Platform;->getProtocolMethod:Ljava/lang/reflect/Method;
  90. const/4 v1, 0x0
  91. new-array v1, v1, [Ljava/lang/Object;
  92. invoke-virtual {v0, p1, v1}, Ljava/lang/reflect/Method;->invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
  93. move-result-object p1
  94. check-cast p1, Ljava/lang/String;
  95. if-eqz p1, :cond_1
  96. const-string v0, ""
  97. invoke-virtual {p1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  98. move-result v0
  99. :try_end_0
  100. .catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_1
  101. .catch Ljava/lang/reflect/InvocationTargetException; {:try_start_0 .. :try_end_0} :catch_0
  102. if-eqz v0, :cond_0
  103. goto :goto_0
  104. :cond_0
  105. return-object p1
  106. :cond_1
  107. :goto_0
  108. const/4 p1, 0x0
  109. return-object p1
  110. :catch_0
  111. move-exception p1
  112. goto :goto_1
  113. :catch_1
  114. move-exception p1
  115. :goto_1
  116. const-string v0, "unable to get selected protocols"
  117. invoke-static {v0, p1}, Lokhttp3/internal/Util;->assertionError(Ljava/lang/String;Ljava/lang/Exception;)Ljava/lang/AssertionError;
  118. move-result-object p1
  119. throw p1
  120. .end method
  121. .method public trustManager(Ljavax/net/ssl/SSLSocketFactory;)Ljavax/net/ssl/X509TrustManager;
  122. .locals 1
  123. new-instance p1, Ljava/lang/UnsupportedOperationException;
  124. const-string v0, "clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+"
  125. invoke-direct {p1, v0}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V
  126. throw p1
  127. .end method