diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java index 21b6056bb04c..2ff252c75a7e 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.publisher.v1.common/src/main/java/org/wso2/carbon/apimgt/rest/api/publisher/v1/common/mappings/APIMappingUtil.java @@ -1155,6 +1155,15 @@ public static APIDTO fromAPItoDTO(API model, boolean preserveCredentials, } } + if (APIConstants.ENDPOINT_SECURITY_TYPE_API_KEY.equals(productionEndpointType)) { + String apiKeyValue = (String) productionEndpointSecurity + .get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE); + if (StringUtils.isNotEmpty(apiKeyValue)) { + productionEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE, + new String(cryptoUtil.base64DecodeAndDecrypt(apiKeyValue))); + } + } + endpointSecurity.put(APIConstants.OAuthConstants.ENDPOINT_SECURITY_PRODUCTION, productionEndpointSecurity); endpointConfigJson.put(APIConstants.ENDPOINT_SECURITY, endpointSecurity); @@ -1184,6 +1193,15 @@ public static APIDTO fromAPItoDTO(API model, boolean preserveCredentials, } } + if (APIConstants.ENDPOINT_SECURITY_TYPE_API_KEY.equals(sandboxEndpointType)) { + String apiKeyValue = (String) sandboxEndpointSecurity + .get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE); + if (StringUtils.isNotEmpty(apiKeyValue)) { + sandboxEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE, + new String(cryptoUtil.base64DecodeAndDecrypt(apiKeyValue))); + } + } + endpointSecurity.put(APIConstants.OAuthConstants.ENDPOINT_SECURITY_SANDBOX, sandboxEndpointSecurity); endpointConfigJson.put(APIConstants.ENDPOINT_SECURITY, endpointSecurity); @@ -3266,6 +3284,9 @@ private static JSONObject handleEndpointSecurity(API api, JSONObject endpointSec if (sandboxEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_PASSWORD) != null) { sandboxEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_PASSWORD, ""); } + if (sandboxEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE) != null) { + sandboxEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE, ""); + } } if (endpointSecurityElement.get(APIConstants.ENDPOINT_SECURITY_PRODUCTION) != null) { JSONObject productionEndpointSecurity = @@ -3277,6 +3298,9 @@ private static JSONObject handleEndpointSecurity(API api, JSONObject endpointSec if (productionEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_PASSWORD) != null) { productionEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_PASSWORD, ""); } + if (productionEndpointSecurity.get(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE) != null) { + productionEndpointSecurity.put(APIConstants.ENDPOINT_SECURITY_API_KEY_VALUE, ""); + } } return endpointSecurityElement; }