de.adorsys.opba.api.security.requestsigner.GetAccounts Maven / Gradle / Ivy
package de.adorsys.opba.api.security.requestsigner;
import de.adorsys.opba.api.security.generator.api.RequestDataToSignNormalizer;
import de.adorsys.opba.api.security.generator.api.RequestToSign;
import java.lang.Override;
import java.lang.String;
import javax.annotation.Generated;
@Generated(
value = "de.adorsys.opba.api.security.generator.normalizer.DataToSignProviderGenerator",
comments = "This class provides request signature canonicalization functionality for a concrete request (convert Request to String to sign)"
)
public class GetAccounts implements RequestDataToSignNormalizer {
/**
* @param toSign Request data to sign
*/
@Override
public String canonicalString(RequestToSign toSign) {
StringBuilder result = new StringBuilder();
// Add path;
if (null == toSign.getPath() || "".equals(toSign.getPath())) {
throw new IllegalStateException("Missing path");
}
result.append(toSign.getPath()).append("&");
// Done adding path;
// Add headers;
// Optional header Bank-Profile-ID;
String Bank_Profile_ID = toSign.getHeaders().get("bank-profile-id");
if (null != Bank_Profile_ID && !"".equals(Bank_Profile_ID)) {
result.append("Bank-Profile-ID").append("=").append(Bank_Profile_ID).append("&");
}
// Optional header Compute-PSU-IP-Address;
String Compute_PSU_IP_Address = toSign.getHeaders().get("compute-psu-ip-address");
if (null != Compute_PSU_IP_Address && !"".equals(Compute_PSU_IP_Address)) {
result.append("Compute-PSU-IP-Address").append("=").append(Compute_PSU_IP_Address).append("&");
}
// Optional header Fintech-ID;
String Fintech_ID = toSign.getHeaders().get("fintech-id");
if (null != Fintech_ID && !"".equals(Fintech_ID)) {
result.append("Fintech-ID").append("=").append(Fintech_ID).append("&");
}
// Mandatory header Fintech-Redirect-URL-NOK;
String Fintech_Redirect_URL_NOK = toSign.getHeaders().get("fintech-redirect-url-nok");
if (null == Fintech_Redirect_URL_NOK || "".equals(Fintech_Redirect_URL_NOK)) {
throw new IllegalStateException("Missing Fintech-Redirect-URL-NOK mandatory header");
}
result.append("Fintech-Redirect-URL-NOK").append("=").append(Fintech_Redirect_URL_NOK).append("&");
// Mandatory header Fintech-Redirect-URL-OK;
String Fintech_Redirect_URL_OK = toSign.getHeaders().get("fintech-redirect-url-ok");
if (null == Fintech_Redirect_URL_OK || "".equals(Fintech_Redirect_URL_OK)) {
throw new IllegalStateException("Missing Fintech-Redirect-URL-OK mandatory header");
}
result.append("Fintech-Redirect-URL-OK").append("=").append(Fintech_Redirect_URL_OK).append("&");
// Mandatory header Fintech-User-ID;
String Fintech_User_ID = toSign.getHeaders().get("fintech-user-id");
if (null == Fintech_User_ID || "".equals(Fintech_User_ID)) {
throw new IllegalStateException("Missing Fintech-User-ID mandatory header");
}
result.append("Fintech-User-ID").append("=").append(Fintech_User_ID).append("&");
// Optional header PSU-IP-Address;
String PSU_IP_Address = toSign.getHeaders().get("psu-ip-address");
if (null != PSU_IP_Address && !"".equals(PSU_IP_Address)) {
result.append("PSU-IP-Address").append("=").append(PSU_IP_Address).append("&");
}
// Optional header Service-Session-ID;
String Service_Session_ID = toSign.getHeaders().get("service-session-id");
if (null != Service_Session_ID && !"".equals(Service_Session_ID)) {
result.append("Service-Session-ID").append("=").append(Service_Session_ID).append("&");
}
// Mandatory header Service-Session-Password;
String Service_Session_Password = toSign.getHeaders().get("service-session-password");
if (null == Service_Session_Password || "".equals(Service_Session_Password)) {
throw new IllegalStateException("Missing Service-Session-Password mandatory header");
}
result.append("Service-Session-Password").append("=").append(Service_Session_Password).append("&");
// Optional header X-Create-Consent-If-None;
String X_Create_Consent_If_None = toSign.getHeaders().get("x-create-consent-if-none");
if (null != X_Create_Consent_If_None && !"".equals(X_Create_Consent_If_None)) {
result.append("X-Create-Consent-If-None").append("=").append(X_Create_Consent_If_None).append("&");
}
// Optional header X-Import-User-Data;
String X_Import_User_Data = toSign.getHeaders().get("x-import-user-data");
if (null != X_Import_User_Data && !"".equals(X_Import_User_Data)) {
result.append("X-Import-User-Data").append("=").append(X_Import_User_Data).append("&");
}
// Optional header X-Psu-Authentication-Required;
String X_Psu_Authentication_Required = toSign.getHeaders().get("x-psu-authentication-required");
if (null != X_Psu_Authentication_Required && !"".equals(X_Psu_Authentication_Required)) {
result.append("X-Psu-Authentication-Required").append("=").append(X_Psu_Authentication_Required).append("&");
}
// Mandatory header X-Request-ID;
String X_Request_ID = toSign.getHeaders().get("x-request-id");
if (null == X_Request_ID || "".equals(X_Request_ID)) {
throw new IllegalStateException("Missing X-Request-ID mandatory header");
}
result.append("X-Request-ID").append("=").append(X_Request_ID).append("&");
// Optional header X-Request-Signature;
String X_Request_Signature = toSign.getHeaders().get("x-request-signature");
if (null != X_Request_Signature && !"".equals(X_Request_Signature)) {
result.append("X-Request-Signature").append("=").append(X_Request_Signature).append("&");
}
// Optional header X-Timestamp-UTC;
String X_Timestamp_UTC = toSign.getHeaders().get("x-timestamp-utc");
if (null != X_Timestamp_UTC && !"".equals(X_Timestamp_UTC)) {
result.append("X-Timestamp-UTC").append("=").append(X_Timestamp_UTC).append("&");
}
// Done adding headers;
// Add query parameters;
// Optional parameter online;
String online = toSign.getQueryParams().get("online");
if (null != online && !"".equals(online)) {
result.append("online").append("=").append(online).append("&");
}
// Optional parameter withBalance;
String withBalance = toSign.getQueryParams().get("withBalance");
if (null != withBalance && !"".equals(withBalance)) {
result.append("withBalance").append("=").append(withBalance).append("&");
}
// Done adding query parameters;
return result.toString();
}
}