Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
482 changes: 408 additions & 74 deletions MLE.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ import com.cybersource.authsdk.payloaddigest.PayloadDigest;
import com.cybersource.authsdk.util.GlobalLabelParameters;
import com.cybersource.authsdk.util.PrettyPrintingMap;
import com.cybersource.authsdk.util.PropertiesUtil;
import com.cybersource.authsdk.util.mle.MLEException;
import com.cybersource.authsdk.util.mle.MLEUtility;

import Invokers.auth.ApiKeyAuth;
import Invokers.auth.Authentication;
Expand Down Expand Up @@ -1065,6 +1067,18 @@ public class ApiClient {
// ensuring a default content type
contentType = "application/json";
}

// Check the response body first if it is mle encrypted then do deserialize
if(MLEUtility.checkIsMleEncryptedResponse(respBody)) {
try {
respBody = MLEUtility.decryptMleResponsePayload(this.merchantConfig, respBody);
} catch (MLEException e) {
logger.error("MLE Encrypted Response Decryption Error Occurred. Error: " + e.getMessage());
throw new ApiException("MLE Encrypted Response Decryption Error Occurred. Error: " + e.getMessage(),
response.code(), response.headers().toMultimap(), respBody);
}
}

if (isJsonMime(contentType)) {
return json.deserialize(respBody, returnType);
} else if (returnType.equals(String.class)) {
Expand Down Expand Up @@ -1327,7 +1341,7 @@ public class ApiClient {
*/
public Call buildCall(String path, String method, List<Pair> queryParams, Object body,
Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames,
ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
ProgressRequestBody.ProgressRequestListener progressRequestListener, boolean isResponseMLEforApi) throws ApiException {

//create reqHeader parameter here
Map<String, String> requestHeaderMap = new HashMap<String, String>();
Expand All @@ -1347,7 +1361,7 @@ public class ApiClient {
}
RequestBody requestbody = createRequestBody(method, body, formParams, contentType);

callAuthenticationHeader(method, path, requestbody, queryParams, requestHeaderMap);
callAuthenticationHeader(method, path, requestbody, queryParams, requestHeaderMap, isResponseMLEforApi);

if (merchantConfig.isEnableClientCert()) {
addClientCertToKeyStore();
Expand Down Expand Up @@ -1384,7 +1398,7 @@ public class ApiClient {
*
*/

public void callAuthenticationHeader(String method, String path, RequestBody reqBody, List<Pair> queryParams, Map<String, String> requestHeaderMap) {
public void callAuthenticationHeader(String method, String path, RequestBody reqBody, List<Pair> queryParams, Map<String, String> requestHeaderMap, boolean isResponseMLEforApi) {

try {
String requestTarget = null;
Expand Down Expand Up @@ -1424,7 +1438,7 @@ public class ApiClient {
if (isMerchantDetails
&& !merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.MUTUALAUTH)) {
String date = PropertiesUtil.getNewDate();
String token = authorization.getToken(merchantConfig, method, requestBody, requestTarget, date);
String token = authorization.getToken(merchantConfig, method, requestBody, requestTarget, date, isResponseMLEforApi);
if (merchantConfig.getAuthenticationType().equalsIgnoreCase(GlobalLabelParameters.HTTP)) {

requestHeaderMap.put("Date", date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public class {{classname}} {
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "{{operationId}},{{operationId}}Async,{{operationId}}WithHttpInfo,{{operationId}}Call");

// create path and map variables
String {{localVariablePrefix}}localVarPath = "{{{path}}}"{{#pathParams}}
Expand Down Expand Up @@ -141,7 +143,7 @@ public class {{classname}} {
}

String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAuthNames, progressRequestListener);
return {{localVariablePrefix}}apiClient.buildCall({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/Api/BatchesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public okhttp3.Call getBatchReportCall(String batchId, final ProgressResponseBod
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getBatchReport,getBatchReportAsync,getBatchReportWithHttpInfo,getBatchReportCall");

// create path and map variables
String localVarPath = "/accountupdater/v1/batches/{batchId}/report"
Expand Down Expand Up @@ -129,7 +131,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -239,6 +241,8 @@ public okhttp3.Call getBatchStatusCall(String batchId, final ProgressResponseBod
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getBatchStatus,getBatchStatusAsync,getBatchStatusWithHttpInfo,getBatchStatusCall");

// create path and map variables
String localVarPath = "/accountupdater/v1/batches/{batchId}/status"
Expand Down Expand Up @@ -275,7 +279,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -388,6 +392,8 @@ public okhttp3.Call getBatchesListCall(Long offset, Long limit, String fromDate,
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getBatchesList,getBatchesListAsync,getBatchesListWithHttpInfo,getBatchesListCall");

// create path and map variables
String localVarPath = "/accountupdater/v1/batches";
Expand Down Expand Up @@ -431,7 +437,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -541,6 +547,8 @@ public okhttp3.Call postBatchCall(Body body, final ProgressResponseBody.Progress
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "postBatch,postBatchAsync,postBatchWithHttpInfo,postBatchCall");

// create path and map variables
String localVarPath = "/accountupdater/v1/batches";
Expand Down Expand Up @@ -576,7 +584,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/Api/BillingAgreementsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public okhttp3.Call billingAgreementsDeRegistrationCall(ModifyBillingAgreement m
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "billingAgreementsDeRegistration,billingAgreementsDeRegistrationAsync,billingAgreementsDeRegistrationWithHttpInfo,billingAgreementsDeRegistrationCall");

// create path and map variables
String localVarPath = "/pts/v2/billing-agreements/{id}"
Expand Down Expand Up @@ -129,7 +131,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "PATCH", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -246,6 +248,8 @@ public okhttp3.Call billingAgreementsIntimationCall(IntimateBillingAgreement int
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "billingAgreementsIntimation,billingAgreementsIntimationAsync,billingAgreementsIntimationWithHttpInfo,billingAgreementsIntimationCall");

// create path and map variables
String localVarPath = "/pts/v2/billing-agreements/{id}/intimations"
Expand Down Expand Up @@ -282,7 +286,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -398,6 +402,8 @@ public okhttp3.Call billingAgreementsRegistrationCall(CreateBillingAgreement cre
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "billingAgreementsRegistration,billingAgreementsRegistrationAsync,billingAgreementsRegistrationWithHttpInfo,billingAgreementsRegistrationCall");

// create path and map variables
String localVarPath = "/pts/v2/billing-agreements";
Expand Down Expand Up @@ -433,7 +439,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Api/BinLookupApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public okhttp3.Call getAccountInfoCall(CreateBinLookupRequest createBinLookupReq
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getAccountInfo,getAccountInfoAsync,getAccountInfoWithHttpInfo,getAccountInfoCall");

// create path and map variables
String localVarPath = "/bin/v1/binlookup";
Expand Down Expand Up @@ -123,7 +125,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Api/CaptureApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public okhttp3.Call capturePaymentCall(CapturePaymentRequest capturePaymentReque
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "capturePayment,capturePaymentAsync,capturePaymentWithHttpInfo,capturePaymentCall");

// create path and map variables
String localVarPath = "/pts/v2/payments/{id}/captures"
Expand Down Expand Up @@ -125,7 +127,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Api/ChargebackDetailsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public okhttp3.Call getChargebackDetailsCall(DateTime startTime, DateTime endTim
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getChargebackDetails,getChargebackDetailsAsync,getChargebackDetailsWithHttpInfo,getChargebackDetailsCall");

// create path and map variables
String localVarPath = "/reporting/v3/chargeback-details";
Expand Down Expand Up @@ -132,7 +134,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Api/ChargebackSummariesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public okhttp3.Call getChargebackSummariesCall(DateTime startTime, DateTime endT
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getChargebackSummaries,getChargebackSummariesAsync,getChargebackSummariesWithHttpInfo,getChargebackSummariesCall");

// create path and map variables
String localVarPath = "/reporting/v3/chargeback-summaries";
Expand Down Expand Up @@ -132,7 +134,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/Api/ConversionDetailsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public okhttp3.Call getConversionDetailCall(DateTime startTime, DateTime endTime
throw new ApiException("Failed to encrypt request body : " + e.getMessage());
}
}

boolean isResponseMLEForApi = MLEUtility.checkIsResponseMLEForAPI(apiClient.merchantConfig, "getConversionDetail,getConversionDetailAsync,getConversionDetailWithHttpInfo,getConversionDetailCall");

// create path and map variables
String localVarPath = "/reporting/v3/conversion-details";
Expand Down Expand Up @@ -133,7 +135,7 @@ public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOExce
}

String[] localVarAuthNames = new String[] { };
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener, isResponseMLEForApi);
}

@SuppressWarnings("rawtypes")
Expand Down
Loading