|
41 | 41 | import java.util.regex.Matcher; |
42 | 42 | import java.util.regex.Pattern; |
43 | 43 | import javax.net.ssl.*; |
| 44 | +import com.cybersource.authsdk.util.Utility; |
44 | 45 | import com.google.gson.Gson; |
| 46 | +import com.google.gson.reflect.TypeToken; |
45 | 47 | import org.apache.logging.log4j.Logger; |
46 | 48 | import com.cybersource.authsdk.core.Authorization; |
47 | 49 | import com.cybersource.authsdk.core.ConfigException; |
@@ -1164,6 +1166,10 @@ public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiExceptio |
1164 | 1166 | responseCode = String.valueOf(response.code()); |
1165 | 1167 | status = response.message(); |
1166 | 1168 |
|
| 1169 | + if(returnType == new TypeToken< Model.AccessTokenResponse >(){}.getType()) { |
| 1170 | + Logger logger = Log4j.getInstance(merchantConfig); |
| 1171 | + Utility.log(logger, response.peekBody(Long.MAX_VALUE).string(), org.apache.logging.log4j.Level.DEBUG); |
| 1172 | + } |
1167 | 1173 | T data = handleResponse(response, returnType); |
1168 | 1174 |
|
1169 | 1175 | return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data); |
@@ -1355,33 +1361,33 @@ public void callAuthenticationHeader(String method, String path, Object body, Li |
1355 | 1361 |
|
1356 | 1362 | merchantConfig.setRequestHost(merchantConfig.getRequestHost().trim()); |
1357 | 1363 |
|
1358 | | - if (isMerchantDetails && !merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.NOAUTH)) { |
1359 | | - String token = authorization.getToken(merchantConfig); |
1360 | | - if (merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.HTTP)) { |
1361 | 1364 |
|
1362 | | - addDefaultHeader("Date", PropertiesUtil.date); |
1363 | | - addDefaultHeader("Host", merchantConfig.getRequestHost().trim()); |
1364 | | - addDefaultHeader("v-c-merchant-id", merchantConfig.getMerchantID()); |
1365 | | - addDefaultHeader("Signature", token); |
1366 | | - addDefaultHeader("User-Agent", "Mozilla/5.0"); |
1367 | | - |
1368 | | - if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT") |
1369 | | - || method.equalsIgnoreCase("PATCH")) { |
1370 | | - PayloadDigest payloadDigest = new PayloadDigest(merchantConfig); |
1371 | | - String digest = payloadDigest.getDigest(); |
1372 | | - addDefaultHeader("Digest", digest); |
1373 | | - } |
| 1365 | + if (isMerchantDetails && !merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.MUTUALAUTH)) { |
| 1366 | + String token = authorization.getToken(merchantConfig); |
| 1367 | + if (merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.HTTP)) { |
1374 | 1368 |
|
1375 | | - } else if (merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.JWT)) { |
1376 | | - token = "Bearer " + token; |
1377 | | - addDefaultHeader("Authorization", token); |
1378 | | - } |
1379 | | - else if(merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.OAUTH)) |
1380 | | - { |
1381 | | - token = "Bearer " + token; |
1382 | | - addDefaultHeader("Authorization", token); |
| 1369 | + addDefaultHeader("Date", PropertiesUtil.date); |
| 1370 | + addDefaultHeader("Host", merchantConfig.getRequestHost().trim()); |
| 1371 | + addDefaultHeader("v-c-merchant-id", merchantConfig.getMerchantID()); |
| 1372 | + addDefaultHeader("Signature", token); |
| 1373 | + addDefaultHeader("User-Agent", "Mozilla/5.0"); |
| 1374 | + |
| 1375 | + if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT") |
| 1376 | + || method.equalsIgnoreCase("PATCH")) { |
| 1377 | + PayloadDigest payloadDigest = new PayloadDigest(merchantConfig); |
| 1378 | + String digest = payloadDigest.getDigest(); |
| 1379 | + addDefaultHeader("Digest", digest); |
| 1380 | + } |
| 1381 | + |
| 1382 | + } else if (merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.JWT)) { |
| 1383 | + token = "Bearer " + token; |
| 1384 | + addDefaultHeader("Authorization", token); |
| 1385 | + } |
| 1386 | + else if (merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.OAUTH)) { |
| 1387 | + token = "Bearer " + token; |
| 1388 | + addDefaultHeader("Authorization", token); |
| 1389 | + } |
1383 | 1390 | } |
1384 | | - } |
1385 | 1391 |
|
1386 | 1392 | if (versionInfo != null && !versionInfo.isEmpty()) { |
1387 | 1393 | addDefaultHeader("v-c-client-id", "cybs-rest-sdk-java-" + versionInfo); |
|
0 commit comments