Skip to content

Commit

Permalink
Merge branch 'master' into seqTask
Browse files Browse the repository at this point in the history
  • Loading branch information
chanikag authored Sep 6, 2023
2 parents 66da899 + c81c7d5 commit 7ccf3ac
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 103 deletions.
9 changes: 0 additions & 9 deletions .github/ISSUE_TEMPLATE/config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Please follow the steps below to build WSO2 Micro Integrator from the source cod
2. Run the maven command `mvn clean install` from the root directory of the repository.
3. The generated Micro Integrator distribution can be found at `micro-integrator/distribution/target/wso2mi-<version>.zip`.

Please note that the product can be build using only JDK 8 but the integration tests can be run in either JDK 8 or 11.
Please note that the product can be build using only JDK 11 but the integration tests can be run in either JDK 11 or 17.

#### Building the Docker image

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,8 @@ private MongoDB() {
public static final String CONNECT_TIMEOUT = "mongoDB_connectTimeout";
public static final String MAX_WAIT_TIME = "mongoDB_maxWaitTime";
public static final String SOCKET_TIMEOUT = "mongoDB_socketTimeout";
public static final String SSL_ENABLED = "mongoDB_ssl_enabled";
public static final String AUTH_SOURCE = "mongoDB_auth_source";
public static final String CONNECTIONS_PER_HOST = "mongoDB_connectionsPerHost";
public static final String THREADS_ALLOWED_TO_BLOCK_CONN_MULTIPLIER = "mongoDB_threadsAllowedToBlockForConnectionMultiplier";
public static final String RESULT_COLUMN_NAME = "Document";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.wso2.micro.integrator.dataservices.core;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -70,7 +71,7 @@ public class DataServiceFault extends Exception {
/**
* This map contains all the properties related to data services fault message
*/
private Map<String, Object> propertyMap = new HashMap<String, Object>();
private Map<String, Object> propertyMap = new LinkedHashMap<>();

public DataServiceFault(Throwable nestedException, String code, String dsFaultMessage) {
super(nestedException);
Expand Down Expand Up @@ -103,9 +104,11 @@ public static OMElement extractFaultMessage(Throwable throwable) {
keyElement.addChild(dataServiceKeyElement);
}
} else {
OMText valueElement = fac.createOMText(
keyElement, rootEntry.getValue().toString());
keyElement.addChild(valueElement);
if (rootEntry.getValue() != null) {
OMText valueElement = fac.createOMText(
keyElement, rootEntry.getValue().toString());
keyElement.addChild(valueElement);
}
}
root.addChild(keyElement);
}
Expand Down Expand Up @@ -173,40 +176,54 @@ public String getMessage() {
/**
* Returns a detailed description of the data service fault.
*/
public String getFullMessage() {
StringBuffer buff = new StringBuffer();
if (this.getDsFaultMessage() != null) {
buff.append("DS Fault Message: " + this.getDsFaultMessage() + "\n");
}
if (this.getCode() != null) {
buff.append("DS Code: " + this.getCode() + "\n");
getPropertyMap().put(DBConstants.FaultParams.DS_CODE, this.getCode());
}
if (this.getSourceDataService() != null) {
buff.append("Source Data Service:-\n");
buff.append(this.getSourceDataService().toString());
Map<String, String> sourcePropertyMap = new HashMap<String, String>();
sourcePropertyMap.put(DBConstants.FaultParams.DATA_SERVICE_NAME, this.getSourceDataService().getName());
public String getFullMessage() {
StringBuffer buff = new StringBuffer();
if (this.getDsFaultMessage() != null) {
buff.append("DS Fault Message: " + this.getDsFaultMessage() + "\n");
}
// if skipCurrentParams is not set to true, we don't have current params in WSDL
// so no need to add a null value
if (!("true".equalsIgnoreCase(DBUtils.getCurrentParamsDisabledProperty()))) {
if (this.getCurrentParams() != null) {
buff.append("Current Params: " + this.getCurrentParams() + "\n");
getPropertyMap().put(DBConstants.FaultParams.CURRENT_PARAMS, this.getCurrentParams().toString());
} else {
getPropertyMap().put(DBConstants.FaultParams.CURRENT_PARAMS, null);
}
}
if (this.getCurrentRequestName() != null) {
buff.append("Current Request Name: " + this.getCurrentRequestName() + "\n");
getPropertyMap().put(DBConstants.FaultParams.CURRENT_REQUEST_NAME, this.getCurrentRequestName());
} else {
getPropertyMap().put(DBConstants.FaultParams.CURRENT_REQUEST_NAME, null);
}
if (this.getCause() != null) {
buff.append("Nested Exception:-\n" + this.getCause() + "\n");
getPropertyMap().put(DBConstants.FaultParams.NESTED_EXCEPTION, this.getCause().toString());
} else {
getPropertyMap().put(DBConstants.FaultParams.NESTED_EXCEPTION, null);
}
if (this.getSourceDataService() != null) {
buff.append("Source Data Service:-\n");
buff.append(this.getSourceDataService().toString());
Map<String, String> sourcePropertyMap = new LinkedHashMap<>();
sourcePropertyMap.put(DBConstants.FaultParams.LOCATION, this.getSourceDataService().getRelativeDsLocation());
sourcePropertyMap.put(DBConstants.FaultParams.DEFAULT_NAMESPACE, this.getSourceDataService().getDefaultNamespace());
sourcePropertyMap.put(DBConstants.FaultParams.DESCRIPTION, this.getSourceDataService().getDescription() != null ?
this.getSourceDataService().getDescription() : "N/A");
sourcePropertyMap.put(DBConstants.FaultParams.DEFAULT_NAMESPACE, this.getSourceDataService().getDefaultNamespace());
sourcePropertyMap.put(DBConstants.FaultParams.DATA_SERVICE_NAME, this.getSourceDataService().getName());
getPropertyMap().put(DBConstants.FaultParams.SOURCE_DATA_SERVICE, sourcePropertyMap);
}
if (this.getCurrentRequestName() != null) {
buff.append("Current Request Name: " + this.getCurrentRequestName() + "\n");
getPropertyMap().put(DBConstants.FaultParams.CURRENT_REQUEST_NAME, this.getCurrentRequestName());
}
if (this.getCurrentParams() != null && !("true".equalsIgnoreCase(DBUtils.getCurrentParamsDisabledProperty()))) {
buff.append("Current Params: " + this.getCurrentParams() + "\n");
getPropertyMap().put(DBConstants.FaultParams.CURRENT_PARAMS, this.getCurrentParams().toString());
}
if (this.getCause() != null) {
buff.append("Nested Exception:-\n" + this.getCause() + "\n");
getPropertyMap().put(DBConstants.FaultParams.NESTED_EXCEPTION, this.getCause().toString());
}
return buff.toString();
}
} else {
getPropertyMap().put(DBConstants.FaultParams.SOURCE_DATA_SERVICE, null);
}
if (this.getCode() != null) {
buff.append("DS Code: " + this.getCode() + "\n");
getPropertyMap().put(DBConstants.FaultParams.DS_CODE, this.getCode());
} else {
getPropertyMap().put(DBConstants.FaultParams.DS_CODE, null);
}
return buff.toString();
}

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ private MongoClientOptions extractMongoOptions(Map<String, String> properties) {
builder.threadsAllowedToBlockForConnectionMultiplier(
Integer.parseInt(threadsAllowedToBlockForConnectionMultiplier));
}

String sslEnabled = (properties.get(DBConstants.MongoDB.SSL_ENABLED));
if (Boolean.parseBoolean(sslEnabled)) {
builder.sslEnabled(true);
}
return builder.build();
}

Expand All @@ -169,17 +174,23 @@ private MongoCredential createCredential(Map<String, String> properties) throws
String authenticationType = properties.get(DBConstants.MongoDB.AUTHENTICATION_TYPE);
String username = properties.get(DBConstants.MongoDB.USERNAME);
String password = properties.get(DBConstants.MongoDB.PASSWORD);
String database = properties.get(DBConstants.MongoDB.DATABASE);
String authSource = properties.get(DBConstants.MongoDB.AUTH_SOURCE);
if (authSource == null || authSource.isEmpty()) {
// For MONGODB-CR, SCRAM-SHA-1, and SCRAM-SHA-256, PLAIN the default auth source is the database tyring to connect
// refer: https://docs.mongodb.com/ruby-driver/master/reference/authentication/
// since database is mandatory, we will not address the case where DB is not defined.
authSource = properties.get(DBConstants.MongoDB.DATABASE);
}
if (authenticationType != null) {
switch (authenticationType) {
case DBConstants.MongoDB.MongoAuthenticationTypes.PLAIN:
credential = MongoCredential.createPlainCredential(username, database, password.toCharArray());
credential = MongoCredential.createPlainCredential(username, authSource, password.toCharArray());
break;
case DBConstants.MongoDB.MongoAuthenticationTypes.SCRAM_SHA_1:
credential = MongoCredential.createScramSha1Credential(username, database, password.toCharArray());
credential = MongoCredential.createScramSha1Credential(username, authSource, password.toCharArray());
break;
case DBConstants.MongoDB.MongoAuthenticationTypes.MONGODB_CR:
credential = MongoCredential.createMongoCRCredential(username, database, password.toCharArray());
credential = MongoCredential.createMongoCRCredential(username, authSource, password.toCharArray());
break;
case DBConstants.MongoDB.MongoAuthenticationTypes.GSSAPI:
credential = MongoCredential.createGSSAPICredential(username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ public InvocationResponse invoke(MessageContext msgCtx) throws AxisFault {
if (faultCodeObject instanceof SOAP11FaultCodeImpl) {
faultCode = ((SOAP11FaultCodeImpl) faultCodeObject).getTextContent();
} else if (faultCodeObject instanceof SOAP12FaultCodeImpl) {
faultCode = ((SOAP12FaultSubCodeImpl) ((SOAP12FaultCodeImpl) faultCodeObject).getSubCode()).getTextContent();
if (null != ((SOAP12FaultCodeImpl) faultCodeObject).getSubCode()) {
faultCode = ((SOAP12FaultSubCodeImpl) ((SOAP12FaultCodeImpl) faultCodeObject)
.getSubCode()).getTextContent();
} else {
faultCode = ((SOAP12FaultCodeImpl)faultCodeObject).getTextContent();
}
}

if (faultCode != null && faultCode.contains("FailedAuthentication")) { // this is standard error code according to the WS-Sec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public class Constants {
public static final String USER_NAME = "username";
public static final String PASSWORD = "password";
public static final String SERVICE_CATALOG_EXECUTOR_THREADS = "executor_threads";

public static final String SERVICE_CATALOG_PUBLISH_ENDPOINT = "api/am/service-catalog/v1/services/import?overwrite" +
"=true";
public static final String SERVICE_CATALOG_GET_SERVICES_ENDPOINT = "api/am/service-catalog/v1/services";
public static final String SERVICE_CATALOG_API_VERSION_PROPERTY = "service-catalog.api.version";
public static final String SERVICE_CATALOG_DEFAULT_API_VERSION = "v1";
public static final String SERVICE_CATALOG_ENDPOINT_PREFIX = "api/am/service-catalog/";
public static final String SERVICE_CATALOG_PUBLISH_ENDPOINT = "/services/import?overwrite=true";
public static final String SERVICE_CATALOG_GET_SERVICES_ENDPOINT = "/services";

// creating the payload.zip related constants
public static final String SERVICE_CATALOG = "ServiceCatalog";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.wso2.micro.application.deployer.CarbonApplication;
import org.wso2.micro.core.util.CarbonException;
import org.wso2.micro.core.util.StringUtils;
import org.wso2.micro.integrator.core.util.MicroIntegratorBaseUtils;
import org.wso2.micro.integrator.initializer.deployment.application.deployer.CappDeployer;
import org.wso2.securevault.SecretResolver;
import org.wso2.securevault.SecretResolverFactory;
Expand Down Expand Up @@ -83,6 +82,15 @@ public class ServiceCatalogUtils {
private static String resolvedUrl;
private static String lineSeparator;
private static Map<String, Object> parsedConfigs;
private static final String API_VERSION;

static {
String apiVersion = System.getProperty(SERVICE_CATALOG_API_VERSION_PROPERTY);
if (apiVersion == null) {
apiVersion = SERVICE_CATALOG_DEFAULT_API_VERSION;
}
API_VERSION = apiVersion;
}

/**
* Update the service url by injecting env variables.
Expand Down Expand Up @@ -241,11 +249,10 @@ public static Map<String, String> getAllServices(Map<String, String> apimConfigs
(apimConfigs.get(USER_NAME) + ":" + apimConfigs.get(PASSWORD)).getBytes());

// create get all services url
if (APIMHost.endsWith("/")) {
APIMHost = APIMHost + SERVICE_CATALOG_GET_SERVICES_ENDPOINT;
} else {
APIMHost = APIMHost + "/" + SERVICE_CATALOG_GET_SERVICES_ENDPOINT;
if (!APIMHost.endsWith("/")) {
APIMHost = APIMHost + "/";
}
APIMHost = APIMHost + SERVICE_CATALOG_ENDPOINT_PREFIX + API_VERSION + SERVICE_CATALOG_GET_SERVICES_ENDPOINT;

try {
HttpsURLConnection connection = (HttpsURLConnection) new URL(APIMHost).openConnection();
Expand Down Expand Up @@ -303,11 +310,10 @@ private static int uploadZip(Map<String, String> apimConfigs, String attachmentF
String APIMHost = apimConfigs.get(APIM_HOST);

// create POST URL
if (APIMHost.endsWith("/")) {
APIMHost = APIMHost + SERVICE_CATALOG_PUBLISH_ENDPOINT;
} else {
APIMHost = APIMHost + "/" + SERVICE_CATALOG_PUBLISH_ENDPOINT;
if (!APIMHost.endsWith("/")) {
APIMHost = APIMHost + "/";
}
APIMHost = APIMHost + SERVICE_CATALOG_ENDPOINT_PREFIX + API_VERSION + SERVICE_CATALOG_PUBLISH_ENDPOINT;

String encodeBytes =
Base64.getEncoder().encodeToString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public boolean accept(File dir, String name) {
String packageName = retrievePackageName(connectorExtractedPath);

// Retrieve connector name
String connectorName = connectorZip.getName().substring(0, connectorZip.getName().indexOf('-'));
String connectorName = connectorZip.getName().substring(0, connectorZip.getName().lastIndexOf('-'));
QName qualifiedName = new QName(packageName, connectorName);
File importFile = new File(importsDir, qualifiedName.toString() + ".xml");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public Map getProperties() {
public boolean processSecurity(String credentials) {
String decodedCredentials = new String(new Base64().decode(credentials.getBytes()));
String username = decodedCredentials.split(":")[0];
String password = decodedCredentials.split(":")[1];
String password = decodedCredentials.split(":",2)[1];
UserStoreManager userStoreManager;
try {
userStoreManager = MicroIntegratorSecurityUtils.getUserStoreManager();
Expand Down
5 changes: 4 additions & 1 deletion distribution/src/resources/config-tool/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@
"cache_delay": "2"
},

"user_store.base_dn": "dc=wso2,dc=org"
"user_store.base_dn": "dc=wso2,dc=org",

"transport.jms.sender_class": "org.apache.axis2.transport.jms.JMSSender",
"transport.jms.listener_class": "org.apache.axis2.transport.jms.JMSListener"

}
Original file line number Diff line number Diff line change
Expand Up @@ -290,30 +290,18 @@
{% endfor %}
</transportReceiver>
{% endif %}
{% if transport.jms.listener_enable is defined %}
{% if transport.jms.listener_enable and transport.jms.listener|length==0 %}
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"/>
{% elif transport.jms.listener_enable %}
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
{% for listener in transport.jms.listener %}
<parameter name="{{listener.name}}" locked="false">
{% for name,value in listener.parameter.items() %}
<parameter name="{{name}}" locked="false">{{value}}</parameter>
{% endfor %}
</parameter>
{% endfor %}
</transportReceiver>
{% endif %}
{% if transport.jms.listener|length==0 %}
<transportReceiver name="jms" class="{{transport.jms.listener_class}}"/>
{% elif transport.jms.listener|length>0 %}
<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">
<transportReceiver name="jms" class="{{transport.jms.listener_class}}">
{% for listener in transport.jms.listener %}
<parameter name="{{listener.name}}" locked="false">
<parameter name="{{listener.name}}" locked="false">
{% for name,value in listener.parameter.items() %}
<parameter name="{{name}}" locked="false">{{value}}</parameter>
<parameter name="{{name}}" locked="false">{{value}}</parameter>
{% endfor %}
</parameter>
</parameter>
{% endfor %}
</transportReceiver>
</transportReceiver>
{% endif %}
{% if transport.fix.listener.enable == true %}
<transportReceiver name="fix" class="org.apache.synapse.transport.fix.FIXTransportListener">
Expand Down Expand Up @@ -565,30 +553,18 @@
{% endif %}
</transportSender>
{% endif %}
{% if transport.jms.sender_enable is defined %}
{% if transport.jms.sender_enable and transport.jms.sender|length==0 %}
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>
{% elif transport.jms.sender_enable %}
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender">
{% for sender in transport.jms.sender %}
<parameter name="{{sender.name}}" locked="false">
{% for name,value in sender.parameter.items() %}
<parameter name="{{name}}" locked="false">{{value}}</parameter>
{% endfor %}
</parameter>
{% endfor %}
</transportSender>
{% endif %}
{% if transport.jms.sender|length==0 %}
<transportSender name="jms" class="{{transport.jms.sender_class}}"/>
{% elif transport.jms.sender|length>0 %}
<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender">
<transportSender name="jms" class="{{transport.jms.sender_class}}">
{% for sender in transport.jms.sender %}
<parameter name="{{sender.name}}" locked="false">
<parameter name="{{sender.name}}" locked="false">
{% for name,value in sender.parameter.items() %}
<parameter name="{{name}}" locked="false">{{value}}</parameter>
<parameter name="{{name}}" locked="false">{{value}}</parameter>
{% endfor %}
</parameter>
</parameter>
{% endfor %}
</transportSender>
</transportSender>
{% endif %}
{% if transport.local.sender.nonblocking.enable == true %}
<transportSender name="local" class="org.apache.axis2.transport.local.NonBlockingLocalTransportSender"/>
Expand Down
Loading

0 comments on commit 7ccf3ac

Please sign in to comment.