Skip to content

Commit a7818a3

Browse files
Release 22.8 (#44)
* Release 22.8 * Updated format jar for tests added * Fix security issue "`TrustManager` that accepts all certificates" Co-authored-by: Denis Averin <59285247+Denis-Averin@users.noreply.github.com> Co-authored-by: ivankamkin <109517020+ivankamkin@users.noreply.github.com>
1 parent 08e5d4e commit a7818a3

5 files changed

Lines changed: 7 additions & 160 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepository.aspose.cloud%2Frepo%2Fcom%2Faspose%2Faspose-barcode-cloud%2Fmaven-metadata.xml)](https://repository.aspose.cloud/repo/com/aspose/aspose-barcode-cloud/)
66

77
- API version: 3.0
8-
- SDK version: 22.7.0
8+
- SDK version: 22.8.0
99

1010
## Demo applications
1111

@@ -68,7 +68,7 @@ Add this dependency to your project's POM:
6868
<dependency>
6969
<groupId>com.aspose</groupId>
7070
<artifactId>aspose-barcode-cloud</artifactId>
71-
<version>22.7.0</version>
71+
<version>22.8.0</version>
7272
<scope>compile</scope>
7373
</dependency>
7474
```
@@ -83,7 +83,7 @@ mvn clean package
8383

8484
Then manually install the following JARs:
8585

86-
- `target/aspose-barcode-cloud-22.7.0.jar`
86+
- `target/aspose-barcode-cloud-22.8.0.jar`
8787
- `target/lib/*.jar`
8888

8989
## Getting Started

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>aspose-barcode-cloud</artifactId>
66
<packaging>jar</packaging>
77
<name>aspose-barcode-cloud</name>
8-
<version>22.7.0</version>
8+
<version>22.8.0</version>
99
<url>https://www.aspose.cloud</url>
1010
<description>Aspose.BarCode Cloud SDK for Java</description>
1111
<scm>

scripts/fix-region-point.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
#
66
set -euo pipefail
77

8-
find ./src -type f -iname 'RegionPoint.java' -exec sed -i '' -e 's_@SerializedName(value = "\(X\|Y\)"_@SerializedName(value = "\l\1"_g' '{}' \;
8+
find ./src -type f -iname 'RegionPoint.java' -exec sed -e 's_@SerializedName(value = "\(X\|Y\)"_@SerializedName(value = "\l\1"_g' -i '{}' \;

src/main/java/com/aspose/barcode/cloud/ApiClient.java

Lines changed: 2 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,16 @@
3232
import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level;
3333
import java.io.File;
3434
import java.io.IOException;
35-
import java.io.InputStream;
3635
import java.io.UnsupportedEncodingException;
3736
import java.lang.reflect.Type;
3837
import java.net.URLConnection;
3938
import 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;
4639
import java.text.DateFormat;
4740
import java.util.*;
4841
import java.util.Map.Entry;
4942
import java.util.concurrent.TimeUnit;
5043
import java.util.regex.Matcher;
5144
import java.util.regex.Pattern;
52-
import javax.net.ssl.*;
5345
import okio.BufferedSink;
5446
import okio.Okio;
5547
import org.threeten.bp.LocalDate;
@@ -58,7 +50,7 @@
5850
public 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
*
3.25 MB
Binary file not shown.

0 commit comments

Comments
 (0)