diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
deleted file mode 100644
index 02be6a41d..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml
+++ /dev/null
@@ -1,167 +0,0 @@
-
-
-
-
-
-
-
- virtual-fire-alarm-plugin
- org.wso2.carbon.devicemgt-plugins
- 3.0.12-SNAPSHOT
- ../pom.xml
-
-
- 4.0.0
- org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin
- bundle
- WSO2 Carbon - IoT Server VirtualFireAlarm Management Plugin
- WSO2 Carbon - Virtual FireAlarm Management/Control Plugin Implementation
- http://wso2.org
-
-
-
-
- org.apache.felix
- maven-scr-plugin
-
-
- maven-compiler-plugin
-
-
- 1.7
-
- 2.3.2
-
-
- org.apache.felix
- maven-bundle-plugin
- 1.4.0
- true
-
-
- ${project.artifactId}
- ${project.artifactId}
- ${carbon.devicemgt.plugins.version}
- IoT Server Virtual Firealarm Impl Bundle
- org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal
-
- org.osgi.framework,
- org.osgi.service.component,
- org.apache.commons.logging,
- javax.naming;resolution:=optional,
- javax.sql;resolution:=optional,
- org.wso2.carbon.device.mgt.common.*,
- org.wso2.carbon.device.mgt.common,
- org.wso2.carbon.device.mgt.input.adapter.extension.*,
- org.wso2.carbon.device.mgt.extensions.feature.mgt.*,
- org.wso2.carbon.utils.*,
- org.wso2.carbon.context,
- org.wso2.carbon.core,
- javax.crypto,
- org.apache.commons.codec.binary,
- org.json.*;version="${commons-json.version.range}",
- org.wso2.carbon.certificate.mgt.core.*,
- org.wso2.carbon.device.mgt.analytics.data.publisher.exception,
- org.wso2.carbon.device.mgt.analytics.data.publisher.service,
- org.wso2.carbon.event.input.adapter.core,
- org.wso2.carbon.event.input.adapter.core.exception,
- org.jivesoftware.smack.*,
- javax.xml,
- javax.xml.bind,
- javax.xml.bind.annotation,
- javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
- org.w3c.dom
-
-
- !org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal,
- org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.*,
-
-
-
-
-
-
-
-
-
- commons-codec
- commons-codec
-
-
- org.eclipse.osgi
- org.eclipse.osgi
-
-
- org.eclipse.osgi
- org.eclipse.osgi.services
-
-
- org.wso2.carbon
- org.wso2.carbon.logging
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.common
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.core
-
-
- org.wso2.carbon
- org.wso2.carbon.ndatasource.core
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.extensions
-
-
- org.wso2.carbon
- org.wso2.carbon.utils
-
-
- org.wso2.carbon.analytics-common
- org.wso2.carbon.event.input.adapter.core
-
-
- org.wso2.carbon.devicemgt-plugins
- org.wso2.carbon.device.mgt.input.adapter.extension
-
-
- org.json.wso2
- json
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.certificate.mgt.core
-
-
- org.wso2.carbon.devicemgt
- org.wso2.carbon.device.mgt.analytics.data.publisher
-
-
- org.igniterealtime.smack.wso2
- smack
-
-
- org.igniterealtime.smack.wso2
- smackx
-
-
-
\ No newline at end of file
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java
deleted file mode 100644
index f7721fdd2..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.device.mgt.iot.virtualfirealarm.plugin.config;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "DeviceManagementConfiguration")
-public class DeviceManagementConfiguration {
-
- private EventListenerConfiguration eventListenerConfiguration;
-
- private static final Log log = LogFactory.getLog(DeviceManagementConfiguration.class);
-
- private DeviceManagementConfiguration() {
- }
-
- @XmlElement(name = "EventListenerConfiguration", required = false)
- public EventListenerConfiguration getEventListenerConfiguration() {
- return eventListenerConfiguration;
- }
-
- public void setEventListenerConfiguration(EventListenerConfiguration eventListenerConfiguration) {
- this.eventListenerConfiguration = eventListenerConfiguration;
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java
deleted file mode 100644
index c182b9218..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.device.mgt.iot.virtualfirealarm.plugin.config;
-
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlValue;
-import java.util.List;
-
-@XmlRootElement(name = "EventListenerConfiguration")
-public class EventListenerConfiguration {
-
- private String eventListenerProvider;
- private List properties;
-
- @XmlElementWrapper(name = "Properties", required = true)
- @XmlElement(name = "Property", required = true)
- public List getProperties() {
- return properties;
- }
-
- public void setProperties(List properties) {
- this.properties = properties;
- }
-
- @XmlElement(name = "EventListenerProvider", required = true)
- public String getEventListenerProvider() {
- return eventListenerProvider;
- }
-
- public void setEventListenerProvider(String eventListenerProvider) {
- this.eventListenerProvider = eventListenerProvider;
- }
-
- @XmlRootElement(name = "Property")
- public static class Property {
-
- private String name;
- private String value;
-
- @XmlAttribute(name = "Name", required = true)
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @XmlValue
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- }
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java
deleted file mode 100644
index 9bb1380e5..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.exception.VirtualFirealarmConfigurationException;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import java.io.File;
-public class VirtualFirealarmConfig {
-
- private static final Log log = LogFactory.getLog(VirtualFirealarmConfig.class);
- private static final String DEVICE_TYPE_CONFIG_PATH =
- CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "device-mgt-plugins" + File.separator
- + "virtual_firealarm.xml";
- private static VirtualFirealarmConfig virtualFirealarmConfig = new VirtualFirealarmConfig();
- private static DeviceManagementConfiguration deviceManagementConfiguration;
-
- public static VirtualFirealarmConfig getInstance() {
- return virtualFirealarmConfig;
- }
-
- public static void initialize() throws VirtualFirealarmConfigurationException {
- File configFile = new File(DEVICE_TYPE_CONFIG_PATH);
- try {
- Document doc = convertToDocument(configFile);
-
- /* Un-marshaling Webapp Authenticator configuration */
- JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfiguration.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- //unmarshaller.setSchema(getSchema());
- deviceManagementConfiguration = (DeviceManagementConfiguration) unmarshaller.unmarshal(doc);
- } catch (JAXBException e) {
- throw new VirtualFirealarmConfigurationException("Error occurred while un-marshalling the file " +
- DEVICE_TYPE_CONFIG_PATH, e);
- }
-
- }
-
- public DeviceManagementConfiguration getDeviceTypeConfiguration() {
- return deviceManagementConfiguration;
- }
-
- public static Document convertToDocument(File file) throws VirtualFirealarmConfigurationException {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- try {
- factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- DocumentBuilder docBuilder = factory.newDocumentBuilder();
- return docBuilder.parse(file);
- } catch (Exception e) {
- throw new VirtualFirealarmConfigurationException("Error occurred while parsing file, while converting " +
- "to a org.w3c.dom.Document", e);
- }
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java
deleted file mode 100644
index 0cba81bcc..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.device.mgt.iot.virtualfirealarm.plugin.config.exception;
-
-public class VirtualFirealarmConfigurationException extends Exception {
-
- private static final long serialVersionUID = -3151279431229070297L;
-
- public VirtualFirealarmConfigurationException(int errorCode, String message) {
- super(message);
- }
-
- public VirtualFirealarmConfigurationException(int errorCode, String message, Throwable cause) {
- super(message, cause);
- }
-
- public VirtualFirealarmConfigurationException(String msg, Exception nestedEx) {
- super(msg, nestedEx);
- }
-
- public VirtualFirealarmConfigurationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public VirtualFirealarmConfigurationException(String msg) {
- super(msg);
- }
-
- public VirtualFirealarmConfigurationException() {
- super();
- }
-
- public VirtualFirealarmConfigurationException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java
deleted file mode 100644
index 5815fa1c7..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.constants;
-
-import org.wso2.carbon.utils.CarbonUtils;
-
-import java.io.File;
-
-public class VirtualFireAlarmConstants {
- public final static String DEVICE_TYPE = "virtual_firealarm";
- public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME";
- public final static String DEVICE_PLUGIN_DEVICE_ID = "VIRTUAL_FIREALARM_DEVICE_ID";
- public final static String STATE_ON = "ON";
- public final static String STATE_OFF = "OFF";
-
- public static final String URL_PREFIX = "http://";
- public static final String BULB_CONTEXT = "BULB";
- public static final String POLICY_CONTEXT = "POLICY";
-
- //sensor events sumerized table name for temperature
- public static final String TEMPERATURE_EVENT_TABLE = "DEVICE_TEMPERATURE_SUMMARY";
- public final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
-
- //mqtt tranport related constants
- public static final String MQTT_ADAPTER_NAME = "virtual_firealarm_mqtt";
- public static final String MQTT_ADAPTER_TYPE = "oauth-mqtt";
- public static final String ADAPTER_TOPIC_PROPERTY = "topic";
- public static final String MQTT_PORT = "\\$\\{mqtt.broker.port\\}";
- public static final String MQTT_BROKER_HOST = "\\$\\{mqtt.broker.host\\}";
- public static final String CARBON_CONFIG_PORT_OFFSET = "Ports.Offset";
- public static final String DEFAULT_CARBON_LOCAL_IP_PROPERTY = "carbon.local.ip";
- public static final int CARBON_DEFAULT_PORT_OFFSET = 0;
- public static final int DEFAULT_MQTT_PORT = 1886;
-
- //xmpp transport related constants
- public static final String XMPP_ADAPTER_NAME = "virtual_firealarm_xmpp";
- public static final String XMPP_ADAPTER_TYPE = "xmpp";
- public static final String PASSWORD_PROPERTY_KEY = "password";
- public static final String JID_PROPERTY_KEY = "jid";
- public static final String CLIENT_JID_PROPERTY_KEY = "xmpp.client.jid";
- public static final String SUBJECT_PROPERTY_KEY = "xmpp.client.subject";
- public static final String MESSAGE_TYPE_PROPERTY_KEY = "xmpp.client.messageType";
- public static final String CHAT_PROPERTY_KEY = "chat";
-
- public static final String USERNAME_PROPERTY_KEY = "username";
- public static final String DCR_PROPERTY_KEY = "dcrUrl";
- public static final String BROKER_URL_PROPERTY_KEY = "url";
- public static final String SCOPES_PROPERTY_KEY = "scopes";
- public static final String QOS_PROPERTY_KEY = "qos";
- public static final String CLIENT_ID_PROPERTY_KEY = "qos";
- public static final String CLEAR_SESSION_PROPERTY_KEY = "clearSession";
- public static final String TOPIC = "topic";
- public static final String SUBSCRIBED_TOPIC = "carbon.super/virtual_firealarm/+/publisher";
-
- public static final String CONTENT_VALIDATION = "contentValidator";
- public static final String CONTENT_TRANSFORMATION = "contentTransformer";
- public static final String RESOURCE = "resource";
-
- public static final String JSON_SERIAL_KEY = "SerialNumber";
- public static final String TEMPERATURE_STREAM_DEFINITION = "org.wso2.iot.devices.temperature";
- public static final String JSON_MESSAGE_KEY = "Msg";
- public static final String JSON_SIGNATURE_KEY = "Sig";
-
- public static final String HOST_KEY = "host";
- public static final String PORT_KEY = "port";
-
- public static final String SERVER_NAME = "serverName";
-
- public static final String MQTT_ADAPTER_TOPIC_PROPERTY_NAME = "mqtt.adapter.topic";
-
- public static final String APIM_APPLICATION_TOKEN_VALIDITY_PERIOD = "3600";
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java
deleted file mode 100644
index 150745ac8..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.exception;
-
-
-public class VirtualFirealarmDeviceMgtPluginException extends Exception{
-
- private String errorMessage;
-
- public String getErrorMessage() {
- return errorMessage;
- }
-
- public void setErrorMessage(String errorMessage) {
- this.errorMessage = errorMessage;
- }
-
- public VirtualFirealarmDeviceMgtPluginException(String msg, Exception nestedEx) {
- super(msg, nestedEx);
- setErrorMessage(msg);
- }
-
- public VirtualFirealarmDeviceMgtPluginException(String message, Throwable cause) {
- super(message, cause);
- setErrorMessage(message);
- }
-
- public VirtualFirealarmDeviceMgtPluginException(String msg) {
- super(msg);
- setErrorMessage(msg);
- }
-
- public VirtualFirealarmDeviceMgtPluginException() {
- super();
- }
-
- public VirtualFirealarmDeviceMgtPluginException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java
deleted file mode 100644
index d9dbf9936..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.certificate.mgt.core.exception.KeystoreException;
-import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
-import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.mqtt.MqttConfig;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.xmpp.XmppConfig;
-import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration;
-import org.wso2.carbon.event.input.adapter.core.MessageType;
-import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException;
-import org.json.JSONObject;
-
-import java.io.IOException;
-import java.security.PublicKey;
-import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Contains utility methods used by FireAlarm plugin.
- */
-public class VirtualFireAlarmUtils {
-
- private static Log log = LogFactory.getLog(VirtualFireAlarmUtils.class);
-
- public static void setupMqttInputAdapter() throws IOException {
- if (!MqttConfig.getInstance().isEnabled()) {
- return;
- }
- InputEventAdapterConfiguration inputEventAdapterConfiguration =
- createMqttInputEventAdapterConfiguration(VirtualFireAlarmConstants.MQTT_ADAPTER_NAME,
- VirtualFireAlarmConstants.MQTT_ADAPTER_TYPE, MessageType.TEXT);
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN, true);
- VirtualFirealarmManagementDataHolder.getInstance().getInputEventAdapterService()
- .create(inputEventAdapterConfiguration, new VirtualFirealarmEventAdapterSubscription());
- } catch (InputEventAdapterException e) {
- log.error("Unable to create Input Event Adapter : " + VirtualFireAlarmConstants.MQTT_ADAPTER_NAME, e);
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
- }
-
- /**
- * Create Output Event Adapter Configuration for given configuration.
- *
- * @param name Input Event Adapter name
- * @param type Input Event Adapter type
- * @param msgFormat Input Event Adapter message format
- * @return InputEventAdapterConfiguration instance for given configuration
- */
- private static InputEventAdapterConfiguration createMqttInputEventAdapterConfiguration(String name, String type,
- String msgFormat) throws IOException {
- InputEventAdapterConfiguration inputEventAdapterConfiguration = new InputEventAdapterConfiguration();
- inputEventAdapterConfiguration.setName(name);
- inputEventAdapterConfiguration.setType(type);
- inputEventAdapterConfiguration.setMessageFormat(msgFormat);
- Map mqttAdapterProperties = new HashMap<>();
- mqttAdapterProperties.put(VirtualFireAlarmConstants.USERNAME_PROPERTY_KEY, MqttConfig.getInstance().getUsername());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.DCR_PROPERTY_KEY, MqttConfig.getInstance().getDcrUrl());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.BROKER_URL_PROPERTY_KEY, MqttConfig.getInstance().getUrl());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.SCOPES_PROPERTY_KEY, MqttConfig.getInstance().getScopes());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.CLEAR_SESSION_PROPERTY_KEY, MqttConfig.getInstance()
- .getClearSession());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.QOS_PROPERTY_KEY, MqttConfig.getInstance().getQos());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.CLIENT_ID_PROPERTY_KEY, "");
- mqttAdapterProperties.put(VirtualFireAlarmConstants.TOPIC, VirtualFireAlarmConstants.SUBSCRIBED_TOPIC);
- mqttAdapterProperties.put(VirtualFireAlarmConstants.CONTENT_TRANSFORMATION,
- VirtualFirealarmMqttContentTransformer.class.getName());
- mqttAdapterProperties.put(VirtualFireAlarmConstants.CONTENT_VALIDATION, "default");
- mqttAdapterProperties.put(VirtualFireAlarmConstants.RESOURCE, "input-event");
- inputEventAdapterConfiguration.setProperties(mqttAdapterProperties);
-
- return inputEventAdapterConfiguration;
- }
-
- public static String extractMessageFromPayload(String message, PublicKey verifySignatureKey)
- throws VirtualFirealarmDeviceMgtPluginException {
- String actualMessage;
-
- JSONObject jsonPayload = new JSONObject(message);
- Object encodedMessage = jsonPayload.get(VirtualFireAlarmConstants.JSON_MESSAGE_KEY);
- Object signedPayload = jsonPayload.get(VirtualFireAlarmConstants.JSON_SIGNATURE_KEY);
-
- if (encodedMessage != null && signedPayload != null) {
- if (VirtualFirealarmSecurityManager.verifySignature(
- encodedMessage.toString(), signedPayload.toString(), verifySignatureKey)) {
- actualMessage = new String(Base64.decodeBase64(encodedMessage.toString()));
- //VirtualFirealarmSecurityManager.decryptMessage(encryptedMessage.toString(), decryptionKey);
- } else {
- String errorMsg = "The message was not signed by a valid client. Could not verify signature on payload";
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg);
- }
- } else {
- String errorMsg = "The received message is in an INVALID format. " +
- "Need to be JSON - {\"Msg\":\"\", \"Sig\":\"\"}.";
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg);
- }
-
- return actualMessage;
- }
-
- public static PublicKey getDevicePublicKey(String alias) throws VirtualFirealarmDeviceMgtPluginException {
- PublicKey clientPublicKey;
- try {
- CertificateManagementService certificateManagementService =
- VirtualFirealarmManagementDataHolder.getInstance().getCertificateManagementService();
- X509Certificate clientCertificate = (X509Certificate) certificateManagementService.getCertificateByAlias(
- alias);
- clientPublicKey = clientCertificate.getPublicKey();
- } catch (KeystoreException e) {
- String errorMsg;
- if (e.getMessage().contains("NULL_CERT")) {
- errorMsg = "The Device-View page might have been accessed prior to the device being started.";
- if(log.isDebugEnabled()){
- log.debug(errorMsg);
- }
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } else {
- errorMsg = "An error occurred whilst trying to retrieve certificate for alias [" + alias +
- "] with alias: [" + alias + "]";
- if(log.isDebugEnabled()){
- log.debug(errorMsg);
- }
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- }
- }
- return clientPublicKey;
- }
-
- public static boolean publishToDAS(String deviceId, float temperature) {
- EventsPublisherService deviceAnalyticsService =
- VirtualFirealarmManagementDataHolder.getInstance().getEventsPublisherService();
- if (deviceAnalyticsService != null) {
- String owner = "";
- Object metdaData[] = {owner, VirtualFireAlarmConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()};
- Object payloadData[] = {temperature};
- try {
- deviceAnalyticsService.publishEvent(VirtualFireAlarmConstants.TEMPERATURE_STREAM_DEFINITION,
- "1.0.0", metdaData, new Object[0], payloadData);
- } catch (DataPublisherConfigurationException e) {
- return false;
- }
- return true;
- }
- return false;
- }
-
- public static void setupXmppInputAdapter() throws IOException {
- if (!XmppConfig.getInstance().isEnabled()) return;
- InputEventAdapterConfiguration inputEventAdapterConfiguration =
- createXmppInputEventAdapterConfiguration(VirtualFireAlarmConstants.XMPP_ADAPTER_NAME,
- VirtualFireAlarmConstants.XMPP_ADAPTER_TYPE, MessageType.TEXT);
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
- VirtualFireAlarmConstants.DEVICE_TYPE_PROVIDER_DOMAIN, true);
- VirtualFirealarmManagementDataHolder.getInstance().getInputEventAdapterService()
- .create(inputEventAdapterConfiguration, new VirtualFirealarmEventAdapterSubscription());
- } catch (InputEventAdapterException e) {
- log.error("Unable to create Input Event Adapter : " + VirtualFireAlarmConstants.MQTT_ADAPTER_NAME, e);
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
- }
-
- /**
- * Create Input Event Adapter Configuration for given configuration.
- *
- * @param name Input Event Adapter name
- * @param type Input Event Adapter type
- * @param msgFormat Input Event Adapter message format
- * @return InputEventAdapterConfiguration instance for given configuration
- */
- private static InputEventAdapterConfiguration createXmppInputEventAdapterConfiguration(String name, String type,
- String msgFormat) throws IOException {
- InputEventAdapterConfiguration inputEventAdapterConfiguration = new InputEventAdapterConfiguration();
- inputEventAdapterConfiguration.setName(name);
- inputEventAdapterConfiguration.setType(type);
- inputEventAdapterConfiguration.setMessageFormat(msgFormat);
- Map xmppAdapterProperties = new HashMap<>();
- XmppConfig xmppConfig = XmppConfig.getInstance();
- xmppAdapterProperties.put(VirtualFireAlarmConstants.HOST_KEY, xmppConfig.getHost());
- xmppAdapterProperties.put(VirtualFireAlarmConstants.PORT_KEY, String.valueOf(xmppConfig.getPort()));
- xmppAdapterProperties.put(VirtualFireAlarmConstants.USERNAME_PROPERTY_KEY, xmppConfig.getUsername());
- xmppAdapterProperties.put(VirtualFireAlarmConstants.PASSWORD_PROPERTY_KEY, xmppConfig.getPassword());
- xmppAdapterProperties.put(VirtualFireAlarmConstants.JID_PROPERTY_KEY, xmppConfig.getJid());
- xmppAdapterProperties.put(VirtualFireAlarmConstants.CONTENT_TRANSFORMATION,
- VirtualFirealarmXmppContentTransformer.class.getName());
- xmppAdapterProperties.put(VirtualFireAlarmConstants.CONTENT_VALIDATION, "default");
- inputEventAdapterConfiguration.setProperties(xmppAdapterProperties);
- return inputEventAdapterConfiguration;
- }
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java
deleted file mode 100644
index 89c977260..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.wso2.carbon.event.input.adapter.core.InputEventAdapterSubscription;
-
-public class VirtualFirealarmEventAdapterSubscription implements InputEventAdapterSubscription {
-
- @Override
- public void onEvent(Object o) {
- String msg = (String) o;
- if (msg != null && !msg.isEmpty()) {
- String[] messages = (msg).split(",");
- String deviceId = messages[0];
- String actualMessage = messages[1];
- if (actualMessage.contains("PUBLISHER")) {
- float temperature = Float.parseFloat(actualMessage.split(":")[2]);
- VirtualFireAlarmUtils.publishToDAS(deviceId, temperature);
- } else {
- float temperature = Float.parseFloat(actualMessage.split(":")[1]);
- VirtualFireAlarmUtils.publishToDAS(deviceId, temperature);
- }
- }
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java
deleted file mode 100644
index bf42dd578..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.json.JSONObject;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-
-import java.security.PublicKey;
-import java.util.Map;
-
-public class VirtualFirealarmMqttContentTransformer implements ContentTransformer {
-
- @Override
- public Object transform(Object message, Map dynamicProperties) {
- String topic = (String) dynamicProperties.get("topic");
- String[] topicParams = topic.split("/");
- String tenantDomain = topicParams[0];
- String deviceId = topicParams[2];
- JSONObject jsonPayload = new JSONObject((String) message);
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- ctx.setTenantDomain(tenantDomain, true);
- Integer serialNo = (Integer) jsonPayload.get(VirtualFireAlarmConstants.JSON_SERIAL_KEY);
- // the hash-code of the deviceId is used as the alias for device certificates during SCEP enrollment.
- // hence, the same is used here to fetch the device-specific-certificate from the key store.
- PublicKey clientPublicKey = VirtualFireAlarmUtils.getDevicePublicKey("" + serialNo);
-
- // the MQTT-messages from VirtualFireAlarm devices are in the form {"Msg":, "Sig":}
- String actualMessage = VirtualFireAlarmUtils.extractMessageFromPayload((String) message, clientPublicKey);
- return deviceId + "," + actualMessage;
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- return "";
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java
deleted file mode 100644
index f7b19fdce..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * 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.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.certificate.mgt.core.config.CertificateConfigurationManager;
-import org.wso2.carbon.certificate.mgt.core.config.CertificateKeystoreConfig;
-import org.wso2.carbon.certificate.mgt.core.exception.CertificateManagementException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-
-public class VirtualFirealarmSecurityManager {
- private static final Log log = LogFactory.getLog(VirtualFirealarmSecurityManager.class);
-
- private static PrivateKey serverPrivateKey;
- private static final String SHA_512 = "SHA-512";
- private static final String CIPHER_PADDING = "RSA/ECB/PKCS1Padding";
- private static CertificateKeystoreConfig certificateKeystoreConfig;
- private VirtualFirealarmSecurityManager() {
-
- }
-
- private static CertificateKeystoreConfig getCertKeyStoreConfig() throws CertificateManagementException {
- if (certificateKeystoreConfig == null) {
- certificateKeystoreConfig = CertificateConfigurationManager.getInstance().getCertificateKeyStoreConfig();
- }
- return certificateKeystoreConfig;
- }
-
- public static void initVerificationManager() {
- serverPrivateKey = retrievePrivateKey();
- }
-
- public static PrivateKey retrievePrivateKey() {
- PrivateKey privateKey = null;
- InputStream inputStream = null;
- KeyStore keyStore;
- try {
- CertificateKeystoreConfig certificateKeystoreConfig = getCertKeyStoreConfig();
- keyStore = KeyStore.getInstance(certificateKeystoreConfig.getCertificateKeystoreType());
- inputStream = new FileInputStream(certificateKeystoreConfig.getCertificateKeystoreLocation());
-
- keyStore.load(inputStream, certificateKeystoreConfig.getCertificateKeystorePassword().toCharArray());
-
- privateKey = (PrivateKey) (keyStore.getKey(certificateKeystoreConfig.getCACertAlias(),
- certificateKeystoreConfig.getCAPrivateKeyPassword().toCharArray()));
-
- } catch (KeyStoreException e) {
- String errorMsg = "Could not load KeyStore of given type in [certificate-config.xml] file." ;
- log.error(errorMsg, e);
- } catch (FileNotFoundException e) {
- String errorMsg = "KeyStore file could not be loaded from path given in [certificate-config.xml] file.";
- log.error(errorMsg, e);
- } catch (NoSuchAlgorithmException e) {
- String errorMsg = "Algorithm not found when loading KeyStore";
- log.error(errorMsg, e);
- } catch (CertificateException e) {
- String errorMsg = "CertificateException when loading KeyStore";
- log.error(errorMsg, e);
- } catch (IOException e) {
- String errorMsg = "Input output issue occurred when loading KeyStore";
- log.error(errorMsg, e);
- } catch (UnrecoverableKeyException e) {
- String errorMsg = "Key is unrecoverable when retrieving CA private key";
- log.error(errorMsg, e);
- } catch (CertificateManagementException e) {
- String errorMsg = "Failed to load the certificate";
- log.error(errorMsg, e);
- } finally {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- } catch (IOException e) {
- log.error("Error closing KeyStore input stream", e);
- }
- }
-
- return privateKey;
- }
-
- public static PrivateKey getServerPrivateKey() {
- return serverPrivateKey;
- }
-
- public static String encryptMessage(String message, Key encryptionKey) throws
- VirtualFirealarmDeviceMgtPluginException {
- Cipher encrypter;
- byte[] cipherData;
-
- try {
- encrypter = Cipher.getInstance(CIPHER_PADDING);
- encrypter.init(Cipher.ENCRYPT_MODE, encryptionKey);
- cipherData = encrypter.doFinal(message.getBytes(StandardCharsets.UTF_8));
-
- } catch (NoSuchAlgorithmException e) {
- String errorMsg = "Algorithm not found exception occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (NoSuchPaddingException e) {
- String errorMsg = "No Padding error occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (InvalidKeyException e) {
- String errorMsg = "InvalidKey exception occurred for encryptionKey \n[\n" + encryptionKey + "\n]\n";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (BadPaddingException e) {
- String errorMsg = "Bad Padding error occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (IllegalBlockSizeException e) {
- String errorMsg = "Illegal blockSize error occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- }
-
- return Base64.encodeBase64String(cipherData);
- }
-
- public static String signMessage(String encryptedData, PrivateKey signatureKey) throws VirtualFirealarmDeviceMgtPluginException {
-
- Signature signature;
- String signedEncodedString;
-
- try {
- signature = Signature.getInstance(SHA_512);
- signature.initSign(signatureKey);
- signature.update(Base64.decodeBase64(encryptedData));
-
- byte[] signatureBytes = signature.sign();
- signedEncodedString = Base64.encodeBase64String(signatureBytes);
-
- } catch (NoSuchAlgorithmException e) {
- String errorMsg = "Algorithm not found exception occurred for Signature instance of [" + SHA_512 + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (SignatureException e) {
- String errorMsg = "Signature exception occurred for Signature instance of [" + SHA_512 + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (InvalidKeyException e) {
- String errorMsg = "InvalidKey exception occurred for signatureKey \n[\n" + signatureKey + "\n]\n";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- }
-
- return signedEncodedString;
- }
-
- public static boolean verifySignature(String data, String signedData, PublicKey verificationKey)
- throws VirtualFirealarmDeviceMgtPluginException {
-
- Signature signature;
- boolean verified;
-
- try {
- signature = Signature.getInstance(SHA_512);
- signature.initVerify(verificationKey);
- signature.update(Base64.decodeBase64(data));
-
- verified = signature.verify(Base64.decodeBase64(signedData));
-
- } catch (NoSuchAlgorithmException e) {
- String errorMsg = "Algorithm not found exception occurred for Signature instance of [" + SHA_512 + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (SignatureException e) {
- String errorMsg = "Signature exception occurred for Signature instance of [" + SHA_512 + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (InvalidKeyException e) {
- String errorMsg = "InvalidKey exception occurred for signatureKey \n[\n" + verificationKey + "\n]\n";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- }
-
- return verified;
- }
-
- public static String decryptMessage(String encryptedMessage, Key decryptKey) throws VirtualFirealarmDeviceMgtPluginException {
-
- Cipher decrypter;
- String decryptedMessage;
-
- try {
-
- decrypter = Cipher.getInstance(CIPHER_PADDING);
- decrypter.init(Cipher.DECRYPT_MODE, decryptKey);
- decryptedMessage = new String(decrypter.doFinal(Base64.decodeBase64(encryptedMessage)), StandardCharsets.UTF_8);
-
- } catch (NoSuchAlgorithmException e) {
- String errorMsg = "Algorithm not found exception occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (NoSuchPaddingException e) {
- String errorMsg = "No Padding error occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (InvalidKeyException e) {
- String errorMsg = "InvalidKey exception occurred for encryptionKey \n[\n" + decryptKey + "\n]\n";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (BadPaddingException e) {
- String errorMsg = "Bad Padding error occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- } catch (IllegalBlockSizeException e) {
- String errorMsg = "Illegal blockSize error occurred for Cipher instance of [" + CIPHER_PADDING + "]";
- log.error(errorMsg);
- throw new VirtualFirealarmDeviceMgtPluginException(errorMsg, e);
- }
-
- return decryptedMessage;
- }
-
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java
deleted file mode 100644
index 70dbcc7d9..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.core.ServerStartupObserver;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
-
-import java.io.IOException;
-
-public class VirtualFirealarmStartupListener implements ServerStartupObserver {
- private static final Log log = LogFactory.getLog(VirtualFirealarmStartupListener.class);
-
- @Override
- public void completingServerStartup() {
- }
-
- @Override
- public void completedServerStartup() {
- try {
- VirtualFireAlarmUtils.setupMqttInputAdapter();
- VirtualFireAlarmUtils.setupXmppInputAdapter();
- VirtualFirealarmManagementDataHolder.getInstance().getInputEventAdapterService().start();
- } catch (IOException e) {
- log.error("Failed to intilaize the virtual firealarm input adapter", e);
- }
- }
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java
deleted file mode 100644
index 20ae77f46..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl;
-
-import org.json.JSONObject;
-import org.wso2.carbon.context.PrivilegedCarbonContext;
-import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-
-import java.security.PublicKey;
-import java.util.Map;
-
-public class VirtualFirealarmXmppContentTransformer implements ContentTransformer {
-
- @Override
- public Object transform(Object message, Map dynamicProperties) {
- String from = (String) dynamicProperties.get("from");
- String subject = (String) dynamicProperties.get("subject");
-
- int indexOfAt = from.indexOf("@");
- int indexOfSlash = from.indexOf("/");
-
- if (indexOfAt != -1 && indexOfSlash != -1) {
- String deviceId = from.substring(0, indexOfAt);
- JSONObject jsonPayload = new JSONObject((String) message);
- try {
- PrivilegedCarbonContext.startTenantFlow();
- PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- ctx.setTenantDomain(subject, true);
- Integer serialNo = (Integer) jsonPayload.get(VirtualFireAlarmConstants.JSON_SERIAL_KEY);
- // the hash-code of the deviceId is used as the alias for device certificates during SCEP enrollment.
- // hence, the same is used here to fetch the device-specific-certificate from the key store.
- PublicKey clientPublicKey = VirtualFireAlarmUtils.getDevicePublicKey("" + serialNo);
-
- // the MQTT-messages from VirtualFireAlarm devices are in the form {"Msg":, "Sig":}
- String actualMessage = VirtualFireAlarmUtils.extractMessageFromPayload((String) message,
- clientPublicKey);
- return deviceId + "," + actualMessage;
- } catch (VirtualFirealarmDeviceMgtPluginException e) {
- return "";
- } finally {
- PrivilegedCarbonContext.endTenantFlow();
- }
- }
- return "";
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java
deleted file mode 100644
index 9fc9111fb..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.internal;
-
-import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
-import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
-import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
-
-/**
- * DataHolder class of virtual firealarm plugins component.
- */
-public class VirtualFirealarmManagementDataHolder {
-
- private InputEventAdapterService inputEventAdapterService;
- private EventsPublisherService eventsPublisherService;
- private CertificateManagementService certificateManagementService;
-
- private static VirtualFirealarmManagementDataHolder thisInstance = new VirtualFirealarmManagementDataHolder();
-
- private VirtualFirealarmManagementDataHolder() {
- }
-
- public static VirtualFirealarmManagementDataHolder getInstance() {
- return thisInstance;
- }
-
- public InputEventAdapterService getInputEventAdapterService() {
- return inputEventAdapterService;
- }
-
- public void setInputEventAdapterService(InputEventAdapterService inputEventAdapterService) {
- this.inputEventAdapterService = inputEventAdapterService;
- }
-
- public EventsPublisherService getEventsPublisherService() {
- return eventsPublisherService;
- }
-
- public void setEventsPublisherService(
- EventsPublisherService eventsPublisherService) {
- this.eventsPublisherService = eventsPublisherService;
- }
-
- public CertificateManagementService getCertificateManagementService() {
- return certificateManagementService;
- }
-
- public void setCertificateManagementService(CertificateManagementService certificateManagementService) {
- this.certificateManagementService = certificateManagementService;
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java
deleted file mode 100644
index 6a1e8c4bf..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
-* Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.internal;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
-import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
-import org.wso2.carbon.core.ServerStartupObserver;
-import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmSecurityManager;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.VirtualFirealarmStartupListener;
-import org.wso2.carbon.event.input.adapter.core.InputEventAdapterService;
-
-/**
- * @scr.component name="org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal
- * .VirtualFirealarmManagementServiceComponent"
- * immediate="true"
- * @scr.reference name="event.input.adapter.service"
- * interface="org.wso2.carbon.event.input.adapter.core.InputEventAdapterService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setInputEventAdapterService"
- * unbind="unsetInputEventAdapterService"
- * @scr.reference name="certificate.management.service"
- * interface="org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setCertificateManagementService"
- * unbind="unsetCertificateManagementService"
- * @scr.reference name="event.publisher.service"
- * interface="org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService"
- * cardinality="1..1"
- * policy="dynamic"
- * bind="setEventsPublisherService"
- * unbind="unsetEventsPublisherService"
- */
-public class VirtualFirealarmManagementServiceComponent {
-
- private static final Log log = LogFactory.getLog(VirtualFirealarmManagementServiceComponent.class);
- private ServiceRegistration firealarmServiceRegRef;
-
- protected void activate(ComponentContext ctx) {
- if (log.isDebugEnabled()) {
- log.debug("Activating Virtual Firealarm Device Management Service Component");
- }
- try {
- VirtualFirealarmConfig.initialize();
- BundleContext bundleContext = ctx.getBundleContext();
- bundleContext.registerService(ServerStartupObserver.class.getName(), new VirtualFirealarmStartupListener(),
- null);
- if (log.isDebugEnabled()) {
- log.debug("Virtual Firealarm Device Management Service Component has been successfully activated");
- }
- VirtualFirealarmSecurityManager.initVerificationManager();
- } catch (Throwable e) {
- log.error("Error occurred while activating Virtual Firealarm Device Management Service Component", e);
- }
- }
-
- protected void deactivate(ComponentContext ctx) {
- if (log.isDebugEnabled()) {
- log.debug("De-activating Virtual Firealarm Device Management Service Component");
- }
- }
-
- /**
- * Initialize the Input EventAdapter Service dependency
- *
- * @param inputEventAdapterService Input EventAdapter Service reference
- */
- protected void setInputEventAdapterService(InputEventAdapterService inputEventAdapterService) {
- VirtualFirealarmManagementDataHolder.getInstance().setInputEventAdapterService(inputEventAdapterService);
- }
-
- /**
- * De-reference the Input EventAdapter Service dependency.
- */
- protected void unsetInputEventAdapterService(InputEventAdapterService inputEventAdapterService) {
- VirtualFirealarmManagementDataHolder.getInstance().setInputEventAdapterService(null);
- }
-
- protected void setCertificateManagementService(CertificateManagementService certificateManagementService) {
- VirtualFirealarmManagementDataHolder.getInstance().setCertificateManagementService(certificateManagementService);
- }
-
- protected void unsetCertificateManagementService(CertificateManagementService certificateManagementService) {
- VirtualFirealarmManagementDataHolder.getInstance().setCertificateManagementService(null);
- }
-
- protected void setEventsPublisherService(EventsPublisherService eventsPublisherService) {
- VirtualFirealarmManagementDataHolder.getInstance().setEventsPublisherService(eventsPublisherService);
- }
-
- protected void unsetEventsPublisherService(EventsPublisherService eventsPublisherService) {
- VirtualFirealarmManagementDataHolder.getInstance().setEventsPublisherService(null);
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java
deleted file mode 100644
index e47ac11ea..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.mqtt;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.EventListenerConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
-
-import java.util.List;
-
-public class MqttConfig {
-
- private static MqttConfig mqttConfig = new MqttConfig();
- private static final Log log = LogFactory.getLog(MqttConfig.class);
-
- private boolean enabled;
- private String url;
- private String username;
- private String dcrUrl;
- private String qos;
- private String scopes;
- private String clearSession;
-
- private MqttConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmConfig.getInstance()
- .getDeviceTypeConfiguration();
- List properties = deviceManagementConfiguration
- .getEventListenerConfiguration().getProperties();
- String provider = deviceManagementConfiguration.getEventListenerConfiguration().getEventListenerProvider();
- if (provider.equals("MQTT")) {
- enabled = true;
- }
- if (enabled) {
- for (EventListenerConfiguration.Property property : properties) {
- switch (property.getName()) {
- case "url":
- url = property.getValue();
- break;
- case "username":
- username = property.getValue();
- break;
- case "dcrUrl":
- dcrUrl = property.getValue();
- break;
- case "qos":
- qos = property.getValue();
- break;
- case "scopes":
- scopes = property.getValue();
- break;
- case "clearSession":
- clearSession = property.getValue();
- break;
- }
- }
- }
- }
-
- public static MqttConfig getInstance() {
- return mqttConfig;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getDcrUrl() {
- return dcrUrl;
- }
-
- public String getQos() {
- return qos;
- }
-
- public String getScopes() {
- return scopes;
- }
-
- public String getClearSession() {
- return clearSession;
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java
deleted file mode 100644
index f8239a8d9..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.xmpp;
-
-/**
- * holds the information related to account that needs to be created on xmpp server.
- */
-public class XmppAccount {
-
- private String username;
- private String password;
- private String accountName;
- private String email;
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getAccountName() {
- return accountName;
- }
-
- public void setAccountName(String accountName) {
- this.accountName = accountName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
deleted file mode 100644
index d600b3a82..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.xmpp;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.DeviceManagementConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.EventListenerConfiguration;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.config.VirtualFirealarmConfig;
-
-import java.util.List;
-
-public class XmppConfig {
-
- private String host;
- private int port;
- private String username;
- private String password;
- private String serverName;
- private boolean enabled;
- private String jid;
- private static XmppConfig xmppConfig = new XmppConfig();
- private static final Log log = LogFactory.getLog(XmppConfig.class);
-
- private XmppConfig() {
- DeviceManagementConfiguration deviceManagementConfiguration = VirtualFirealarmConfig.getInstance()
- .getDeviceTypeConfiguration();
- List properties = deviceManagementConfiguration.getEventListenerConfiguration()
- .getProperties();
- String provider = deviceManagementConfiguration.getEventListenerConfiguration().getEventListenerProvider();
- if ("XMPP".equals(provider)) {
- enabled = true;
- }
- if (enabled) {
- for (EventListenerConfiguration.Property property : properties) {
- switch (property.getName()) {
- case "host":
- host = property.getValue();
- break;
- case "port":
- port = Integer.parseInt(property.getValue());
- break;
- case "username":
- username = property.getValue();
- break;
- case "password":
- password = property.getValue();
- break;
- case "server.name":
- serverName = property.getValue();
- break;
- case "jid":
- jid = property.getValue();
- break;
-
- }
- }
- }
- }
-
- public static XmppConfig getInstance() {
- return xmppConfig;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public void setServerName(String serverName) {
- this.serverName = serverName;
- }
-
- public boolean isEnabled() {
- return enabled;
- }
-
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- public String getJid() {
- return jid;
- }
-
- public void setJid(String jid) {
- this.jid = jid;
- }
-}
diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java
deleted file mode 100644
index cdbcb87dd..000000000
--- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2015, 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.device.mgt.iot.virtualfirealarm.plugin.xmpp;
-
-import org.jivesoftware.smack.AccountManager;
-import org.jivesoftware.smack.ConnectionConfiguration;
-import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.XMPPException;
-import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class XmppServerClient {
-
- public static boolean createAccount(XmppAccount xmppAccount) throws VirtualFirealarmDeviceMgtPluginException {
- if (XmppConfig.getInstance().isEnabled()) {
- if (xmppAccount != null) {
- try {
- ConnectionConfiguration config = new ConnectionConfiguration(XmppConfig.getInstance().getHost(),
- XmppConfig.getInstance().getPort(),
- "Accounts");
- XMPPConnection xmppConnection = new XMPPConnection(config);
- xmppConnection.connect();
- xmppConnection.login(XmppConfig.getInstance().getUsername(), XmppConfig.getInstance().getPassword());
- AccountManager accountManager = xmppConnection.getAccountManager();
- Map attributes = new HashMap<>();
- attributes.put("username", xmppAccount.getUsername());
- attributes.put("password", xmppAccount.getPassword());
- attributes.put("email", xmppAccount.getEmail());
- attributes.put("name", xmppAccount.getAccountName());
- accountManager.createAccount(xmppAccount.getUsername(), xmppAccount.getPassword(), attributes);
- xmppConnection.disconnect();
- return true;
- } catch (XMPPException e) {
- if (e.getXMPPError().getCode() == 409) {
- //AccountAlreadyExist
- return true;
- } else {
- throw new VirtualFirealarmDeviceMgtPluginException(
- "XMPP account creation failed. Error: " + e.getLocalizedMessage(), e);
- }
- }
- } else {
- throw new VirtualFirealarmDeviceMgtPluginException("Invalid XMPP attributes");
- }
- } else {
- return true;
- }
- }
-}