3232import com .squareup .okhttp .logging .HttpLoggingInterceptor .Level ;
3333import java .io .File ;
3434import java .io .IOException ;
35- import java .io .InputStream ;
3635import java .io .UnsupportedEncodingException ;
3736import java .lang .reflect .Type ;
3837import java .net .URLConnection ;
3938import java .net .URLEncoder ;
40- import java .security .GeneralSecurityException ;
41- import java .security .KeyStore ;
42- import java .security .SecureRandom ;
43- import java .security .cert .Certificate ;
44- import java .security .cert .CertificateFactory ;
45- import java .security .cert .X509Certificate ;
4639import java .text .DateFormat ;
4740import java .util .*;
4841import java .util .Map .Entry ;
4942import java .util .concurrent .TimeUnit ;
5043import java .util .regex .Matcher ;
5144import java .util .regex .Pattern ;
52- import javax .net .ssl .*;
5345import okio .BufferedSink ;
5446import okio .Okio ;
5547import org .threeten .bp .LocalDate ;
5850public class ApiClient {
5951
6052 public final String apiVersion = "v3.0" ;
61- public final String clientVersion = "22.7 .0" ;
53+ public final String clientVersion = "22.8 .0" ;
6254 private String baseUrl = "https://api.aspose.cloud" ;
6355 private String clientId ;
6456 private String clientSecret ;
@@ -71,10 +63,6 @@ public class ApiClient {
7163 private boolean lenientDatetimeFormat ;
7264 private int dateLength ;
7365
74- private InputStream sslCaCert ;
75- private boolean verifyingSsl ;
76- private KeyManager [] keyManagers ;
77-
7866 private OkHttpClient httpClient ;
7967 private JSON json ;
8068
@@ -105,12 +93,10 @@ public ApiClient(String accessToken) {
10593 protected ApiClient () {
10694 httpClient = new OkHttpClient ();
10795
108- verifyingSsl = true ;
109-
11096 json = new JSON ();
11197
11298 // Set default User-Agent.
113- setUserAgent ("Swagger-Codegen/22.7 .0/java" );
99+ setUserAgent ("Swagger-Codegen/22.8 .0/java" );
114100
115101 addDefaultHeader ("x-aspose-client" , "java sdk" );
116102 addDefaultHeader ("x-aspose-client-version" , clientVersion );
@@ -166,68 +152,6 @@ public ApiClient setJSON(JSON json) {
166152 return this ;
167153 }
168154
169- /**
170- * True if isVerifyingSsl flag is on
171- *
172- * @return True if isVerifySsl flag is on
173- */
174- public boolean isVerifyingSsl () {
175- return verifyingSsl ;
176- }
177-
178- /**
179- * Configure whether to verify certificate and hostname when making https requests. Default to
180- * true. NOTE: Do NOT set to false in production code, otherwise you would face multiple types
181- * of cryptographic attacks.
182- *
183- * @param verifyingSsl True to verify TLS/SSL connection
184- * @return ApiClient
185- */
186- public ApiClient setVerifyingSsl (boolean verifyingSsl ) {
187- this .verifyingSsl = verifyingSsl ;
188- applySslSettings ();
189- return this ;
190- }
191-
192- /**
193- * Get SSL CA cert.
194- *
195- * @return Input stream to the SSL CA cert
196- */
197- public InputStream getSslCaCert () {
198- return sslCaCert ;
199- }
200-
201- /**
202- * Configure the CA certificate to be trusted when making https requests. Use null to reset to
203- * default.
204- *
205- * @param sslCaCert input stream for SSL CA cert
206- * @return ApiClient
207- */
208- public ApiClient setSslCaCert (InputStream sslCaCert ) {
209- this .sslCaCert = sslCaCert ;
210- applySslSettings ();
211- return this ;
212- }
213-
214- public KeyManager [] getKeyManagers () {
215- return keyManagers ;
216- }
217-
218- /**
219- * Configure client keys to use for authorization in an SSL session. Use null to reset to
220- * default.
221- *
222- * @param managers The KeyManagers to use
223- * @return ApiClient
224- */
225- public ApiClient setKeyManagers (KeyManager [] managers ) {
226- this .keyManagers = managers ;
227- applySslSettings ();
228- return this ;
229- }
230-
231155 public DateFormat getDateFormat () {
232156 return dateFormat ;
233157 }
@@ -1066,83 +990,6 @@ public String guessContentTypeFromFile(File file) {
1066990 }
1067991 }
1068992
1069- /**
1070- * Apply SSL related settings to httpClient according to the current values of verifyingSsl and
1071- * sslCaCert.
1072- */
1073- private void applySslSettings () {
1074- try {
1075- TrustManager [] trustManagers = null ;
1076- HostnameVerifier hostnameVerifier = null ;
1077- if (!verifyingSsl ) {
1078- TrustManager trustAll =
1079- new X509TrustManager () {
1080- @ Override
1081- public void checkClientTrusted (
1082- X509Certificate [] chain , String authType ) {}
1083-
1084- @ Override
1085- public void checkServerTrusted (
1086- X509Certificate [] chain , String authType ) {}
1087-
1088- @ Override
1089- public X509Certificate [] getAcceptedIssuers () {
1090- return null ;
1091- }
1092- };
1093- SSLContext sslContext = SSLContext .getInstance ("TLS" );
1094- trustManagers = new TrustManager [] {trustAll };
1095- hostnameVerifier =
1096- new HostnameVerifier () {
1097- @ Override
1098- public boolean verify (String hostname , SSLSession session ) {
1099- return true ;
1100- }
1101- };
1102- } else if (sslCaCert != null ) {
1103- char [] password = null ; // Any password will work.
1104- CertificateFactory certificateFactory = CertificateFactory .getInstance ("X.509" );
1105- Collection <? extends Certificate > certificates =
1106- certificateFactory .generateCertificates (sslCaCert );
1107- if (certificates .isEmpty ()) {
1108- throw new IllegalArgumentException (
1109- "expected non-empty set of trusted certificates" );
1110- }
1111- KeyStore caKeyStore = newEmptyKeyStore (password );
1112- int index = 0 ;
1113- for (Certificate certificate : certificates ) {
1114- String certificateAlias = "ca" + index ++;
1115- caKeyStore .setCertificateEntry (certificateAlias , certificate );
1116- }
1117- TrustManagerFactory trustManagerFactory =
1118- TrustManagerFactory .getInstance (TrustManagerFactory .getDefaultAlgorithm ());
1119- trustManagerFactory .init (caKeyStore );
1120- trustManagers = trustManagerFactory .getTrustManagers ();
1121- }
1122-
1123- if (keyManagers != null || trustManagers != null ) {
1124- SSLContext sslContext = SSLContext .getInstance ("TLS" );
1125- sslContext .init (keyManagers , trustManagers , new SecureRandom ());
1126- httpClient .setSslSocketFactory (sslContext .getSocketFactory ());
1127- } else {
1128- httpClient .setSslSocketFactory (null );
1129- }
1130- httpClient .setHostnameVerifier (hostnameVerifier );
1131- } catch (GeneralSecurityException e ) {
1132- throw new RuntimeException (e );
1133- }
1134- }
1135-
1136- private KeyStore newEmptyKeyStore (char [] password ) throws GeneralSecurityException {
1137- try {
1138- KeyStore keyStore = KeyStore .getInstance (KeyStore .getDefaultType ());
1139- keyStore .load (null , password );
1140- return keyStore ;
1141- } catch (IOException e ) {
1142- throw new AssertionError (e );
1143- }
1144- }
1145-
1146993 /**
1147994 * Request OAuth token
1148995 *
0 commit comments