diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index 889a13f2..420c9152 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -780,6 +780,13 @@ true 644 + + src/repository/conf/etc/device-analytics-config.xml + ${pom.artifactId}-${pom.version}/repository/conf/etc + device-analytics-config.xml + true + 644 + src/repository/conf/synapse-handlers.xml diff --git a/modules/distribution/src/repository/conf/etc/device-analytics-config.xml b/modules/distribution/src/repository/conf/etc/device-analytics-config.xml new file mode 100644 index 00000000..5baa363c --- /dev/null +++ b/modules/distribution/src/repository/conf/etc/device-analytics-config.xml @@ -0,0 +1,36 @@ + + + + + + true + tcp://localhost:7611 + admin + admin + diff --git a/modules/distribution/src/repository/conf/identity/identity-providers/CDMF_DEFAULT_IDP.xml b/modules/distribution/src/repository/conf/identity/identity-providers/CDMF_DEFAULT_IDP.xml index 7e969f24..8109ae92 100644 --- a/modules/distribution/src/repository/conf/identity/identity-providers/CDMF_DEFAULT_IDP.xml +++ b/modules/distribution/src/repository/conf/identity/identity-providers/CDMF_DEFAULT_IDP.xml @@ -20,7 +20,7 @@ CDMF_DEFAULT_IDP CDMF_DEFAULT_IDP - https://localhost:9443/oauth2/token + JwtIdentityAudience true diff --git a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/pom.xml b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/pom.xml index f33fd41a..acb81ddc 100644 --- a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/pom.xml +++ b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/pom.xml @@ -154,7 +154,9 @@ org.apache.commons.httpclient.protocol, org.apache.commons.pool, org.apache.commons.pool.impl, - org.apache.log4j + org.apache.log4j, + org.wso2.carbon.base, + org.wso2.carbon.core.util diff --git a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/http/oauth/OAuthTokenValidaterStubFactory.java b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/http/oauth/OAuthTokenValidaterStubFactory.java index 57962f00..981138fe 100644 --- a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/http/oauth/OAuthTokenValidaterStubFactory.java +++ b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/http/oauth/OAuthTokenValidaterStubFactory.java @@ -32,6 +32,7 @@ import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.pool.BasePoolableObjectFactory; import org.apache.log4j.Logger; +import org.wso2.carbon.core.util.Utils; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.extensions.http.oauth.exception.OAuthTokenValidationException; import org.wso2.carbon.event.input.adapter.extensions.http.util.HTTPEventAdapterConstants; @@ -91,8 +92,8 @@ public class OAuthTokenValidaterStubFactory extends BasePoolableObjectFactory { private OAuth2TokenValidationServiceStub generateStub() throws OAuthTokenValidationException { OAuth2TokenValidationServiceStub stub; try { - URL hostURL = new URL(eventAdapterConfiguration.getProperties().get( - HTTPEventAdapterConstants.TOKEN_VALIDATION_ENDPOINT_URL)); + URL hostURL = new URL(Utils.replaceSystemProperty(eventAdapterConfiguration.getProperties().get( + HTTPEventAdapterConstants.TOKEN_VALIDATION_ENDPOINT_URL))); if (hostURL != null) { stub = new OAuth2TokenValidationServiceStub(hostURL.toString()); if (stub != null) { diff --git a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/util/MQTTBrokerConnectionConfiguration.java b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/util/MQTTBrokerConnectionConfiguration.java index 3845531c..2bd038f4 100644 --- a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/util/MQTTBrokerConnectionConfiguration.java +++ b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/mqtt/util/MQTTBrokerConnectionConfiguration.java @@ -18,6 +18,7 @@ package org.wso2.carbon.event.input.adapter.extensions.mqtt.util; import org.wso2.carbon.event.input.adapter.extensions.mqtt.Constants; +import org.wso2.carbon.event.input.adapter.extensions.util.PropertyUtils; import java.util.Map; @@ -108,8 +109,8 @@ public class MQTTBrokerConnectionConfiguration { if (brokerScopes == null) { this.brokerScopes = Constants.EMPTY_STRING; } - this.brokerUrl = brokerUrl; - this.dcrUrl = dcrUrl; + this.brokerUrl = PropertyUtils.replaceMqttProperty(brokerUrl); + this.dcrUrl = PropertyUtils.replaceMqttProperty(dcrUrl); this.contentValidatorClassName = contentValidatorClassName; if (cleanSession != null) { this.cleanSession = Boolean.parseBoolean(cleanSession); diff --git a/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/util/PropertyUtils.java b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/util/PropertyUtils.java new file mode 100644 index 00000000..2b97363f --- /dev/null +++ b/modules/iot-extensions/components/das-extensions/org.wso2.carbon.event.input.adapter.extensions/src/main/java/org/wso2/carbon/event/input/adapter/extensions/util/PropertyUtils.java @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* +* WSO2 Inc. 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 org.wso2.carbon.event.input.adapter.extensions.util; + +import org.wso2.carbon.base.ServerConfiguration; +import org.wso2.carbon.core.util.Utils; + +public class PropertyUtils { + private static final String MQTT_PORT = "\\$\\{mqtt.broker.port\\}"; + private static final String MQTT_BROKER_HOST = "\\$\\{mqtt.broker.host\\}"; + private static final String CARBON_CONFIG_PORT_OFFSET = "Ports.Offset"; + private static final String DEFAULT_CARBON_SERVER_HOST_PROPERTY = "server.host"; + private static final int CARBON_DEFAULT_PORT_OFFSET = 0; + private static final int DEFAULT_MQTT_PORT = 1883; + + //This method is only used if the mb features are within DAS. + public static String replaceMqttProperty (String urlWithPlaceholders) { + urlWithPlaceholders = Utils.replaceSystemProperty(urlWithPlaceholders); + urlWithPlaceholders = urlWithPlaceholders.replaceAll(MQTT_PORT, "" + (DEFAULT_MQTT_PORT + getPortOffset())); + urlWithPlaceholders = urlWithPlaceholders.replaceAll(MQTT_BROKER_HOST, System.getProperty(DEFAULT_CARBON_SERVER_HOST_PROPERTY, + "localhost")); + return urlWithPlaceholders; + } + + private static int getPortOffset() { + ServerConfiguration carbonConfig = ServerConfiguration.getInstance(); + String portOffset = System.getProperty("portOffset", + carbonConfig.getFirstProperty(CARBON_CONFIG_PORT_OFFSET)); + try { + if ((portOffset != null)) { + return Integer.parseInt(portOffset.trim()); + } else { + return CARBON_DEFAULT_PORT_OFFSET; + } + } catch (NumberFormatException e) { + return CARBON_DEFAULT_PORT_OFFSET; + } + } +}