diff --git a/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationException.java b/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationException.java index 821287ca..54a5fb5f 100644 --- a/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationException.java +++ b/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationException.java @@ -16,14 +16,14 @@ * under the License. */ -package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency; +package org.wso2.financial.services.accelerator.consent.mgt.extensions.common.idempotency; -import com.wso2.openbanking.accelerator.common.exception.OpenBankingException; +import org.wso2.financial.services.accelerator.common.exception.ConsentManagementException; /** * Used for handling exceptions in Idempotency Validation. */ -public class IdempotencyValidationException extends OpenBankingException { +public class IdempotencyValidationException extends ConsentManagementException { public IdempotencyValidationException(String message) { super(message); diff --git a/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationUtils.java b/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationUtils.java index ce1119b1..afcaf827 100644 --- a/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationUtils.java +++ b/financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/common/idempotency/IdempotencyValidationUtils.java @@ -16,15 +16,15 @@ * under the License. */ -package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency; +package org.wso2.financial.services.accelerator.consent.mgt.extensions.common.idempotency; -import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser; -import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException; -import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder; -import com.wso2.openbanking.accelerator.consent.mgt.service.ConsentCoreService; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.financial.services.accelerator.common.config.FinancialServicesConfigParser; +import org.wso2.financial.services.accelerator.common.exception.ConsentManagementException; +import org.wso2.financial.services.accelerator.consent.mgt.extensions.internal.ConsentExtensionsDataHolder; +import org.wso2.financial.services.accelerator.consent.mgt.service.ConsentCoreService; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -32,6 +32,9 @@ import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * Class to hold idempotency validation utils. @@ -49,8 +52,8 @@ public class IdempotencyValidationUtils { * @param idempotencyKeyValue Idempotency Key Value * @return List of consent ids if available, else an empty list will be returned */ - static ArrayList getConsentIdsFromIdempotencyKey(String idempotencyKeyName, - String idempotencyKeyValue) { + static List getConsentIdsFromIdempotencyKey(String idempotencyKeyName, + String idempotencyKeyValue) { try { return consentCoreService.getConsentIdByConsentAttributeNameAndValue( idempotencyKeyName, idempotencyKeyValue); @@ -60,6 +63,21 @@ static ArrayList getConsentIdsFromIdempotencyKey(String idempotencyKeyNa } } + /** + * Method to retrieve the consent ids and idempotency key value using the idempotency key. + * + * @param idempotencyKeyName Idempotency Key Name + * @return Map of consent ids and idempotency key vallue if available, else an empty map will be returned + */ + static Map getAttributesFromIdempotencyKey(String idempotencyKeyName) { + try { + return consentCoreService.getConsentAttributesByName(idempotencyKeyName); + } catch (ConsentManagementException e) { + log.debug("No consent ids found for the idempotency key value"); + return new HashMap<>(); + } + } + /** * Method to compare the client ID sent in the request and client id retrieved from the database. * @@ -86,13 +104,13 @@ static boolean isRequestReceivedWithinAllowedTime(long createdTime) { log.debug("Created time is of the previous request is not correctly set. Hence returning false"); return false; } - String allowedTimeDuration = OpenBankingConfigParser.getInstance().getIdempotencyAllowedTime(); + String allowedTimeDuration = FinancialServicesConfigParser.getInstance().getIdempotencyAllowedTime(); if (StringUtils.isNotBlank(allowedTimeDuration)) { OffsetDateTime createdDate = OffsetDateTime.parse(toISO8601DateTime(createdTime)); OffsetDateTime currDate = OffsetDateTime.now(createdDate.getOffset()); - long diffInMinutes = Duration.between(createdDate, currDate).toMinutes(); - return diffInMinutes <= Long.parseLong(allowedTimeDuration); + long diffInHours = Duration.between(createdDate, currDate).toHours(); + return diffInHours <= Long.parseLong(allowedTimeDuration); } else { log.error("Idempotency allowed duration is not configured in the system. Hence returning false"); return false; diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java deleted file mode 100644 index 2ad025f9..00000000 --- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/config/OpenBankingConfigParser.java +++ /dev/null @@ -1,1479 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.wso2.openbanking.accelerator.common.config; - -import com.wso2.openbanking.accelerator.common.constant.OpenBankingConstants; -import com.wso2.openbanking.accelerator.common.exception.OpenBankingRuntimeException; -import com.wso2.openbanking.accelerator.common.util.CarbonUtils; -import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMException; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.securevault.SecretResolver; -import org.wso2.securevault.SecretResolverFactory; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Stack; -import java.util.stream.Collectors; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; - -import static java.util.Map.Entry.comparingByKey; - -/** - * Config parser for open-banking.xml. - */ -public class OpenBankingConfigParser { - - // To enable attempted thread-safety using double-check locking - private static final Object lock = new Object(); - private static final Log log = LogFactory.getLog(OpenBankingConfigParser.class); - private static final Map configuration = new HashMap<>(); - private static final Map> obExecutors = new HashMap<>(); - private static final Map> dataPublishingStreams = new HashMap<>(); - private static final Map> dataPublishingValidationMap = new HashMap<>(); - private static final Map> dcrRegistrationConfigs = new HashMap<>(); - private static final Map> authorizeSteps = new HashMap<>(); - private static final Map> allowedScopes = new HashMap<>(); - private static final Map> allowedAPIs = new HashMap<>(); - private static final Map revocationValidators = new HashMap<>(); - private static final List serviceActivatorSubscribers = new ArrayList<>(); - private static final Map> keyManagerAdditionalProperties - = new HashMap<>(); - private static Map obEventExecutors = new HashMap<>(); - private static OpenBankingConfigParser parser; - private static String configFilePath; - private static SecretResolver secretResolver; - private OMElement rootElement; - - private Map authWorkerConfig = new HashMap<>(); - - /** - * Private Constructor of config parser. - */ - private OpenBankingConfigParser() { - - buildConfiguration(); - } - - /** - * Singleton getInstance method to create only one object. - * - * @return OpenBankingConfigParser object - */ - public static OpenBankingConfigParser getInstance() { - - if (parser == null) { - synchronized (lock) { - if (parser == null) { - parser = new OpenBankingConfigParser(); - } - } - } - return parser; - } - - /** - * Method to get an instance of ConfigParser when custom file path is provided. - * - * This method is deprecated as it allows custom absolute file paths which could result in - * path traversal attacks. Do not use this method unless the custom path is trusted. - * - * @param filePath Custom file path - * @return OpenBankingConfigParser object - * @Deprecated use OpenBankingConfigParser.getInstance() - */ - @Deprecated - public static OpenBankingConfigParser getInstance(String filePath) { - - configFilePath = filePath; - return getInstance(); - } - - /** - * Method to obtain map of configs. - * - * @return Config map - */ - public Map getConfiguration() { - - return configuration; - } - - /** - * Method to read the configuration (in a recursive manner) as a model and put them in the configuration map. - */ - @SuppressFBWarnings("PATH_TRAVERSAL_IN") - // Suppressed content - new FileInputStream(configFilePath) - // Suppression reason - False Positive : Method for passing configFilePath is deprecated and is used for testing - // purposes only. Therefore, it can be assumed that configFilePath is a trusted filepath - // Suppressed warning count - 1 - private void buildConfiguration() { - - InputStream inStream = null; - StAXOMBuilder builder; - String warningMessage = ""; - try { - if (configFilePath != null) { - File openBankingConfigXml = new File(configFilePath); - if (openBankingConfigXml.exists()) { - inStream = new FileInputStream(openBankingConfigXml); - } - } else { - File openBankingConfigXml = new File(CarbonUtils.getCarbonConfigDirPath(), - OpenBankingConstants.OB_CONFIG_FILE); - if (openBankingConfigXml.exists()) { - inStream = new FileInputStream(openBankingConfigXml); - } - } - if (inStream == null) { - String message = - "open-banking configuration not found at: " + configFilePath + " . Cause - " + warningMessage; - if (log.isDebugEnabled()) { - log.debug(message.replaceAll("[\r\n]", "")); - } - throw new FileNotFoundException(message); - } - builder = new StAXOMBuilder(inStream); - builder.setDoDebug(false); - rootElement = builder.getDocumentElement(); - Stack nameStack = new Stack<>(); - secretResolver = SecretResolverFactory.create(rootElement, true); - readChildElements(rootElement, nameStack); - buildOBExecutors(); - buildDataPublishingStreams(); - buildDCRParameters(); - buildConsentAuthSteps(); - buildAllowedScopes(); - buildAllowedSubscriptions(); - buildServiceActivatorSubscribers(); - buildKeyManagerProperties(); - buildOBEventExecutors(); - buildWorkers(); - } catch (IOException | XMLStreamException | OMException e) { - throw new OpenBankingRuntimeException("Error occurred while building configuration from open-banking.xml", - e); - } finally { - try { - if (inStream != null) { - inStream.close(); - } - } catch (IOException e) { - log.error("Error closing the input stream for open-banking.xml", e); - } - } - } - - private void buildOBExecutors() { - - OMElement gatewayElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.GATEWAY_CONFIG_TAG)); - - if (gatewayElement != null) { - - OMElement openBankingGatewayExecutors = gatewayElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.GATEWAY_EXECUTOR_CONFIG_TAG)); - - if (openBankingGatewayExecutors != null) { - //obtaining each consent type element under OpenBankingGatewayExecutors tag - Iterator consentTypeElement = openBankingGatewayExecutors.getChildElements(); - while (consentTypeElement.hasNext()) { - OMElement consentType = (OMElement) consentTypeElement.next(); - String consentTypeName = consentType.getLocalName(); - Map executors = new HashMap<>(); - //obtaining each Executor element under each consent type - Iterator obExecutor = consentType.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.EXECUTOR_CONFIG_TAG)); - if (obExecutor != null) { - while (obExecutor.hasNext()) { - OMElement executorElement = obExecutor.next(); - //Retrieve class name and priority from executor config - String obExecutorClass = executorElement.getAttributeValue(new QName("class")); - String obExecutorPriority = executorElement.getAttributeValue(new QName("priority")); - - if (StringUtils.isEmpty(obExecutorClass)) { - //Throwing exceptions since we cannot proceed without invalid executor names - throw new OpenBankingRuntimeException("Executor class is not defined " + - "correctly in open-banking.xml"); - } - int priority = Integer.MAX_VALUE; - if (!StringUtils.isEmpty(obExecutorPriority)) { - priority = Integer.parseInt(obExecutorPriority); - } - executors.put(priority, obExecutorClass); - } - } - //Ordering the executors based on the priority number - LinkedHashMap priorityMap = executors.entrySet() - .stream() - .sorted(comparingByKey()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, - LinkedHashMap::new)); - obExecutors.put(consentTypeName, priorityMap); - } - } - } - } - - protected void buildKeyManagerProperties() { - - OMElement keyManagerElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.KEY_MANAGER_CONFIG_TAG)); - - if (keyManagerElement != null) { - OMElement keyManagerProperties = keyManagerElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.KEY_MANAGER_ADDITIONAL_PROPERTIES_CONFIG_TAG)); - - if (keyManagerProperties != null) { - Iterator properties = keyManagerProperties.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.PROPERTY_CONFIG_TAG)); - if (properties != null) { - while (properties.hasNext()) { - OMElement propertyElement = properties.next(); - - //Retrieve attributes from key manager config - Map property = new HashMap<>(); - property.put("priority", propertyElement.getAttributeValue(new QName("priority"))); - property.put("label", propertyElement.getAttributeValue(new QName("label"))); - property.put("type", propertyElement.getAttributeValue(new QName("type"))); - property.put("tooltip", propertyElement.getAttributeValue(new QName("tooltip"))); - property.put("default", propertyElement.getAttributeValue(new QName("default"))); - property.put("required", propertyElement.getAttributeValue(new QName("required"))); - property.put("mask", propertyElement.getAttributeValue(new QName("mask"))); - property.put("multiple", propertyElement.getAttributeValue(new QName("multiple"))); - property.put("values", propertyElement.getAttributeValue(new QName("values"))); - String propertyName = propertyElement.getAttributeValue(new QName("name")); - - if (StringUtils.isBlank(propertyName)) { - //Throwing exceptions since we cannot proceed without property names - throw new OpenBankingRuntimeException("Additional property name is not defined " + - "correctly in open-banking.xml"); - } - - keyManagerAdditionalProperties.put(propertyName, property); - } - } - } - } - } - - protected void buildDataPublishingStreams() { - - OMElement dataPublishingElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.DATA_PUBLISHING_CONFIG_TAG)); - - if (dataPublishingElement != null) { - OMElement thriftElement = dataPublishingElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.THRIFT_CONFIG_TAG)); - - if (thriftElement != null) { - OMElement streams = thriftElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.STREAMS_CONFIG_TAG)); - - if (streams != null) { - Iterator dataStreamElement = streams.getChildElements(); - while (dataStreamElement.hasNext()) { - OMElement dataStream = (OMElement) dataStreamElement.next(); - String dataStreamName = dataStream.getLocalName(); - Map attributes = new HashMap<>(); - //obtaining attributes under each stream - Iterator attribute = dataStream.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.ATTRIBUTE_CONFIG_TAG)); - if (attribute != null) { - while (attribute.hasNext()) { - OMElement attributeElement = attribute.next(); - //Retrieve attribute name and priority from config - String attributeName = attributeElement.getAttributeValue(new QName("name")); - String attributePriority = attributeElement.getAttributeValue(new QName("priority")); - String isRequired = attributeElement.getAttributeValue(new QName("required")); - String type = attributeElement.getAttributeValue(new QName("type")); - - if (StringUtils.isEmpty(attributeName)) { - //Throwing exceptions since we cannot proceed without valid attribute names - throw new OpenBankingRuntimeException( - "Data publishing attribute name is not defined " + - "correctly in open-banking.xml"); - } - int priority = Integer.MAX_VALUE; - if (!StringUtils.isEmpty(attributePriority)) { - priority = Integer.parseInt(attributePriority); - } - boolean required = false; - if (!StringUtils.isEmpty(isRequired)) { - required = Boolean.parseBoolean(isRequired); - } - - String attributeType = "string"; - if (!StringUtils.isEmpty(type)) { - attributeType = type; - } - - Map metadata = new HashMap<>(); - metadata.put(OpenBankingConstants.REQUIRED, required); - metadata.put(OpenBankingConstants.ATTRIBUTE_TYPE, attributeType); - - attributes.put(priority, attributeName); - String attributeKey = dataStreamName + "_" + attributeName; - dataPublishingValidationMap.put(attributeKey, metadata); - } - } - //Ordering the attributes based on the priority number - LinkedHashMap priorityMap = attributes.entrySet() - .stream() - .sorted(comparingByKey()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, - LinkedHashMap::new)); - dataPublishingStreams.put(dataStreamName, priorityMap); - } - } - } - } - } - - private void buildDCRParameters() { - - OMElement dcrElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.DCR_CONFIG_TAG)); - - if (dcrElement != null) { - OMElement registrationElement = dcrElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.DCR_REGISTRATION_CONFIG_TAG)); - - if (registrationElement != null) { - //obtaining each parameter type element under RegistrationRequestPrams tag - Iterator parameterTypeElement = registrationElement.getChildElements(); - while (parameterTypeElement.hasNext()) { - OMElement parameterType = (OMElement) parameterTypeElement.next(); - String parameterTypeName = parameterType.getLocalName(); - Map parameterValues = new HashMap<>(); - //obtaining each element under each parameter type - Iterator childValues = parameterType.getChildElements(); - while (childValues.hasNext()) { - OMElement child = (OMElement) childValues.next(); - if (OpenBankingConstants.DCR_REGISTRATION_PARAM_ALLOWED_VALUE_TAG - .equalsIgnoreCase(child.getLocalName())) { - - OMElement allowedValuesElement = parameterType.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.DCR_REGISTRATION_PARAM_ALLOWED_VALUE_TAG)); - - List values = new ArrayList<>(); - if (allowedValuesElement != null) { - Iterator allowedValues = allowedValuesElement.getChildElements(); - while (allowedValues.hasNext()) { - OMElement value = (OMElement) allowedValues.next(); - values.add(value.getText()); - } - parameterValues.put(child.getLocalName(), values); - } - } else { - parameterValues.put(child.getLocalName(), child.getText()); - } - } - dcrRegistrationConfigs.put(parameterTypeName, parameterValues); - } - } - } - - } - - private void buildConsentAuthSteps() { - - OMElement consentElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.CONSENT_CONFIG_TAG)); - - if (consentElement != null) { - OMElement consentAuthorizeSteps = consentElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.AUTHORIZE_STEPS_CONFIG_TAG)); - - if (consentAuthorizeSteps != null) { - //obtaining each step type element under AuthorizeSteps tag - Iterator stepTypeElement = consentAuthorizeSteps.getChildElements(); - while (stepTypeElement.hasNext()) { - OMElement stepType = (OMElement) stepTypeElement.next(); - String consentTypeName = stepType.getLocalName(); - Map executors = new HashMap<>(); - //obtaining each step under each consent type - Iterator obExecutor = stepType.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.STEP_CONFIG_TAG)); - if (obExecutor != null) { - while (obExecutor.hasNext()) { - OMElement executorElement = obExecutor.next(); - //Retrieve class name and priority from executor config - String obExecutorClass = executorElement.getAttributeValue(new QName("class")); - String obExecutorPriority = executorElement.getAttributeValue(new QName("priority")); - - if (StringUtils.isEmpty(obExecutorClass)) { - //Throwing exceptions since we cannot proceed without invalid executor names - throw new OpenBankingRuntimeException("Executor class is not defined " + - "correctly in open-banking.xml"); - } - int priority = Integer.MAX_VALUE; - if (!StringUtils.isEmpty(obExecutorPriority)) { - priority = Integer.parseInt(obExecutorPriority); - } - executors.put(priority, obExecutorClass); - } - } - //Ordering the executors based on the priority number - LinkedHashMap priorityMap = executors.entrySet() - .stream() - .sorted(comparingByKey()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, - LinkedHashMap::new)); - authorizeSteps.put(consentTypeName, priorityMap); - } - } - } - } - - /** - * Method to read text configs from xml when root element is given. - * - * @param serverConfig XML root element object - * @param nameStack stack of config names - */ - private void readChildElements(OMElement serverConfig, Stack nameStack) { - - for (Iterator childElements = serverConfig.getChildElements(); childElements.hasNext(); ) { - OMElement element = (OMElement) childElements.next(); - nameStack.push(element.getLocalName()); - if (elementHasText(element)) { - String key = getKey(nameStack); - Object currentObject = configuration.get(key); - String value = replaceSystemProperty(element.getText()); - if (secretResolver != null && secretResolver.isInitialized() && - secretResolver.isTokenProtected(key)) { - value = secretResolver.resolve(key); - } - if (currentObject == null) { - configuration.put(key, value); - } else if (currentObject instanceof ArrayList) { - ArrayList list = (ArrayList) currentObject; - if (!list.contains(value)) { - list.add(value); - configuration.put(key, list); - } - } else { - if (!value.equals(currentObject)) { - ArrayList arrayList = new ArrayList<>(2); - arrayList.add(currentObject); - arrayList.add(value); - configuration.put(key, arrayList); - } - } - } else if (OpenBankingConstants.REVOCATION_VALIDATORS_CONFIG_TAG.equalsIgnoreCase(element.getLocalName())) { - Iterator environmentIterator = element - .getChildrenWithLocalName(OpenBankingConstants.REVOCATION_VALIDATOR_CONFIG_TAG); - - while (environmentIterator.hasNext()) { - OMElement environmentElem = (OMElement) environmentIterator.next(); - String revocationType = environmentElem.getAttributeValue(new QName("type")); - Integer priority; - try { - priority = Integer.parseInt(environmentElem.getAttributeValue(new QName("priority"))); - } catch (NumberFormatException e) { - log.warn("Consent retrieval RevocationValidator " + revocationType.replaceAll("[\r\n]", "") - + " priority invalid. Hence skipped"); - continue; - } - revocationValidators.put(priority, revocationType); - } - } - readChildElements(element, nameStack); - nameStack.pop(); - } - } - - private void buildAllowedScopes() { - OMElement gatewayElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.GATEWAY_CONFIG_TAG)); - - if (gatewayElement != null) { - OMElement tppManagementElement = gatewayElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.TPP_MANAGEMENT_CONFIG_TAG)); - - if (tppManagementElement != null) { - OMElement allowedScopesElement = tppManagementElement.getFirstChildWithName(new QName( - OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.ALLOWED_SCOPES_CONFIG_TAG)); - - //obtaining each scope under allowed scopes - Iterator environmentIterator = - allowedScopesElement.getChildrenWithLocalName(OpenBankingConstants.SCOPE_CONFIG_TAG); - - while (environmentIterator.hasNext()) { - OMElement scopeElem = (OMElement) environmentIterator.next(); - String scopeName = scopeElem.getAttributeValue(new QName("name")); - String rolesStr = scopeElem.getAttributeValue(new QName("roles")); - if (StringUtils.isNotEmpty(rolesStr)) { - List rolesList = Arrays.stream(rolesStr.split(",")) - .map(String::trim) - .collect(Collectors.toList()); - allowedScopes.put(scopeName, rolesList); - } - } - } - } - } - - private void buildAllowedSubscriptions() { - - OMElement dcrElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.DCR_CONFIG_TAG)); - - if (dcrElement != null) { - OMElement regulatoryAPINames = dcrElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.REGULATORY_APINAMES)); - - if (regulatoryAPINames != null) { - - //obtaining each scope under allowed scopes - Iterator environmentIterator = - regulatoryAPINames.getChildrenWithLocalName(OpenBankingConstants.REGULATORY_API); - - while (environmentIterator.hasNext()) { - OMElement scopeElem = (OMElement) environmentIterator.next(); - String scopeName = scopeElem.getAttributeValue(new QName("name")); - String rolesStr = scopeElem.getAttributeValue(new QName("roles")); - if (StringUtils.isNotEmpty(rolesStr)) { - List rolesList = Arrays.stream(rolesStr.split(",")) - .map(String::trim) - .collect(Collectors.toList()); - allowedAPIs.put(scopeName, rolesList); - } - } - } - } - - } - - private void buildOBEventExecutors() { - - OMElement eventElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.EVENT_CONFIG_TAG)); - - if (eventElement != null) { - - OMElement openBankingEventExecutors = eventElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, - OpenBankingConstants.EVENT_EXECUTOR_CONFIG_TAG)); - - if (openBankingEventExecutors != null) { - //obtaining each executor element under EventExecutors tag - //Ordering the executors based on the priority number - Iterator eventExecutor = openBankingEventExecutors.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.EXECUTOR_CONFIG_TAG)); - if (eventExecutor != null) { - while (eventExecutor.hasNext()) { - OMElement executorElement = eventExecutor.next(); - //Retrieve class name and priority from executor config - String obExecutorClass = executorElement.getAttributeValue(new QName("class")); - String obExecutorPriority = executorElement.getAttributeValue(new QName("priority")); - - if (StringUtils.isEmpty(obExecutorClass)) { - //Throwing exceptions since we cannot proceed without invalid executor names - throw new OpenBankingRuntimeException("Event Executor class is not defined " + - "correctly in open-banking.xml"); - } - int priority = Integer.MAX_VALUE; - if (!StringUtils.isEmpty(obExecutorPriority)) { - priority = Integer.parseInt(obExecutorPriority); - } - obEventExecutors.put(priority, obExecutorClass); - } - } - //Ordering the executors based on the priority number - obEventExecutors = obEventExecutors.entrySet() - .stream() - .sorted(comparingByKey()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, - LinkedHashMap::new)); - } - } - } - - /** - * Method to build configurations for Authentication Worker Extension point. - */ - private void buildWorkers() { - - OMElement workersOMEList = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.AUTHENTICATION_WORKER_LIST_TAG)); - - if (workersOMEList != null) { - Iterator workerConfigs = workersOMEList.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.AUTHENTICATION_WORKER_TAG)); - if (workerConfigs != null) { - while (workerConfigs.hasNext()) { - OMElement executorElement = workerConfigs.next(); - //Retrieve class name and implementation from executor config - String workerClass = executorElement.getAttributeValue(new QName("class")); - String workerName = executorElement.getAttributeValue(new QName("name")); - - if (StringUtils.isEmpty(workerClass) || StringUtils.isEmpty(workerName)) { - //Throwing exceptions since we cannot proceed without invalid worker names - throw new OpenBankingRuntimeException("Authentication worker class is not defined " + - "correctly in open-banking.xml"); - } - authWorkerConfig.put(workerName, workerClass); - } - } - } - } - - /** - * Method to obtain config key from stack. - * - * @param nameStack Stack of strings with names. - * @return key as a String - */ - private String getKey(Stack nameStack) { - - StringBuilder key = new StringBuilder(); - for (int index = 0; index < nameStack.size(); index++) { - String name = nameStack.elementAt(index); - key.append(name).append("."); - } - key.deleteCharAt(key.lastIndexOf(".")); - return key.toString(); - } - - /** - * Method to replace system properties in configs. - * - * @param text String that may require modification - * @return modified string - */ - private String replaceSystemProperty(String text) { - - int indexOfStartingChars = -1; - int indexOfClosingBrace; - - // The following condition deals with properties. - // Properties are specified as ${system.property}, - // and are assumed to be System properties - StringBuilder textBuilder = new StringBuilder(text); - while (indexOfStartingChars < textBuilder.indexOf("${") - && (indexOfStartingChars = textBuilder.indexOf("${")) != -1 - && (indexOfClosingBrace = textBuilder.indexOf("}")) != -1) { // Is a property used? - String sysProp = textBuilder.substring(indexOfStartingChars + 2, indexOfClosingBrace); - String propValue = System.getProperty(sysProp); - if (propValue != null) { - textBuilder = new StringBuilder(textBuilder.substring(0, indexOfStartingChars) + propValue - + textBuilder.substring(indexOfClosingBrace + 1)); - } - if (sysProp.equals(OpenBankingConstants.CARBON_HOME) && - System.getProperty(OpenBankingConstants.CARBON_HOME).equals(".")) { - textBuilder.insert(0, new File(".").getAbsolutePath() + File.separator); - } - } - return textBuilder.toString(); - } - - /** - * Method to check whether config element has text value. - * - * @param element root element as a object - * @return availability of text in the config - */ - private boolean elementHasText(OMElement element) { - - String text = element.getText(); - return text != null && text.trim().length() != 0; - } - - public Map> getOpenBankingExecutors() { - - return obExecutors; - } - - public Map getOpenBankingEventExecutors() { - - return obEventExecutors; - } - - public Map> getDataPublishingStreams() { - - return dataPublishingStreams; - } - - public Map> getDataPublishingValidationMap() { - - return dataPublishingValidationMap; - } - - public Map> getConsentAuthorizeSteps() { - - return authorizeSteps; - } - - public Map> getKeyManagerAdditionalProperties() { - - return keyManagerAdditionalProperties; - } - - /** - * Returns the element with the provided key. - * - * @param key local part name - * @return Corresponding value for key - */ - public Object getConfigElementFromKey(String key) { - - return configuration.get(key); - } - - public String getDataSourceName() { - - return getConfigElementFromKey(OpenBankingConstants.JDBC_PERSISTENCE_CONFIG) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.JDBC_PERSISTENCE_CONFIG)).trim(); - } - - /** - * Returns the database connection verification timeout in seconds configured in open-banking.xml. - * - * @return 1 if nothing is configured - */ - public int getConnectionVerificationTimeout() { - - return getConfigElementFromKey(OpenBankingConstants.DB_CONNECTION_VERIFICATION_TIMEOUT) == null ? 1 : - Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.DB_CONNECTION_VERIFICATION_TIMEOUT).toString().trim()); - } - - /** - * Returns the retention datasource name configured in open-banking.xml. - * @return - */ - public String getRetentionDataSourceName() { - - return getConfigElementFromKey(OpenBankingConstants.JDBC_RETENTION_DATA_PERSISTENCE_CONFIG) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.JDBC_RETENTION_DATA_PERSISTENCE_CONFIG)).trim(); - } - - /** - * Returns the retention database connection verification timeout in seconds configured in open-banking.xml. - * - * @return 1 if nothing is configured - */ - public int getRetentionDataSourceConnectionVerificationTimeout() { - - return getConfigElementFromKey(OpenBankingConstants.RETENTION_DATA_DB_CONNECTION_VERIFICATION_TIMEOUT) - == null ? 1 : Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.RETENTION_DATA_DB_CONNECTION_VERIFICATION_TIMEOUT).toString().trim()); - } - - /** - * Method to get isEnabled config for consent data retention feature. - * @return consent data retention is enabled - */ - public boolean isConsentDataRetentionEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.IS_CONSENT_DATA_RETENTION_ENABLED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_CONSENT_DATA_RETENTION_ENABLED).toString().trim())); - } - - - /** - * Method to get isEnabled config for consent data retention periodical job. - * @return consent data retention is enabled - */ - public boolean isRetentionDataDBSyncEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.IS_CONSENT_RETENTION_DATA_DB_SYNC_ENABLED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_CONSENT_RETENTION_DATA_DB_SYNC_ENABLED).toString().trim())); - } - - - /** - * Method to get configs for data retention db sync periodical job's cron value. - * @return data retention job's cron string - */ - public String getRetentionDataDBSyncCronExpression() { - - return getConfigElementFromKey(OpenBankingConstants.CONSENT_RETENTION_DATA_DB_SYNC_CRON) == null - ? OpenBankingConstants.DEFAULT_MIDNIGHT_CRON : - ((String) getConfigElementFromKey(OpenBankingConstants.CONSENT_RETENTION_DATA_DB_SYNC_CRON)).trim(); - } - - /** - * Truststore dynamic loading interval. - * - * @return truststore dynamic loading time in seconds - */ - public Long getTruststoreDynamicLoadingInterval() { - try { - Object truststoreDynamicLoadingInterval = - getConfigElementFromKey(OpenBankingConstants.TRUSTSTORE_DYNAMIC_LOADING_INTERVAL); - if (truststoreDynamicLoadingInterval != null) { - return Long.parseLong((String) truststoreDynamicLoadingInterval); - } else { - return Long.parseLong("86400"); - } - } catch (NumberFormatException e) { - throw new NumberFormatException("Error occurred while reading the truststore dynamic loading interval " + - "value in open-banking.xml. " + e.getMessage()); - } - } - - /** - * Returns the revocation validators map. - *

- * The revocation validator map contains revocation type (OCSP/CRL) and its executing priority. - * The default priority value has set as 1 for OCSP type, as OCSP validation is faster than the CRL validation - * - * @return certificate revocation validators map - */ - public Map getCertificateRevocationValidators() { - return revocationValidators; - } - - public Map> getOpenBankingDCRRegistrationParams() { - return dcrRegistrationConfigs; - } - - public String getAuthServletExtension() { - return getConfigElementFromKey(OpenBankingConstants.AUTH_SERVLET_EXTENSION) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.AUTH_SERVLET_EXTENSION)).trim(); - } - - public String getCibaServletExtension() { - return getConfigElementFromKey(OpenBankingConstants.CIBA_SERVLET_EXTENSION) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.CIBA_SERVLET_EXTENSION)).trim(); - } - - public String getJWKSConnectionTimeOut() { - - return getConfigElementFromKey(OpenBankingConstants.DCR_JWKS_CONNECTION_TIMEOUT) == null ? "3000" : - ((String) getConfigElementFromKey(OpenBankingConstants.DCR_JWKS_CONNECTION_TIMEOUT)).trim(); - } - - public String getJWKSReadTimeOut() { - - return getConfigElementFromKey(OpenBankingConstants.DCR_JWKS_READ_TIMEOUT) == null ? "3000" : - ((String) getConfigElementFromKey(OpenBankingConstants.DCR_JWKS_READ_TIMEOUT)).trim(); - } - - public String getSPMetadataFilterExtension() { - return getConfigElementFromKey(OpenBankingConstants.SP_METADATA_FILTER_EXTENSION) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.SP_METADATA_FILTER_EXTENSION)).trim(); - } - - public Map> getAllowedScopes() { - return allowedScopes; - } - - public Map> getAllowedAPIs() { - return allowedAPIs; - } - - /** - * Method to get configs for periodical consent expiration job's cron value. - * @return consent expiration job's cron string - */ - public String getConsentExpiryCronExpression() { - - return getConfigElementFromKey(OpenBankingConstants.CONSENT_PERIODICAL_EXPIRATION_CRON) == null - ? OpenBankingConstants.DEFAULT_MIDNIGHT_CRON : - ((String) getConfigElementFromKey(OpenBankingConstants.CONSENT_PERIODICAL_EXPIRATION_CRON)).trim(); - } - - /** - * Method to get statue for expired consents. - * @return statue for expired consents - */ - public String getStatusWordingForExpiredConsents() { - - return getConfigElementFromKey(OpenBankingConstants.STATUS_FOR_EXPIRED_CONSENT) == null - ? OpenBankingConstants.DEFAULT_STATUS_FOR_EXPIRED_CONSENTS : - ((String) getConfigElementFromKey(OpenBankingConstants.STATUS_FOR_EXPIRED_CONSENT)).trim(); - } - - /** - * Method to get eligible statues for evaluate expiration logic. - * @return eligible statues for evaluate expiration logic - */ - public String getEligibleStatusesForConsentExpiry() { - - return getConfigElementFromKey(OpenBankingConstants.ELIGIBLE_STATUSES_FOR_CONSENT_EXPIRY) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.ELIGIBLE_STATUSES_FOR_CONSENT_EXPIRY)).trim(); - } - - /** - * Method to get isEnabled config for periodical consent expiration job. - * @return consent expiration job is enabled - */ - public boolean isConsentExpirationPeriodicalJobEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.IS_CONSENT_PERIODICAL_EXPIRATION_ENABLED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_CONSENT_PERIODICAL_EXPIRATION_ENABLED).toString().trim())); - } - - public boolean isConsentAmendmentHistoryEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.IS_CONSENT_AMENDMENT_HISTORY_ENABLED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_CONSENT_AMENDMENT_HISTORY_ENABLED).toString().trim())); - } - - public String getOBKeyManagerExtensionImpl() { - return getConfigElementFromKey(OpenBankingConstants.OB_KEYMANAGER_EXTENSION_IMPL) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.OB_KEYMANAGER_EXTENSION_IMPL)) - .trim(); - } - - /** - * ConnectionPool maximum connection count. - * - * @return maximum connections count, default value is 2000 - */ - public int getConnectionPoolMaxConnections() { - try { - Object maxConnectionsCount = - getConfigElementFromKey(OpenBankingConstants.CONNECTION_POOL_MAX_CONNECTIONS); - if (maxConnectionsCount != null) { - return Integer.parseInt(String.valueOf(maxConnectionsCount)); - } else { - return 2000; - } - } catch (NumberFormatException e) { - throw new NumberFormatException("Error occurred while reading the MaxConnections " + - "value in open-banking.xml. " + e.getMessage()); - } - } - - /** - * ConnectionPool maximum connection per route count. - * - * @return maximum connections per route value, default value is 1500 - */ - public int getConnectionPoolMaxConnectionsPerRoute() { - try { - Object maxConnectionsPerRouteCount = - getConfigElementFromKey(OpenBankingConstants.CONNECTION_POOL_MAX_CONNECTIONS_PER_ROUTE); - if (maxConnectionsPerRouteCount != null) { - return Integer.parseInt(String.valueOf(maxConnectionsPerRouteCount)); - } else { - return 1500; - } - } catch (NumberFormatException e) { - throw new NumberFormatException("Error occurred while reading the MaxConnectionsPerRoute " + - "value in open-banking.xml. " + e.getMessage()); - } - } - - private void buildServiceActivatorSubscribers() { - OMElement serviceActivatorElement = rootElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.SERVICE_ACTIVATOR_TAG)); - - if (serviceActivatorElement != null) { - OMElement subscribers = serviceActivatorElement.getFirstChildWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.SA_SUBSCRIBERS_TAG)); - - if (subscribers != null) { - Iterator subscriber = subscribers.getChildrenWithName( - new QName(OpenBankingConstants.OB_CONFIG_QNAME, OpenBankingConstants.SA_SUBSCRIBER_TAG)); - if (subscriber != null) { - while (subscriber.hasNext()) { - OMElement executorElement = subscriber.next(); - //Retrieve subscriber class name from service activator configs - final String subscriberClass = executorElement.getText(); - - if (!StringUtils.isEmpty(subscriberClass)) { - serviceActivatorSubscribers.add(subscriberClass); - } - } - } - } - } - } - - /** - * Returns a list of FQNs of the OBServiceObserver interface implementations. - * - * @return ServiceActivator subscribers FQNs. - */ - public List getServiceActivatorSubscribers() { - return serviceActivatorSubscribers; - } - - //Event notifications configurations. - public String getEventNotificationTokenIssuer() { - - return getConfigElementFromKey(OpenBankingConstants.TOKEN_ISSUER) == null ? "www.wso2.com" : - ((String) getConfigElementFromKey(OpenBankingConstants.TOKEN_ISSUER)).trim(); - } - - public int getNumberOfSetsToReturn() { - - return getConfigElementFromKey(OpenBankingConstants.MAX_SETS_TO_RETURN) == null ? 5 : - Integer.parseInt((String) getConfigElementFromKey(OpenBankingConstants.MAX_SETS_TO_RETURN)); - } - - public boolean isSubClaimIncluded() { - - return getConfigElementFromKey(OpenBankingConstants.IS_SUB_CLAIM_INCLUDED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_SUB_CLAIM_INCLUDED).toString().trim())); - } - - public boolean isToeClaimIncluded() { - return getConfigElementFromKey(OpenBankingConstants.IS_TOE_CLAIM_INCLUDED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_TOE_CLAIM_INCLUDED).toString().trim())); - } - - public boolean isTxnClaimIncluded() { - return getConfigElementFromKey(OpenBankingConstants.IS_TXN_CLAIM_INCLUDED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_TXN_CLAIM_INCLUDED).toString().trim())); - } - - /** - * Returns the expiry time for cache modification. - * - * @return String Expiry time. - */ - public String getCommonCacheModifiedExpiryTime() { - - return getConfigElementFromKey(OpenBankingConstants.COMMON_IDENTITY_CACHE_MODIFY_EXPIRY) == null ? "60" : - ((String) getConfigElementFromKey(OpenBankingConstants.COMMON_IDENTITY_CACHE_MODIFY_EXPIRY)).trim(); - } - - /** - * Returns the expiry time for cache access. - * - * @return String Expiry time. - */ - public String getCommonCacheAccessExpiryTime() { - return getConfigElementFromKey(OpenBankingConstants.COMMON_IDENTITY_CACHE_ACCESS_EXPIRY) == null ? "60" : - ((String) getConfigElementFromKey(OpenBankingConstants.COMMON_IDENTITY_CACHE_ACCESS_EXPIRY)).trim(); - } - - /** - * Alias of the signing certificate in Production Environment. - * - * @return signing certificate alias - */ - public String getOBIdnRetrieverSigningCertificateAlias() { - - return getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SIG_ALIAS) == null ? "wso2carbon" : - ((String) getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SIG_ALIAS)).trim(); - } - - /** - * Alias of the signing certificate in Sandbox Environment. - * - * @return signing certificate alias - */ - public String getOBIdnRetrieverSandboxSigningCertificateAlias() { - - return getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SANDBOX_SIG_ALIAS) == null ? "wso2carbon" : - ((String) getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SANDBOX_SIG_ALIAS)).trim(); - } - - /** - * Key ID of the public key of the corresponding private key used for signing. - * - * @return signing certificate Kid in Production environment - */ - public String getOBIdnRetrieverSigningCertificateKid() { - - return getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SIG_KID) == null ? "1234" : - ((String) getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SIG_KID)).trim(); - } - - /** - * Key ID of the public key of the corresponding private key used for signing. - * - * @return signing certificate Kid in sandbox environment - */ - public String getOBIdnRetrieverSandboxCertificateKid() { - - return getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SANDBOX_KID) == null ? "5678" : - ((String) getConfigElementFromKey(OpenBankingConstants.OB_IDN_RETRIEVER_SANDBOX_KID)).trim(); - } - - /** - * JWKS Retriever Size Limit for JWS Signature Handling. - * - * @return - */ - public String getJwksRetrieverSizeLimit() { - - return getConfigElementFromKey(OpenBankingConstants.JWKS_RETRIEVER_SIZE_LIMIT) == null ? "51200" : - ((String) getConfigElementFromKey(OpenBankingConstants.JWKS_RETRIEVER_SIZE_LIMIT)).trim(); - } - - /** - * JWKS Retriever Connection Timeout for JWS Signature Handling. - * - * @return - */ - public String getJwksRetrieverConnectionTimeout() { - - return getConfigElementFromKey(OpenBankingConstants.JWKS_RETRIEVER_CONN_TIMEOUT) == null ? "2000" : - ((String) getConfigElementFromKey(OpenBankingConstants.JWKS_RETRIEVER_CONN_TIMEOUT)).trim(); - } - - /** - * JWKS Retriever Read Timeout for JWS Signature Handling. - * - * @return - */ - public String getJwksRetrieverReadTimeout() { - - return getConfigElementFromKey(OpenBankingConstants.JWKS_RETRIEVER_READ_TIMEOUT) == null ? "2000" : - ((String) getConfigElementFromKey(OpenBankingConstants.JWKS_RETRIEVER_READ_TIMEOUT)).trim(); - } - - /** - * Check if Jws Signature Validation is enabled. - * - * @return if Jws Signature Validation is enabled - */ - public boolean isJwsSignatureValidationEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.JWS_SIG_VALIDATION_ENABLE) != null && - Boolean.parseBoolean(((String) getConfigElementFromKey(OpenBankingConstants.JWS_SIG_VALIDATION_ENABLE)) - .trim()); - } - - /** - * Check if Jws Response signing is enabled. - * - * @return if Jws message Response is enabled - */ - public boolean isJwsResponseSigningEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.JWS_RESP_SIGNING_ENABLE) != null && - Boolean.parseBoolean(((String) getConfigElementFromKey(OpenBankingConstants.JWS_RESP_SIGNING_ENABLE)) - .trim()); - } - - /** - * Jws Request Signing allowed algorithms. - * - * @return - */ - public List getJwsRequestSigningAlgorithms() { - - Object allowedAlgorithmsElement = getConfigElementFromKey( - OpenBankingConstants.JWS_SIG_VALIDATION_ALGO) == null ? new String[] {"PS256"} : - (getConfigElementFromKey(OpenBankingConstants.JWS_SIG_VALIDATION_ALGO)); - List allowedAlgorithmsList = new ArrayList<>(); - if (allowedAlgorithmsElement instanceof ArrayList) { - allowedAlgorithmsList.addAll((ArrayList) allowedAlgorithmsElement); - } else if (allowedAlgorithmsElement instanceof String) { - allowedAlgorithmsList.add((String) allowedAlgorithmsElement); - } - return allowedAlgorithmsList.isEmpty() ? Arrays.asList("PS256") : allowedAlgorithmsList; - } - - /** - * Jws Response Signing allowed algorithm. - * - * @return - */ - public String getJwsResponseSigningAlgorithm() { - - return getConfigElementFromKey(OpenBankingConstants.JWS_RESP_SIGNING_ALGO) == null ? "PS256" : - ((String) getConfigElementFromKey(OpenBankingConstants.JWS_RESP_SIGNING_ALGO)).trim(); - } - - public Map getAuthWorkerConfig() { - return authWorkerConfig; - } - - /** - * Method to check if the Dispute Resolution feature is enabled. - * @return true if Dispute Resolution is enabled. - */ - public boolean isDisputeResolutionEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.IS_DISPUTE_RESOLUTION_ENABLED) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.IS_DISPUTE_RESOLUTION_ENABLED).toString().trim())); - } - - /** - * Method to check if the Dispute Resolution feature is enabled for Non Error Scenarios. - * @return true if Dispute Resolution feature is enabled for Non Error scenarios - */ - public boolean isNonErrorDisputeDataPublishingEnabled() { - - return getConfigElementFromKey(OpenBankingConstants.PUBLISH_NON_ERROR_DISPUTE_DATA) == null ? false : - (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.PUBLISH_NON_ERROR_DISPUTE_DATA).toString().trim())); - } - - /** - * Method to get maximum length for publish response body in Dispute Resolution Feature. - * @return maximum length for response body. - */ - public int getMaxResponseBodyLength() { - - return getConfigElementFromKey(OpenBankingConstants.MAX_RESPONSE_BODY_LENGTH) - == null ? 4096 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.MAX_RESPONSE_BODY_LENGTH).toString().trim())); - } - - /** - * Method to get maximum length for publish request body in Dispute Resolution Feature. - * @return maximum length for request body. - */ - public int getMaxRequestBodyLength() { - - return getConfigElementFromKey(OpenBankingConstants.MAX_REQUEST_BODY_LENGTH) - == null ? 4096 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.MAX_REQUEST_BODY_LENGTH).toString().trim())); - } - - /** - *Method to get maximum length for publish headers in Dispute Resolution Feature. - * @return maximum length for headers. - */ - public int getMaxHeaderLength() { - - return getConfigElementFromKey(OpenBankingConstants.MAX_HEADER_LENGTH) - == null ? 2048 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.MAX_HEADER_LENGTH).toString().trim())); - } - - /** - * Method to determine real-time event notification feature is enabled or not from the configurations. - * - * @return boolean value indicating the state - */ - public boolean isRealtimeEventNotificationEnabled() { - return getConfigElementFromKey(OpenBankingConstants.REALTIME_EVENT_NOTIFICATION_ENABLED) != null - && (Boolean.parseBoolean(getConfigElementFromKey( - OpenBankingConstants.REALTIME_EVENT_NOTIFICATION_ENABLED).toString().trim())); - } - - /** - * Method to get periodic Cron expression config for realtime event notifications scheduler. - * - * @return String Cron expression to trigger the Cron job for real-time event notification - */ - public String getRealtimeEventNotificationSchedulerCronExpression() { - return getConfigElementFromKey(OpenBankingConstants.PERIODIC_CRON_EXPRESSION) - == null ? "0 0/1 0 ? * * *" : (String) getConfigElementFromKey( - OpenBankingConstants.PERIODIC_CRON_EXPRESSION); - } - - /** - * Method to get TIMEOUT_IN_SECONDS config for realtime event notifications. - * - * @return integer timeout for the HTTP Client's POST requests - */ - public int getRealtimeEventNotificationTimeoutInSeconds() { - return getConfigElementFromKey(OpenBankingConstants.TIMEOUT_IN_SECONDS) - == null ? 60 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.TIMEOUT_IN_SECONDS).toString().trim())); - } - - /** - * Method to get MAX_RETRIES config for realtime event notifications. - * - * @return integer maximum number of retries to the retry policy in real-time notification sender - */ - public int getRealtimeEventNotificationMaxRetries() { - return getConfigElementFromKey(OpenBankingConstants.MAX_RETRIES) - == null ? 5 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.MAX_RETRIES).toString().trim())); - } - - /** - * Method to get INITIAL_BACKOFF_TIME_IN_SECONDS config for realtime event notifications. - * - * @return integer start waiting time for the retry policy before the first retry - */ - public int getRealtimeEventNotificationInitialBackoffTimeInSeconds() { - return getConfigElementFromKey(OpenBankingConstants.INITIAL_BACKOFF_TIME_IN_SECONDS) - == null ? 60 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.INITIAL_BACKOFF_TIME_IN_SECONDS).toString().trim())); - } - - /** - * Method to get BACKOFF_FUNCTION config for realtime event notifications. - * Function name should be "EX", "CONSTANT" or "LINEAR". - * - * @return string indicating the retry function - */ - public String getRealtimeEventNotificationBackoffFunction() { - return getConfigElementFromKey(OpenBankingConstants.BACKOFF_FUNCTION) - == null ? "EX" : (String) getConfigElementFromKey( - OpenBankingConstants.BACKOFF_FUNCTION); - } - - /** - * Method to get CIRCUIT_BREAKER_OPEN_TIMEOUT_IN_SECONDS config for realtime event notifications. - * - * @return integer timeout to break the retrying process and make that notification as ERR - */ - public int getRealtimeEventNotificationCircuitBreakerOpenTimeoutInSeconds() { - return getConfigElementFromKey(OpenBankingConstants.CIRCUIT_BREAKER_OPEN_TIMEOUT_IN_SECONDS) - == null ? 600 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.CIRCUIT_BREAKER_OPEN_TIMEOUT_IN_SECONDS).toString().trim())); - } - - /** - * Method to get EVENT_NOTIFICATION_THREADPOOL_SIZE config for realtime event notifications. - * - * @return integer fix size to set the Thread Pool size in the real-time event notification sender - */ - public int getEventNotificationThreadpoolSize() { - return getConfigElementFromKey(OpenBankingConstants.EVENT_NOTIFICATION_THREADPOOL_SIZE) - == null ? 20 : (Integer.parseInt(getConfigElementFromKey( - OpenBankingConstants.EVENT_NOTIFICATION_THREADPOOL_SIZE).toString().trim())); - } - - /** - * Method to get EVENT_NOTIFICATION_GENERATOR config for event notifications. - * - * @return String class name of the event notification generator to generate the event notification payload - */ - public String getEventNotificationGenerator() { - return getConfigElementFromKey(OpenBankingConstants.EVENT_NOTIFICATION_GENERATOR) == null ? - "com.wso2.openbanking.accelerator.event.notifications.service.service.DefaultEventNotificationGenerator" - : (String) getConfigElementFromKey(OpenBankingConstants.EVENT_NOTIFICATION_GENERATOR); - } - - /** - * Method to get REALTIME_EVENT_NOTIFICATION_REQUEST_GENERATOR config for realtime event notifications. - * - * @return String class path of the realtime event notification payload generator - */ - public String getRealtimeEventNotificationRequestGenerator() { - return getConfigElementFromKey(OpenBankingConstants.REALTIME_EVENT_NOTIFICATION_REQUEST_GENERATOR) == null ? - "com.wso2.openbanking.accelerator.event.notifications.service." + - "realtime.service.DefaultRealtimeEventNotificationRequestGenerator" - : (String) getConfigElementFromKey(OpenBankingConstants.REALTIME_EVENT_NOTIFICATION_REQUEST_GENERATOR); - } - - /** - * Method to get software environment identification SSA property name. - * - * @return String software environment identification SSA property name. - */ - public String getSoftwareEnvIdentificationSSAPropertyName() { - return getConfigElementFromKey(OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_PROPERTY_NAME) == null ? - OpenBankingConstants.SOFTWARE_ENVIRONMENT : (String) getConfigElementFromKey( - OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_PROPERTY_NAME); - } - - /** - * Method to get software environment identification value for sandbox in SSA. - * - * @return String software environment identification value for sandbox. - */ - public String getSoftwareEnvIdentificationSSAPropertyValueForSandbox() { - return getConfigElementFromKey(OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX) == null ? - "sandbox" : (String) getConfigElementFromKey( - OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX); - } - - /** - * Method to get software environment identification value for production in SSA. - * - * @return String software environment identification value for production. - */ - public String getSoftwareEnvIdentificationSSAPropertyValueForProduction() { - return getConfigElementFromKey( - OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_PRODUCTION) == null ? - "production" : (String) getConfigElementFromKey( - OpenBankingConstants.DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_PRODUCTION); - } - - /** - * Get config related for checking whether PSU is a federated user or not. - * - * @return Boolean value indicating whether PSU is a federated user or not - */ - public boolean isPSUFederated() { - - Object isPSUFederated = getConfigElementFromKey(OpenBankingConstants.IS_PSU_FEDERATED); - if (isPSUFederated != null) { - return Boolean.parseBoolean((String) isPSUFederated); - } else { - return false; - } - } - - /** - * Get Federated PSU IDP Name. - * - * @return String Federated IDP name - */ - public String getFederatedIDPName() { - - return getConfigElementFromKey(OpenBankingConstants.PSU_FEDERATED_IDP_NAME) == null ? "" : - ((String) getConfigElementFromKey(OpenBankingConstants.PSU_FEDERATED_IDP_NAME)).trim(); - } - - /** - * Method to get the value Idempotency enable configuration. - * @return - */ - public boolean isIdempotencyValidationEnabled() { - return getConfigElementFromKey(OpenBankingConstants.IDEMPOTENCY_IS_ENABLED) != null && - Boolean.parseBoolean(((String) - getConfigElementFromKey(OpenBankingConstants.IDEMPOTENCY_IS_ENABLED)).trim()); - } - - /** - * Method to get the value Idempotency allowed time configuration. - * @return - */ - public String getIdempotencyAllowedTime() { - return getConfigElementFromKey(OpenBankingConstants.IDEMPOTENCY_ALLOWED_TIME) == null ? "1440" : - (String) getConfigElementFromKey(OpenBankingConstants.IDEMPOTENCY_ALLOWED_TIME); - } - -} diff --git a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java b/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java deleted file mode 100644 index 6f4a6e3f..00000000 --- a/open-banking-accelerator/components/com.wso2.openbanking.accelerator.common/src/main/java/com/wso2/openbanking/accelerator/common/constant/OpenBankingConstants.java +++ /dev/null @@ -1,260 +0,0 @@ -/** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.wso2.openbanking.accelerator.common.constant; - - -/** - * Class containing the constants for Open Banking Common module. - */ -public class OpenBankingConstants { - - public static final String OB_CONFIG_FILE = "open-banking.xml"; - public static final String CARBON_HOME = "carbon.home"; - - public static final String OB_CONFIG_QNAME = "http://wso2.org/projects/carbon/open-banking.xml"; - public static final String GATEWAY_CONFIG_TAG = "Gateway"; - public static final String GATEWAY_EXECUTOR_CONFIG_TAG = "OpenBankingGatewayExecutors"; - public static final String EVENT_CONFIG_TAG = "Event"; - public static final String EVENT_EXECUTOR_CONFIG_TAG = "EventExecutors"; - public static final String EXECUTOR_CONFIG_TAG = "Executor"; - public static final String DCR_CONFIG_TAG = "DCR"; - public static final String DCR_REGISTRATION_CONFIG_TAG = "RegistrationRequestParams"; - public static final String DCR_REGISTRATION_PARAM_ALLOWED_VALUE_TAG = "AllowedValues"; - public static final String REGULATORY = "regulatory"; - public static final String DATA_PUBLISHING_CONFIG_TAG = "DataPublishing"; - public static final String THRIFT_CONFIG_TAG = "Thrift"; - public static final String STREAMS_CONFIG_TAG = "Streams"; - public static final String ATTRIBUTE_CONFIG_TAG = "Attribute"; - public static final String REQUIRED = "required"; - public static final String ATTRIBUTE_TYPE = "type"; - public static final String DEFAULT_MIDNIGHT_CRON = "0 0 0 * * ?"; - public static final String DEFAULT_STATUS_FOR_EXPIRED_CONSENTS = "Expired"; - public static final String DEFAULT_STATUS_FOR_REVOKED_CONSENTS = "Revoked"; - public static final String IS_CONSENT_REVOCATION_FLOW = "IS_CONSENT_REVOCATION_FLOW"; - - public static final String SIGNATURE_ALGORITHMS = "SignatureValidation.AllowedAlgorithms.Algorithm"; - public static final String AUTH_SERVLET_EXTENSION = "Identity.AuthenticationWebApp.ServletExtension"; - public static final String COMMON_IDENTITY_CACHE_ACCESS_EXPIRY = "Common.Identity.Cache.CacheAccessExpiry"; - public static final String COMMON_IDENTITY_CACHE_MODIFY_EXPIRY = "Common.Identity.Cache.CacheModifiedExpiry"; - public static final String JWKS_ENDPOINT_NAME = "DCR.JWKSEndpointName"; - public static final String SP_METADATA_FILTER_EXTENSION = - "Identity.ApplicationInformationEndpoint.SPMetadataFilterExtension"; - public static final String CIBA_SERVLET_EXTENSION = "Identity.CIBAAuthenticationEndpointWebApp.ServletExtension"; - public static final String DCR_JWKS_CONNECTION_TIMEOUT = "DCR.JWKS-Retriever.ConnectionTimeout"; - public static final String DCR_JWKS_READ_TIMEOUT = "DCR.JWKS-Retriever.ReadTimeout"; - public static final String DCR_USE_SOFTWAREID_AS_APPNAME = "DCR.UseSoftwareIdAsAppName"; - public static final String DCR_JWKS_NAME = "DCR.JWKSEndpointName"; - public static final String DCR_APPLICATION_NAME_KEY = "DCR.ApplicationName"; - public static final String OB_KM_NAME = "KeyManagerName"; - public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_PROPERTY_NAME = - "DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyName"; - public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_SANDBOX = - "DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyValueForSandbox"; - public static final String DCR_SOFTWARE_ENV_IDENTIFICATION_VALUE_FOR_PRODUCTION = - "DCR.RegistrationRequestParams.SoftwareEnvironmentIdentification.PropertyValueForProduction"; - - public static final String APIM_APPCREATION = "DCR.APIMRESTEndPoints.AppCreation"; - public static final String APIM_KEYGENERATION = "DCR.APIMRESTEndPoints.KeyGeneration"; - public static final String APIM_GETAPIS = "DCR.APIMRESTEndPoints.RetrieveAPIS"; - public static final String APIM_SUBSCRIBEAPIS = "DCR.APIMRESTEndPoints.SubscribeAPIs"; - public static final String APIM_GETSUBSCRIPTIONS = "DCR.APIMRESTEndPoints.RetrieveSubscribedAPIs"; - public static final String REGULATORY_APINAMES = "RegulatoryAPINames"; - public static final String REGULATORY_API = "API"; - public static final String SOFTWARE_ROLES = "software_roles"; - public static final String SOFTWARE_STATEMENT = "software_statement"; - public static final String SOFTWARE_ENVIRONMENT = "software_environment"; - public static final String TOKEN_ENDPOINT = "DCR.TokenEndpoint"; - public static final String STORE_HOSTNAME = "PublisherURL"; - - public static final String JDBC_PERSISTENCE_CONFIG = "JDBCPersistenceManager.DataSource.Name"; - public static final String DB_CONNECTION_VERIFICATION_TIMEOUT = - "JDBCPersistenceManager.ConnectionVerificationTimeout"; - public static final String JDBC_RETENTION_DATA_PERSISTENCE_CONFIG = - "JDBCRetentionDataPersistenceManager.DataSource.Name"; - public static final String RETENTION_DATA_DB_CONNECTION_VERIFICATION_TIMEOUT = - "JDBCRetentionDataPersistenceManager.ConnectionVerificationTimeout"; - - public static final String TRUSTSTORE_CONF_TYPE_DEFAULT = "JKS"; - public static final String CLIENT_CERT_CACHE = "ClientCertCache"; - public static final String OB_CACHE_MANAGER = "OB_CERTIFICATE_CACHE"; - public static final String CERTIFICATE_REVOCATION_VALIDATION_RETRY_COUNT = "Gateway" + - ".CertificateManagement.CertificateRevocationValidationRetryCount"; - public static final String CERTIFICATE_REVOCATION_VALIDATION_CONNECT_TIMEOUT = "Gateway" + - ".CertificateManagement.CertificateRevocationValidationConnectTimeout"; - public static final String CERTIFICATE_REVOCATION_VALIDATION_CONNECTION_REQUEST_TIMEOUT = "Gateway" + - ".CertificateManagement.CertificateRevocationValidationConnectionRequestTimeout"; - public static final String CERTIFICATE_REVOCATION_VALIDATION_SOCKET_TIMEOUT = "Gateway" + - ".CertificateManagement.CertificateRevocationValidationSocketTimeout"; - public static final String CERTIFICATE_REVOCATION_VALIDATION_ENABLED = "Gateway" + - ".CertificateManagement.CertificateRevocationValidationEnabled"; - public static final String CERTIFICATE_REVOCATION_VALIDATION_EXCLUDED_ISSUERS = "Gateway" + - ".CertificateManagement.RevocationValidationExcludedIssuers.IssuerDN"; - public static final String TPP_VALIDATION_SERVICE_IMPL_CLASS = "Gateway" + - ".TPPManagement.TPPValidation.ServiceImplClass"; - public static final String TPP_VALIDATION_ENABLED = "Gateway" + - ".TPPManagement.TPPValidation.Enabled"; - public static final String PSD2_ROLE_VALIDATION_ENABLED = "Gateway" + - ".TPPManagement.PSD2RoleValidation.Enabled"; - public static final String CERTIFICATE_REVOCATION_PROXY_ENABLED = "Gateway" + - ".CertificateManagement.CertificateRevocationProxy.Enabled"; - public static final String CERTIFICATE_REVOCATION_PROXY_HOST = "Gateway" + - ".CertificateManagement.CertificateRevocationProxy.ProxyHost"; - public static final String CERTIFICATE_REVOCATION_PROXY_PORT = "Gateway" + - ".CertificateManagement.CertificateRevocationProxy.ProxyPort"; - public static final String TRANSPORT_CERT_ISSUER_VALIDATION_ENABLED = "Gateway" + - ".CertificateManagement.TransportCertIssuerValidationEnabled"; - public static final String TRUSTSTORE_DYNAMIC_LOADING_INTERVAL = "Gateway" + - ".CertificateManagement.TrustStoreDynamicLoadingInterval"; - public static final String CLIENT_CERTIFICATE_CACHE_EXPIRY = "Gateway" + - ".CertificateManagement.ClientCertificateCacheExpiry"; - public static final String TPP_VALIDATION_CACHE_EXPIRY = "Gateway" + - ".TPPManagement.TPPValidationCacheExpiry"; - public static final String TPP_VALIDATION_SERVICE_AISP_SCOPE_REGEX = "Gateway" + - ".CertificateManagement.TPPValidationService.ScopeRegexPatterns.AISP"; - public static final String TPP_VALIDATION_SERVICE_PISP_SCOPE_REGEX = "Gateway" + - ".CertificateManagement.TPPValidationService.ScopeRegexPatterns.PISP"; - public static final String TPP_VALIDATION_SERVICE_CBPII_SCOPE_REGEX = "Gateway" + - ".CertificateManagement.TPPValidationService.ScopeRegexPatterns.CBPII"; - public static final int PAGINATION_LIMIT_DEFAULT = 25; - public static final int PAGINATION_OFFSET_DEFAULT = 0; - public static final String CONSENT_CONFIG_TAG = "Consent"; - public static final String AUTHORIZE_STEPS_CONFIG_TAG = "AuthorizeSteps"; - public static final String STEP_CONFIG_TAG = "Step"; - public static final String ALLOWED_SCOPES_CONFIG_TAG = "AllowedScopes"; - public static final String SCOPE_CONFIG_TAG = "Scope"; - public static final String REVOCATION_VALIDATORS_CONFIG_TAG = "RevocationValidators"; - public static final String REVOCATION_VALIDATOR_CONFIG_TAG = "RevocationValidator"; - public static final String TPP_MANAGEMENT_CONFIG_TAG = "TPPManagement"; - public static final String CONNECTION_POOL_MAX_CONNECTIONS = "HTTPConnectionPool.MaxConnections"; - public static final String CONNECTION_POOL_MAX_CONNECTIONS_PER_ROUTE = "HTTPConnectionPool.MaxConnectionsPerRoute"; - public static final String PUSH_AUTH_EXPIRY_TIME = "PushAuthorisation.ExpiryTime"; - public static final String PUSH_AUTH_REQUEST_URI_SUBSTRING = "PushAuthorisation.RequestUriSubString"; - - public static final String CONSENT_PERIODICAL_EXPIRATION_CRON = "Consent.PeriodicalExpiration.CronValue"; - public static final String STATUS_FOR_EXPIRED_CONSENT = "Consent.PeriodicalExpiration.ExpiredConsentStatusValue"; - public static final String IS_CONSENT_PERIODICAL_EXPIRATION_ENABLED = "Consent.PeriodicalExpiration.Enabled"; - public static final String IS_CONSENT_AMENDMENT_HISTORY_ENABLED = "Consent.AmendmentHistory.Enabled"; - public static final String ELIGIBLE_STATUSES_FOR_CONSENT_EXPIRY = - "Consent.PeriodicalExpiration.EligibleStatuses"; - public static final String CONSENT_ID_CLAIM_NAME = "Identity.ConsentIDClaimName"; - - public static final String EVENT_QUEUE_SIZE = "Event.QueueSize"; - public static final String EVENT_WORKER_THREAD_COUNT = "Event.WorkerThreadCount"; - public static final String EVENT_EXECUTOR = "Event.EventExecutor"; - - // Data Retention Constants - public static final String IS_CONSENT_DATA_RETENTION_ENABLED = "Consent.DataRetention.Enabled"; - public static final String IS_CONSENT_RETENTION_DATA_DB_SYNC_ENABLED = "Consent.DataRetention.DBSyncEnabled"; - public static final String CONSENT_RETENTION_DATA_DB_SYNC_CRON = "Consent.DataRetention.CronValue"; - - // Service Activator Constants - public static final String SERVICE_ACTIVATOR_TAG = "ServiceActivator"; - public static final String SA_SUBSCRIBERS_TAG = "Subscribers"; - public static final String SA_SUBSCRIBER_TAG = "Subscriber"; - - //JWS handling related constants - public static final String JWS_SIG_VALIDATION_ENABLE = "JwsSignatureConfiguration.SignatureValidation.Enable"; - public static final String JWS_SIG_VALIDATION_ALGO = - "JwsSignatureConfiguration.SignatureValidation.AllowedAlgorithms"; - public static final String JWS_RESP_SIGNING_ENABLE = "JwsSignatureConfiguration.ResponseSigning.Enable"; - public static final String JWS_RESP_SIGNING_ALGO = "JwsSignatureConfiguration.ResponseSigning.AllowedAlgorithm"; - - // Open Banking Identity Manager - public static final String OB_IDN_RETRIEVER_SIG_ALIAS = "OBIdentityRetriever.Server.SigningCertificateAlias"; - public static final String OB_IDN_RETRIEVER_SANDBOX_SIG_ALIAS = - "OBIdentityRetriever.Server.SandboxSigningCertificateAlias"; - public static final String OB_IDN_RETRIEVER_SIG_KID = "OBIdentityRetriever.Server.SigningCertificateKid"; - public static final String OB_IDN_RETRIEVER_SANDBOX_KID = "OBIdentityRetriever.Server.SandboxCertificateKid"; - public static final String JWKS_RETRIEVER_SIZE_LIMIT = "OBIdentityRetriever.JWKSRetriever.SizeLimit"; - public static final String JWKS_RETRIEVER_CONN_TIMEOUT = "OBIdentityRetriever.JWKSRetriever.ConnectionTimeout"; - public static final String JWKS_RETRIEVER_READ_TIMEOUT = "OBIdentityRetriever.JWKSRetriever.ReadTimeout"; - - // Key Manager Additional Property Configs - public static final String KEY_MANAGER_CONFIG_TAG = "KeyManager"; - public static final String KEY_MANAGER_ADDITIONAL_PROPERTIES_CONFIG_TAG = "KeyManagerAdditionalProperties"; - public static final String PROPERTY_CONFIG_TAG = "Property"; - public static final String OB_KEYMANAGER_EXTENSION_IMPL = - "KeyManager.KeyManagerExtensionImpl"; - - //OB Event Notifications Constants - public static final String TOKEN_ISSUER = "OBEventNotifications.TokenIssuer"; - public static final String MAX_SETS_TO_RETURN = "OBEventNotifications.NumberOfSetsToReturn"; - public static final String SIGNING_ALIAS = "OBEventNotifications.SigningAlias"; - public static final String IS_SUB_CLAIM_INCLUDED = "OBEventNotifications.PollingResponseParams.IsSubClaimAvailable"; - public static final String IS_TXN_CLAIM_INCLUDED = "OBEventNotifications.PollingResponseParams.IsTxnClaimAvailable"; - public static final String IS_TOE_CLAIM_INCLUDED = "OBEventNotifications.PollingResponseParams.IsToeClaimAvailable"; - public static final String EVENT_CREATION_HANDLER = "OBEventNotifications.EventCreationHandler"; - public static final String EVENT_POLLING_HANDLER = "OBEventNotifications.EventPollingHandler"; - public static final String EVENT_SUBSCRIPTION_HANDLER = "OBEventNotifications.EventSubscriptionHandler"; - public static final String EVENT_NOTIFICATION_GENERATOR = "OBEventNotifications.NotificationGenerator"; - public static final String AUTHENTICATION_WORKER_LIST_TAG = "AuthenticationWorkers"; - public static final String AUTHENTICATION_WORKER_TAG = "AuthenticationWorker"; - - // Dispute Resolution Implementation Constants - public static final String IS_DISPUTE_RESOLUTION_ENABLED = "DataPublishing.DisputeResolution.Enabled"; - public static final String PUBLISH_NON_ERROR_DISPUTE_DATA = "DataPublishing" + - ".DisputeResolution.PublishNonErrorDisputeResolutionData"; - public static final String MAX_REQUEST_BODY_LENGTH = "DataPublishing.DisputeResolution.MaxRequestBodyLength"; - public static final String MAX_RESPONSE_BODY_LENGTH = "DataPublishing.DisputeResolution.MaxResponseBodyLength"; - public static final String MAX_HEADER_LENGTH = "DataPublishing.DisputeResolution.MaxHeaderLength"; - public static final String DISPUTE_RESOLUTION_STREAM_NAME = "DisputeResolutionStream"; - public static final String DISPUTE_RESOLUTION_STREAM_VERSION = "1.0.0"; - public static final String REQUEST_BODY = "requestBody"; - public static final String HTTP_METHOD = "httpMethod"; - public static final String STATUS_CODE = "statusCode"; - public static final String RESPONSE_BODY = "responseBody"; - public static final String ELECTED_RESOURCE = "electedResource"; - public static final String HEADERS = "headers"; - public static final String TIMESTAMP = "timestamp"; - - public static final String CUTOFF_DATE_ENABLED = "ConsentManagement.PaymentRestrictions.CutOffDateTime.Enabled"; - public static final String CUTOFF_DATE_POLICY = "ConsentManagement.PaymentRestrictions.CutOffDateTime" + - ".CutOffDateTimePolicy"; - public static final String ZONE_ID = "ZoneId"; - public static final String DAILY_CUTOFF = "ConsentManagement.PaymentRestrictions.CutOffDateTime" + - ".DailyCutOffTime"; - public static final String EXPECTED_EXECUTION_TIME = "ConsentManagement.PaymentRestrictions.CutOffDateTime" + - ".ExpectedExecutionTime"; - public static final String EXPECTED_SETTLEMENT_TIME = "ConsentManagement.PaymentRestrictions.CutOffDateTime" + - ".ExpectedSettlementTime"; - - // Realtime Event Notification Constants - public static final String REALTIME_EVENT_NOTIFICATION_ENABLED = "RealtimeEventNotification.Enable"; - public static final String PERIODIC_CRON_EXPRESSION = "RealtimeEventNotification.PeriodicCronExpression"; - public static final String TIMEOUT_IN_SECONDS = "RealtimeEventNotification.TimeoutInSeconds"; - public static final String MAX_RETRIES = "RealtimeEventNotification.MaxRetries"; - public static final String INITIAL_BACKOFF_TIME_IN_SECONDS - = "RealtimeEventNotification.InitialBackoffTimeInSeconds"; - public static final String BACKOFF_FUNCTION = "RealtimeEventNotification.BackoffFunction"; - public static final String CIRCUIT_BREAKER_OPEN_TIMEOUT_IN_SECONDS - = "RealtimeEventNotification.CircuitBreakerOpenTimeoutInSeconds"; - public static final String EVENT_NOTIFICATION_THREADPOOL_SIZE - = "RealtimeEventNotification.EventNotificationThreadPoolSize"; - public static final String REALTIME_EVENT_NOTIFICATION_REQUEST_GENERATOR - = "RealtimeEventNotification.RequestGenerator"; - public static final String CONTENT_TYPE_TAG = "Content-Type"; - public static final String JSON_CONTENT_TYPE = "application/json"; - public static final String SP_API_PATH = "/stores/query"; - public static final String APP_NAME_CC = "appName"; - public static final String QUERY = "query"; - public static final String IS_PSU_FEDERATED = "PSUFederatedAuthentication.Enabled"; - public static final String PSU_FEDERATED_IDP_NAME = "PSUFederatedAuthentication.IDPName"; - public static final String IDEMPOTENCY_IS_ENABLED = "Consent.Idempotency.Enabled"; - public static final String IDEMPOTENCY_ALLOWED_TIME = "Consent.Idempotency.AllowedTimeDuration"; -} diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java deleted file mode 100644 index c3d3993f..00000000 --- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyConstants.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency; - -/** - * Constants related to idempotency operations. - */ -public class IdempotencyConstants { - - public static final String CONTENT_TYPE_TAG = "content-type"; - public static final String X_IDEMPOTENCY_KEY = "x-idempotency-key"; - public static final String IDEMPOTENCY_KEY_NAME = "IdempotencyKey"; - public static final String ISO_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX"; - public static final String ERROR_PAYLOAD_NOT_SIMILAR = "Payloads are not similar. Hence this is not a valid" + - " idempotent request"; - public static final String ERROR_AFTER_ALLOWED_TIME = "Request received after the allowed time., Hence this is" + - " not a valid idempotent request"; - public static final String ERROR_MISMATCHING_CLIENT_ID = "Client ID sent in the request does not match with the" + - " client ID in the retrieved consent. Hence this is not a valid idempotent request"; - public static final String ERROR_NO_CONSENT_DETAILS = "No consent details found for the consent ID %s, Hence this" + - " is not a valid idempotent request"; - public static final String JSON_COMPARING_ERROR = "Error occurred while comparing JSON payloads"; - public static final String CONSENT_RETRIEVAL_ERROR = "Error while retrieving detailed consent data"; -} diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java deleted file mode 100644 index 19b1d193..00000000 --- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/main/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidator.java +++ /dev/null @@ -1,247 +0,0 @@ -/** - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser; -import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException; -import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder; -import com.wso2.openbanking.accelerator.consent.extensions.manage.model.ConsentManageData; -import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource; -import com.wso2.openbanking.accelerator.consent.mgt.service.ConsentCoreService; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.IOException; -import java.util.ArrayList; - -/** - * Class to handle idempotency related operations. - */ -public class IdempotencyValidator { - - private static final Log log = LogFactory.getLog(IdempotencyValidator.class); - private static final ConsentCoreService consentCoreService = ConsentExtensionsDataHolder.getInstance() - .getConsentCoreService(); - - /** - * Method to check whether the request is idempotent. - * This method will first check whether idempotency validation is enabled. After that it will validate whether - * required parameters for validation is present. - * For validation, need to check whether the idempotency key values is present as a consent attribute, if present - * the consent will be retrieved. Finally following conditions will be validated. - * - Whether the client id sent in the request and client id retrieved from the database are equal - * - Whether the difference between two dates is less than the configured time - * - Whether payloads are equal - * - * @param consentManageData Consent Manage Data - * @return IdempotencyValidationResult - */ - public IdempotencyValidationResult validateIdempotency(ConsentManageData consentManageData) - throws IdempotencyValidationException { - - if (!OpenBankingConfigParser.getInstance().isIdempotencyValidationEnabled()) { - return new IdempotencyValidationResult(false, false); - } - // If request is empty then cannot proceed with idempotency validation - if (consentManageData.getPayload() == null) { - log.error("Request payload is empty. Hence cannot proceed with idempotency validation"); - return new IdempotencyValidationResult(false, false); - } - // If client id is empty then cannot proceed with idempotency validation - if (StringUtils.isBlank(consentManageData.getClientId())) { - log.error("Client ID is empty. Hence cannot proceed with idempotency validation"); - return new IdempotencyValidationResult(false, false); - } - String idempotencyKeyValue = consentManageData.getHeaders().get(getIdempotencyHeaderName()); - // If idempotency key value is empty then cannot proceed with idempotency validation - if (StringUtils.isBlank(idempotencyKeyValue)) { - log.error("Idempotency Key Valueis empty. Hence cannot proceed with idempotency validation"); - return new IdempotencyValidationResult(false, false); - } - try { - String idempotencyKeyName = getIdempotencyAttributeName(consentManageData.getRequestPath()); - // Retrieve consent ids that have the idempotency key name and value as attribute - ArrayList consentIds = IdempotencyValidationUtils - .getConsentIdsFromIdempotencyKey(idempotencyKeyName, idempotencyKeyValue); - // Check whether the consent id list is not empty. If idempotency key exists in the database then - // the consent Id list will be not empty. - if (!consentIds.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug(String.format("Idempotency Key %s exists in the database. Hence this is an" + - " idempotent request", idempotencyKeyValue)); - } - for (String consentId : consentIds) { - DetailedConsentResource consentRequest = consentCoreService.getDetailedConsent(consentId); - if (consentRequest != null) { - return validateIdempotencyConditions(consentManageData, consentRequest); - } else { - String errorMsg = String.format(IdempotencyConstants.ERROR_NO_CONSENT_DETAILS, consentId); - log.error(errorMsg); - throw new IdempotencyValidationException(errorMsg); - } - } - } - } catch (IOException e) { - log.error(IdempotencyConstants.JSON_COMPARING_ERROR, e); - throw new IdempotencyValidationException(IdempotencyConstants.JSON_COMPARING_ERROR); - } catch (ConsentManagementException e) { - log.error(IdempotencyConstants.CONSENT_RETRIEVAL_ERROR, e); - return new IdempotencyValidationResult(true, false); - } - return new IdempotencyValidationResult(false, false); - } - - /** - * Method to check whether the idempotency conditions are met. - * This method will validate the following conditions. - * - Whether the client id sent in the request and client id retrieved from the database are equal - * - Whether the difference between two dates is less than the configured time - * - Whether payloads are equal - * - * @param consentManageData Consent Manage Data - * @param consentRequest Detailed Consent Resource - * @return IdempotencyValidationResult - */ - private IdempotencyValidationResult validateIdempotencyConditions(ConsentManageData consentManageData, - DetailedConsentResource consentRequest) - throws IdempotencyValidationException, IOException { - // Compare the client ID sent in the request and client id retrieved from the database - // to validate whether the request is received from the same client - if (IdempotencyValidationUtils.isClientIDEqual(consentRequest.getClientID(), consentManageData.getClientId())) { - // Check whether difference between two dates is less than the configured time - if (IdempotencyValidationUtils.isRequestReceivedWithinAllowedTime(getCreatedTimeOfPreviousRequest( - consentManageData.getRequestPath(), consentRequest.getConsentID()))) { - // Compare whether JSON payloads are equal - if (isPayloadSimilar(consentManageData, getPayloadOfPreviousRequest( - consentManageData.getRequestPath(), consentRequest.getConsentID()))) { - log.debug("Payloads are similar and request received within allowed" + - " time. Hence this is a valid idempotent request"); - return new IdempotencyValidationResult(true, true, - consentRequest, consentRequest.getConsentID()); - } else { - log.error(IdempotencyConstants.ERROR_PAYLOAD_NOT_SIMILAR); - throw new IdempotencyValidationException(IdempotencyConstants - .ERROR_PAYLOAD_NOT_SIMILAR); - } - } else { - log.error(IdempotencyConstants.ERROR_AFTER_ALLOWED_TIME); - throw new IdempotencyValidationException(IdempotencyConstants - .ERROR_AFTER_ALLOWED_TIME); - } - } else { - log.error(IdempotencyConstants.ERROR_MISMATCHING_CLIENT_ID); - throw new IdempotencyValidationException(IdempotencyConstants.ERROR_MISMATCHING_CLIENT_ID); - } - } - - /** - * Method to get the Idempotency Attribute Name store in consent Attributes. - * - * @param resourcePath Resource Path - * @return idempotency Attribute Name. - */ - public String getIdempotencyAttributeName(String resourcePath) { - return IdempotencyConstants.IDEMPOTENCY_KEY_NAME; - } - - /** - * Method to get the Idempotency Header Name according to the request. - * - * @return idempotency Header Name. - */ - public String getIdempotencyHeaderName() { - return IdempotencyConstants.X_IDEMPOTENCY_KEY; - } - - /** - * Method to get created time from the Detailed Consent Resource. - * - * @param resourcePath Resource Path - * @param consentId ConsentId - * @return Created Time. - */ - public long getCreatedTimeOfPreviousRequest(String resourcePath, String consentId) { - DetailedConsentResource consentRequest = null; - try { - consentRequest = consentCoreService.getDetailedConsent(consentId); - } catch (ConsentManagementException e) { - log.error(IdempotencyConstants.CONSENT_RETRIEVAL_ERROR, e); - return 0L; - } - if (consentRequest == null) { - return 0L; - } - return consentRequest.getCreatedTime(); - } - - /** - * Method to get payload from previous request. - * - * @param resourcePath Resource Path - * @param consentId ConsentId - * @return Map containing the payload. - */ - public String getPayloadOfPreviousRequest(String resourcePath, String consentId) { - DetailedConsentResource consentRequest = null; - try { - consentRequest = consentCoreService.getDetailedConsent(consentId); - } catch (ConsentManagementException e) { - log.error(IdempotencyConstants.CONSENT_RETRIEVAL_ERROR, e); - return null; - } - if (consentRequest == null) { - return null; - } - return consentRequest.getReceipt(); - } - - /** - * Method to compare whether payloads are equal. - * - * @param consentManageData Consent Manage Data Object - * @param consentReceipt Payload received from database - * @return Whether payloads are equal - */ - public boolean isPayloadSimilar(ConsentManageData consentManageData, String consentReceipt) { - - if (consentManageData.getPayload() == null || consentReceipt == null) { - return false; - } - - JsonNode expectedNode = null; - JsonNode actualNode = null; - try { - ObjectMapper mapper = new ObjectMapper(); - expectedNode = mapper.readTree(consentManageData.getPayload().toString()); - actualNode = mapper.readTree(consentReceipt); - if (log.isDebugEnabled()) { - log.debug(String.format("Expected payload for idempotent request is: %s. But actual payload " + - "received is %s", expectedNode.toString(), actualNode.toString())); - } - } catch (JsonProcessingException e) { - log.error(IdempotencyConstants.JSON_COMPARING_ERROR, e); - return false; - } - return expectedNode.equals(actualNode); - } -} diff --git a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java b/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java deleted file mode 100644 index aa6f09ae..00000000 --- a/open-banking-accelerator/components/consent-management/com.wso2.openbanking.accelerator.consent.extensions/src/test/java/com/wso2/openbanking/accelerator/consent/extensions/common/idempotency/IdempotencyValidatorTests.java +++ /dev/null @@ -1,283 +0,0 @@ -/** - * Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). - * - * WSO2 LLC. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.wso2.openbanking.accelerator.consent.extensions.common.idempotency; - -import com.wso2.openbanking.accelerator.common.config.OpenBankingConfigParser; -import com.wso2.openbanking.accelerator.common.exception.ConsentManagementException; -import com.wso2.openbanking.accelerator.consent.extensions.internal.ConsentExtensionsDataHolder; -import com.wso2.openbanking.accelerator.consent.extensions.manage.model.ConsentManageData; -import com.wso2.openbanking.accelerator.consent.mgt.dao.models.DetailedConsentResource; -import com.wso2.openbanking.accelerator.consent.mgt.service.impl.ConsentCoreServiceImpl; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.testng.PowerMockTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.time.OffsetDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -/** - * Test class for IdempotencyValidator. - */ -@PrepareForTest({OpenBankingConfigParser.class, ConsentExtensionsDataHolder.class}) -@PowerMockIgnore("jdk.internal.reflect.*") -public class IdempotencyValidatorTests extends PowerMockTestCase { - - @Mock - private ConsentManageData consentManageData; - private ConsentCoreServiceImpl consentCoreServiceImpl; - private ArrayList consentIdList; - private String consentId; - private Map configs; - private Map headers; - private static final String CLIENT_ID = "testClientId"; - - private static final String PAYLOAD = "{\n" + - " \"Data\": {\n" + - " \"ReadRefundAccount\": \"Yes\",\n" + - " \"Initiation\": {\n" + - " \"InstructionIdentification\": \"ACME412\",\n" + - " \"EndToEndIdentification\": \"FRESCO.21302.GFX.20\",\n" + - " \"InstructedAmount\": {\n" + - " \"Amount\": \"165.88\",\n" + - " \"Currency\": \"GBP\"\n" + - " },\n" + - " \"CreditorAccount\": {\n" + - " \"SchemeName\": \"UK.OBIE.SortCodeAccountNumber\",\n" + - " \"Identification\": \"08080021325698\",\n" + - " \"Name\": \"ACME Inc\",\n" + - " \"SecondaryIdentification\": \"0002\"\n" + - " },\n" + - " \"RemittanceInformation\": {\n" + - " \"Reference\": \"FRESCO-101\",\n" + - " \"Unstructured\": \"Internal ops code 5120101\"\n" + - " }\n" + - " }\n" + - " },\n" + - " \"Risk\": {\n" + - " }\n" + - " }\n" + - "}"; - - private static final String DIFFERENT_PAYLOAD = "{\n" + - " \"Data\": {\n" + - " \"ReadRefundAccount\": \"No\",\n" + - " \"Initiation\": {\n" + - " \"InstructionIdentification\": \"ACME413\",\n" + - " \"EndToEndIdentification\": \"FRESCO.21302.GFX.20\",\n" + - " \"InstructedAmount\": {\n" + - " \"Amount\": \"165.88\",\n" + - " \"Currency\": \"GBP\"\n" + - " },\n" + - " \"CreditorAccount\": {\n" + - " \"SchemeName\": \"UK.OBIE.SortCodeAccountNumber\",\n" + - " \"Identification\": \"08080021325698\",\n" + - " \"Name\": \"ACME Inc\",\n" + - " \"SecondaryIdentification\": \"0002\"\n" + - " },\n" + - " \"RemittanceInformation\": {\n" + - " \"Reference\": \"FRESCO-101\",\n" + - " \"Unstructured\": \"Internal ops code 5120101\"\n" + - " }\n" + - " }\n" + - " },\n" + - " \"Risk\": {\n" + - " }\n" + - " }\n" + - "}"; - - - @BeforeClass - public void beforeTest() { - configs = new HashMap<>(); - - headers = new HashMap<>(); - headers.put(IdempotencyConstants.X_IDEMPOTENCY_KEY, "123456"); - headers.put(IdempotencyConstants.CONTENT_TYPE_TAG, "application/json"); - - consentManageData = Mockito.mock(ConsentManageData.class); - consentCoreServiceImpl = Mockito.mock(ConsentCoreServiceImpl.class); - - consentId = UUID.randomUUID().toString(); - consentIdList = new ArrayList<>(); - consentIdList.add(consentId); - } - - @BeforeMethod - public void beforeMethod() { - OpenBankingConfigParser openBankingConfigParserMock = PowerMockito.mock(OpenBankingConfigParser.class); - Mockito.doReturn(configs).when(openBankingConfigParserMock).getConfiguration(); - Mockito.doReturn(true).when(openBankingConfigParserMock).isIdempotencyValidationEnabled(); - Mockito.doReturn("1").when(openBankingConfigParserMock).getIdempotencyAllowedTime(); - ConsentExtensionsDataHolder consentExtensionsDataHolderMock = PowerMockito - .mock(ConsentExtensionsDataHolder.class); - - PowerMockito.mockStatic(OpenBankingConfigParser.class); - PowerMockito.when(OpenBankingConfigParser.getInstance()).thenReturn(openBankingConfigParserMock); - - PowerMockito.mockStatic(ConsentExtensionsDataHolder.class); - PowerMockito.when(ConsentExtensionsDataHolder.getInstance()).thenReturn(consentExtensionsDataHolderMock); - PowerMockito.when(consentExtensionsDataHolderMock.getConsentCoreService()).thenReturn(consentCoreServiceImpl); - } - - @Test - public void testValidateIdempotency() throws ConsentManagementException, IdempotencyValidationException { - OffsetDateTime offsetDateTime = OffsetDateTime.now(); - - Mockito.doReturn(consentIdList).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl) - .getDetailedConsent(Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - IdempotencyValidationResult result = new IdempotencyValidator().validateIdempotency(consentManageData); - - Assert.assertTrue(result.isIdempotent()); - Assert.assertTrue(result.isValid()); - Assert.assertNotNull(result.getConsent()); - Assert.assertEquals(consentId, result.getConsentId()); - } - - @Test - public void testValidateIdempotencyWithoutIdempotencyKeyValue() throws IdempotencyValidationException { - - Mockito.doReturn(new HashMap<>()).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - IdempotencyValidationResult result = new IdempotencyValidator().validateIdempotency(consentManageData); - - Assert.assertFalse(result.isIdempotent()); - } - - @Test - public void testValidateIdempotencyWithoutRequest() throws IdempotencyValidationException { - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn("").when(consentManageData).getPayload(); - IdempotencyValidationResult result = new IdempotencyValidator().validateIdempotency(consentManageData); - - Assert.assertFalse(result.isIdempotent()); - } - - @Test - public void testValidateIdempotencyRetrievingAttributesWithException() - throws ConsentManagementException, IdempotencyValidationException { - - Mockito.doThrow(ConsentManagementException.class).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - IdempotencyValidationResult result = new IdempotencyValidator().validateIdempotency(consentManageData); - - Assert.assertFalse(result.isIdempotent()); - } - - @Test - public void testValidateIdempotencyWithoutAttribute() - throws ConsentManagementException, IdempotencyValidationException { - - Mockito.doReturn(new ArrayList<>()).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - IdempotencyValidationResult result = new IdempotencyValidator().validateIdempotency(consentManageData); - - Assert.assertFalse(result.isIdempotent()); - } - - @Test(expectedExceptions = IdempotencyValidationException.class) - public void testValidateIdempotencyWithNullConsentRequest() - throws ConsentManagementException, IdempotencyValidationException { - - Mockito.doReturn(consentIdList).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString()); - new IdempotencyValidator().validateIdempotency(consentManageData); - } - - @Test(expectedExceptions = IdempotencyValidationException.class) - public void testValidateIdempotencyWithNonMatchingClientId() - throws ConsentManagementException, IdempotencyValidationException { - - Mockito.doReturn(consentIdList).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn("sampleClientID").when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - Mockito.doReturn(null).when(consentCoreServiceImpl).getDetailedConsent(Mockito.anyString()); - new IdempotencyValidator().validateIdempotency(consentManageData); - } - - @Test(expectedExceptions = IdempotencyValidationException.class) - public void testValidateIdempotencyAfterAllowedTime() - throws ConsentManagementException, IdempotencyValidationException { - - OffsetDateTime offsetDateTime = OffsetDateTime.now().minusHours(2); - - Mockito.doReturn(consentIdList).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl) - .getDetailedConsent(Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(PAYLOAD).when(consentManageData).getPayload(); - new IdempotencyValidator().validateIdempotency(consentManageData); - } - - @Test(expectedExceptions = IdempotencyValidationException.class) - public void testValidateIdempotencyWithNonMatchingPayload() - throws ConsentManagementException, IdempotencyValidationException { - - OffsetDateTime offsetDateTime = OffsetDateTime.now(); - - Mockito.doReturn(consentIdList).when(consentCoreServiceImpl) - .getConsentIdByConsentAttributeNameAndValue(Mockito.anyString(), Mockito.anyString()); - Mockito.doReturn(getConsent(offsetDateTime.toEpochSecond())).when(consentCoreServiceImpl) - .getDetailedConsent(Mockito.anyString()); - Mockito.doReturn(headers).when(consentManageData).getHeaders(); - Mockito.doReturn(CLIENT_ID).when(consentManageData).getClientId(); - Mockito.doReturn(DIFFERENT_PAYLOAD).when(consentManageData).getPayload(); - new IdempotencyValidator().validateIdempotency(consentManageData); - - } - - private DetailedConsentResource getConsent(long createdTime) { - DetailedConsentResource consent = new DetailedConsentResource(); - consent.setConsentID(consentId); - consent.setReceipt(PAYLOAD); - consent.setClientID(CLIENT_ID); - consent.setCreatedTime(createdTime); - return consent; - } -} diff --git a/pom.xml b/pom.xml index 0cf90812..8eb777e2 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.common - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.gateway - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.identity - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.runtime.identity.authn.filter - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.consent.extensions - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.data.publisher.common - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.keymanager - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.consent.service - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.consent.dao - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.throttler.dao - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.throttler.service - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.event.notifications.service - ${project.version} - - - com.wso2.openbanking.accelerator - com.wso2.openbanking.accelerator.event.notifications.endpoint - ${project.version} - - - - - org.wso2.carbon.identity.inbound.auth.oauth2 - org.wso2.carbon.identity.oauth.dcr - ${identity.inbound.auth.oauth.version} - - - org.wso2.carbon.identity.inbound.auth.oauth2 - org.wso2.carbon.identity.oauth - ${identity.inbound.auth.oauth.version} - - - org.wso2.carbon.identity.inbound.auth.oauth2 - org.wso2.carbon.identity.oauth.client.authn.filter - ${identity.inbound.auth.oauth.version} - - - org.wso2.carbon.identity.inbound.auth.oauth2 - org.wso2.carbon.identity.oauth.ciba - ${identity.inbound.auth.oauth.ciba.version} - - - org.wso2.carbon.identity.outbound.auth.push - org.wso2.carbon.identity.application.authenticator.push - ${identity.outbound.auth.push.authenticator.version} - - - org.wso2.carbon.identity.outbound.auth.push - org.wso2.carbon.identity.application.authenticator.push.device.handler - ${identity.outbound.auth.push.authenticator.version} - - - org.wso2.carbon.identity.outbound.auth.push - org.wso2.carbon.identity.application.authenticator.push.common - ${identity.outbound.auth.push.authenticator.version} - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.mgt - ${carbon.identity.framework.version} - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.authentication.framework - ${carbon.identity.version} - - - org.wso2.carbon.identity.application.auth.basic - org.wso2.carbon.identity.application.authenticator.basicauth - ${carbon.identity.application.authenticator.version} - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.common - ${carbon.identity.framework.version} - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.core - ${carbon.identity.version} - - - org.wso2.carbon.identity.local.auth.api - org.wso2.carbon.identity.local.auth.api.core - ${carbon.identity.local.auth.api.version} - provided - - - org.wso2.carbon.extension.identity.oauth.addons - org.wso2.carbon.identity.oauth2.token.handler.clientauth.mutualtls - ${carbon.identity.clientauth.mutualtls.version} - - - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.authentication.endpoint.util - ${carbon.identity.framework.version} - provided - - - org.apache.tomcat - tomcat-catalina - ${tomcat.catalina.version} - - - org.wso2.carbon - org.wso2.carbon.logging - ${carbon.kernel.ob.version} - - - org.wso2.carbon - org.wso2.carbon.core - ${carbon.kernel.version} - - - org.apache.ws.commons.axiom.wso2 - axiom - ${axiom.wso2.version} - commons-logging commons-logging @@ -430,17 +301,17 @@ org.apache.commons commons-lang3 - ${commons-lang.version} + ${commons-lang3.version} - commons-dbcp - commons-dbcp - ${commons-dbcp.version} + commons-beanutils + commons-beanutils + ${commons.bean.utils.version} - org.wso2.securevault - org.wso2.securevault - ${org.wso2.securevault.version} + net.minidev + json-smart + ${json-smart.version} org.wso2.eclipse.osgi @@ -453,103 +324,60 @@ ${org.osgi.bundle.version} - org.apache.synapse - synapse-core - ${apache.synapse.version} - - - commons-beanutils - commons-beanutils - ${commons.bean.utils.version} - - - org.javassist - javassist - ${javassist.version} - - - io.swagger - swagger-jaxrs - ${swagger-jaxrs.version} - - - io.swagger.parser.v3 - swagger-parser - ${swagger.parser.version} - - - javax.ws.rs - javax.ws.rs-api - ${javax.ws.rs-api.version} - - - org.eclipse.equinox - javax.servlet - ${equinox.javax.servlet.version} + org.wso2.securevault + org.wso2.securevault + ${org.wso2.securevault.version} - - org.jacoco - org.jacoco.agent - runtime - ${jacoco.version} + org.wso2.orbit.com.nimbusds + nimbus-jose-jwt + ${org.wso2.orbit.nimbus.version} - org.testng - testng - ${org.testng.version} - test + org.hibernate + hibernate-validator + ${hibernate-validator.version} - org.mockito - mockito-all - ${mockito.version} - test + org.apache.commons + commons-collections4 + ${commons-collections.version} - com.h2database - h2 - ${h2database.version} + com.github.spotbugs + spotbugs-annotations + ${spotbugs.annotations.version} - org.powermock - powermock-module-testng - ${powermock.version} - test + org.wso2.orbit.org.owasp.encoder + encoder + ${encoder.wso2.version} - org.powermock - powermock-api-mockito - ${powermock.version} - test + org.json.wso2 + json + ${org.json.version} - org.springframework - spring-test - ${spring-web-test.version} - test + org.apache.cxf + cxf-rt-frontend-jaxrs + ${org.apache.cxf.version} - org.springframework - spring-core - ${spring-web.version} - test + io.swagger + swagger-jaxrs + ${swagger-jaxrs.version} - org.apache.cxf - cxf-bundle-jaxrs - ${cxf-bundle-package.version} + javax.ws.rs + javax.ws.rs-api + ${javax.ws.rs-api.version} org.apache.cxf cxf-core ${org.apache.cxf.version} - - org.apache.cxf - cxf-rt-frontend-jaxrs - ${org.apache.cxf.version} - com.fasterxml.jackson.core jackson-databind @@ -561,98 +389,100 @@ ${jackson.databinding.version} - io.swagger - swagger-annotations - ${swagger-annotations.version} + org.springframework + spring-web + ${spring-web.version} - io.swagger.core.v3 - swagger-models - ${swagger.model.version} + org.apache.tomcat + tomcat-catalina + ${apache.tomcat-catalina.version} - javax.ws.rs - jsr311-api - ${javax.ws.rs.version} + org.apache.taglibs + taglibs-standard-impl + ${taglibs-standard-impl.version} - javax.validation - validation-api - ${javax.validation.api.version} + org.wso2.orbit.org.apache.httpcomponents + httpclient + ${orbit.version.commons.httpclient} - org.springframework - spring-web - ${spring-web.version} + org.apache.httpcomponents.wso2 + httpcore + ${orbit.httpcore.version} - net.minidev - json-smart - ${json-smart} + jstl + jstl + ${jstl.version} - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.keymgt - ${org.wso2.carbon.apimgt.version} + org.slf4j + slf4j-api + ${org.slf4j.verison} - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.user.profile - ${carbon.identity.version} + org.eclipse.equinox + javax.servlet + ${equinox.javax.servlet.version} - org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.common.gateway - ${org.wso2.carbon.apimgt.version} + commons-io.wso2 + commons-io + ${commons.io.version} - io.jsonwebtoken - jjwt - ${jjwt.version} + javax.validation + validation-api + ${javax.validation.api.version} - - - org.wso2.carbon.analytics-common - org.wso2.carbon.databridge.agent - ${carbon.analytics.common.version} + org.wso2.orbit.org.apache.oltu.oauth2 + oltu + ${oltu.version} - org.wso2.am.analytics.publisher - org.wso2.am.analytics.publisher.client - ${analytics.publisher.version} + io.swagger.parser.v3 + swagger-parser + ${swagger.parser.version} - org.wso2.orbit.com.nimbusds - nimbus-jose-jwt - ${org.wso2.orbit.nimbus.version} + org.quartz-scheduler + quartz + ${quartz.version} + + + + org.wso2.carbon + org.wso2.carbon.core + ${carbon.kernel.version} - - - org.seleniumhq.selenium - selenium-server - ${selenium.version} + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth + ${identity.inbound.auth.oauth.version} - io.rest-assured - rest-assured - ${rest.assured.version} + org.wso2.carbon.identity.local.auth.api + org.wso2.carbon.identity.local.auth.api.core + ${carbon.identity.local.auth.api.version} - com.nimbusds - oauth2-oidc-sdk - ${com.nimbusds.oidc.version} + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.application.mgt + ${carbon.identity.framework.version} - org.codehaus.groovy - groovy-all - ${org.codehaus.groovy.version} + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.core + ${carbon.identity.framework.version} org.wso2.carbon.apimgt org.wso2.carbon.apimgt.impl - ${org.wso2.carbon.apimgt.keymgt.version} + ${org.wso2.carbon.apimgt.version} javassist @@ -662,152 +492,147 @@ org.wso2.carbon.apimgt - org.wso2.carbon.apimgt.api - ${org.wso2.carbon.apimgt.keymgt.version} + org.wso2.carbon.apimgt.common.gateway + ${org.wso2.carbon.apimgt.version} + - org.wso2.carbon.identity.framework - org.wso2.carbon.identity.application.mgt.stub - ${carbon.identity.framework.version} + org.wso2.financial.services.accelerator + org.wso2.financial.services.accelerator.common + ${project.version} - com.fasterxml.jackson.core - jackson-core - ${jackson.databinding.version} + org.wso2.financial.services.accelerator + org.wso2.financial.services.accelerator.consent.mgt.dao + ${project.version} - org.hibernate - hibernate-validator - ${hibernate-validator} + org.wso2.financial.services.accelerator + org.wso2.financial.services.accelerator.consent.mgt.service + ${project.version} - javax.servlet - jstl - ${jstl.version} + org.wso2.financial.services.accelerator + org.wso2.financial.services.accelerator.consent.mgt.extensions + ${project.version} - org.bouncycastle - bcprov-jdk15on - ${org.bouncycastle.version} + org.wso2.financial.services.accelerator + org.wso2.financial.services.accelerator.identity.extensions + ${project.version} + - org.bouncycastle - bcpkix-jdk15on - ${org.bouncycastle.version} + org.testng + testng + ${org.testng.version} + test - org.json.wso2 - json - ${org.json.version} + org.mockito + mockito-core + ${mockito.version} + test - org.quartz-scheduler.wso2 - quartz - ${quartz.version} + org.mockito + mockito-testng + ${mockito.testng.version} + test - org.wso2.orbit.org.apache.oltu.oauth2 - oltu - ${oltu.version} + commons-dbcp + commons-dbcp + ${commons-dbcp.version} + test + + + com.h2database.wso2 + h2-database-engine + ${orbit.version.h2.engine} + test + + + org.jacoco + org.jacoco.agent + runtime + ${jacoco.version} + - [6.4.111, 6.11.22] - 6.4.111 - 3.21.0-GA - 1.26 - 6.4.111 - 0.1.1 - 3.21.0-GA - 2.4.0 + 4.9.26 1.8 1.8 - 6.0.20.Final - [9.0.174, 9.28.117] - 9.28.116 - 9.28.116 - [5.2.24, 7.0.0) - [5.2.24, 6.0.10) - 1.0.0 - 1.2.11-wso2v16 - 1.2 - 3.4 - 1.4 - 1.9.3 + + 3.1.0 + 2.4 + 3.8.0 + 3.0.2 + 3.3.2 3.2.0 - 1.1.3 2.22.2 - 2.3.2 - 3.0.2 - 2.8.2 - 2.4 - 2.1.1.wso2v1 - 0.8.6 - 2.1.7-wso2v217 - 1.10.19 - 7.3.0 - 5.18.187 - 6.3.11 - 5.19.32 - 2.3.5 - 3.3.7 - 2.12.0 - 2.7.18 + 4.8.2.0 + 1.12.0 + 3.1.0 + 1.8 + + 1.2 + 3.4 + 1.9.4 + 2.4.10 + 3.5.100.v20160504-1419 + 3.9.1.v20130814-1242 + 1.1.3 + 7.9.0.wso2v1 + 6.0.20.Final + 4.4 + 4.7.3 + 1.2.0.wso2v1 + 3.0.0.wso2v4 + 2.16.1 + 1.0.0.wso2v3 1.6.1 - 1.5.10 - 1.1.1 - 2.0.1.Final - 3.3.2 - 6.6.0 + 2.1.1 5.1.2.RELEASE - 2.3 - [7.3.0,8.0.0) - 7.3.0.wso2v1 - [2.8.5, 3.0.0) - 1.3.175 - 5.3.3 - 1.7.1 2.5 - 9.0.11 - 2.0.1 - [5.11.0, 6.2.0) - [9.0.0, 9.5.0) - [2.6.0, 3.0.0) - 4.6.0 - [4.6, 5.0) - 4.4.32 - 3.0.0.v201112011016 - 3.0.0.wso2v1 - 0.9.1 + 3.3.7 1.2 - 1.59 - [1.6,2) - 4.2.3 - 1.10.1 - 4.7.3 - 3.1.0 - 1.0.0.wso2v3 - 1.12.0 - 1.2.0.wso2v1 - - - [1.7.0, 2.0.0) - [1.2.0, 2.0.0) - 3.5.100.v20160504-1419 - 3.9.1.v20130814-1242 - [6.4.111,6.9.6] - - - 3.3.0 - 3.141.59 - 3.8.1 - 6.13 - 2.4.11 - 2.1.7 + 1.7.21 + 3.0.0.v201112011016 + 4.5.13.wso2v1 + 4.3.3.wso2v1 + 2.15.1.wso2v1 + 1.2.5 + 9.0.11 + 2.0.1.Final 2.0.24 - 4.0.2 - 1.13.1 - + 2.3.2 + + 7.0.75 + [7.0.75, 8.0.0) + 7.0.26 + [6.13.0, 7.0.62) + 2.5.10 + 9.29.120 + [9.29.120, 9.29.121) + + 0.8.6 + 5.3.1 + 7.10.1 + 0.5.2 + 1.4 + 1.2.140.wso2v3 + + [1.7.0, 4.0.0) + [1.2.0, 4.0.0) + [2.6.0, 3.0.0) + [2.9,3) + [4.4.0, 5.0.0) + [1.2.11, 2.0.0) + [7.9.0, 10.0) + [2.15.1, 2.16.0) + [3.0.0, 4.0.0)