@@ -25,6 +25,21 @@ import java.security.KeyStore;
2525import java.security.SecureRandom;
2626import java.security.cert.Certificate;
2727import java.security.cert.CertificateException;
28+ import java.security.cert.CertificateFactory;
29+ import java.security.cert.X509Certificate;
30+ import java.text.DateFormat;
31+ import java.text.ParseException;
32+ import java.text.SimpleDateFormat;
33+ import java.util.ArrayList;
34+ import java.util.Collection;
35+ import java.util.Collections;
36+ import java.util.Date;
37+ import java.util.HashMap;
38+ import java.util.List;
39+ import java.util.Map;
40+ import java.util.Map.Entry;
41+ import java.util.Properties;
42+ import java.util.TimeZone;
2843import java.util.concurrent.TimeUnit;
2944import java.util.regex.Matcher;
3045import java.util.regex.Pattern;
@@ -127,6 +142,7 @@ public class ApiClient {
127142
128143 private OkHttpClient httpClient;
129144 private JSON json;
145+ private String versionInfo;
130146
131147 private HttpLoggingInterceptor loggingInterceptor;
132148
@@ -136,6 +152,8 @@ public class ApiClient {
136152 public ApiClient() {
137153 httpClient = new OkHttpClient();
138154
155+ versionInfo = getClientID();
156+
139157 httpClient = new OkHttpClient.Builder()
140158 .connectTimeout(1, TimeUnit.SECONDS)
141159 .writeTimeout(60, TimeUnit.SECONDS)
@@ -170,6 +188,19 @@ public class ApiClient {
170188 authentications = Collections.unmodifiableMap(authentications);
171189 }
172190
191+ private String getClientID() {
192+ String propertyVersionInfo = null;
193+ final Properties properties = new Properties();
194+ try {
195+ properties.load(this.getClass().getClassLoader().getResourceAsStream(" cybersource-rest-client-java.properties" ));
196+ propertyVersionInfo = properties.getProperty(" sdk.version" );
197+ } catch (IOException e) {
198+
199+ }
200+
201+ return propertyVersionInfo;
202+ }
203+
173204 public ApiClient(MerchantConfig merchantConfig) {
174205 this();
175206 final boolean useProxy = merchantConfig.isUseProxyEnabled();
@@ -921,7 +952,7 @@ public class ApiClient {
921952 if ((returnType == null && response != null) || ("byte[]".equals(returnType.toString()))) {
922953 try {
923954 T respBody = (T) response.body().byteStream();
924-
955+
925956 return respBody;
926957 } catch (IOException e) {
927958 throw new ApiException(e);
@@ -1173,7 +1204,7 @@ public class ApiClient {
11731204 if (response.isSuccessful()) {
11741205 if (response.code() == 204) {
11751206 if (response.body() != null) {
1176- response.body().close();
1207+ response.body().close();
11771208 }
11781209 return null;
11791210 } else {
@@ -1294,6 +1325,14 @@ public class ApiClient {
12941325 token = " Bearer " + token;
12951326 addDefaultHeader(" Authorization" , token);
12961327 }
1328+
1329+ if (merchantConfig.getSolutionId() != null && !merchantConfig.getSolutionId().isEmpty()) {
1330+ addDefaultHeader(" v-c-solution-id" , merchantConfig.getSolutionId());
1331+ }
1332+ }
1333+
1334+ if (versionInfo != null && !versionInfo.isEmpty()) {
1335+ addDefaultHeader(" v-c-client-id" , " cybs-rest-sdk-java-" + versionInfo);
12971336 }
12981337
12991338 } catch (ConfigException e) {
0 commit comments