Merging changes

revert-dabc3590
Hasunie 8 years ago
commit 0c87c32094

@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>iot-analytics</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>iot-analytics</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>iot-analytics</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>analytics</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>androidsense-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -3,7 +3,7 @@
<parent>
<artifactId>androidsense-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<artifactId>androidsense-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>arduino-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>arduino-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<artifactId>arduino-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>raspberrypi-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>raspberrypi-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<artifactId>raspberrypi-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<artifactId>virtual-fire-alarm-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<artifactId>virtual-fire-alarm-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>virtual-fire-alarm-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>virtual-fire-alarm-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -1,167 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>virtual-fire-alarm-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - IoT Server VirtualFireAlarm Management Plugin</name>
<description>WSO2 Carbon - Virtual FireAlarm Management/Control Plugin Implementation</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
<Bundle-Description>IoT Server Virtual Firealarm Impl Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal</Private-Package>
<Import-Package>
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
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal,
org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.*,
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.analytics-common</groupId>
<artifactId>org.wso2.carbon.event.input.adapter.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.input.adapter.extension</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</dependency>
</dependencies>
</project>

@ -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;
}
}

@ -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<Property> properties;
@XmlElementWrapper(name = "Properties", required = true)
@XmlElement(name = "Property", required = true)
public List<Property> getProperties() {
return properties;
}
public void setProperties(List<Property> 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;
}
}
}

@ -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);
}
}
}

@ -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);
}
}

@ -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";
}

@ -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);
}
}

@ -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<String, String> 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\":\"<ENCRYPTED_MSG>\", \"Sig\":\"<SIGNED_MSG>\"}.";
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<String, String> 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;
}
}

@ -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);
}
}
}
}

@ -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<String, Object> 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":<MESSAGE>, "Sig":<SIGNATURE>}
String actualMessage = VirtualFireAlarmUtils.extractMessageFromPayload((String) message, clientPublicKey);
return deviceId + "," + actualMessage;
} catch (VirtualFirealarmDeviceMgtPluginException e) {
return "";
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
}

@ -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;
}
}

@ -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);
}
}
}

@ -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<String, Object> 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":<MESSAGE>, "Sig":<SIGNATURE>}
String actualMessage = VirtualFireAlarmUtils.extractMessageFromPayload((String) message,
clientPublicKey);
return deviceId + "," + actualMessage;
} catch (VirtualFirealarmDeviceMgtPluginException e) {
return "";
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
return "";
}
}

@ -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;
}
}

@ -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);
}
}

@ -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<EventListenerConfiguration.Property> 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;
}
}

@ -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;
}
}

@ -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<EventListenerConfiguration.Property> 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;
}
}

@ -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<String, String> 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;
}
}
}

@ -23,7 +23,7 @@
<parent>
<artifactId>virtual-fire-alarm-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -33,7 +33,6 @@
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin</module>
<module>org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui</module>
<module>org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl</module>
<module>org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl</module>

@ -18,7 +18,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>appm-connector</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -18,7 +18,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>appm-connector</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@ -27,29 +27,6 @@
<packaging>bundle</packaging>
<name>WSO2 Carbon - App Manager WSO2 MDM REST Connector Component</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>wso2-maven2-repository</id>
<name>WSO2 Maven2 Repository</name>
<url>http://dist.wso2.org/maven2/</url>
</repository>
<repository>
<id>wso2-maven2-snapshot-repository</id>
<name>WSO2 Maven2 Snapshot Repository</name>
<url>http://dist.wso2.org/snapshots/maven2/</url>
</repository>
<repository>
<id>wso2-nexus</id>
<name>WSO2 internal Repository</name>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
</repository>
</repositories>
<build>
<plugins>
<plugin>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>cdmf-transport-adapters</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>mb-extensions</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -20,7 +20,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>siddhi-extensions</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>android-plugin</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>android-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -415,7 +415,7 @@ public interface DeviceManagementAdminService {
value = "Clearing the Password on Android Devices",
notes = "Clear the password on Android devices",
response = Activity.class,
tags = "Android Device Management Administrative Service.",
tags = "Android Device Management Administrative Service",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = AndroidConstants.SCOPE, value = "perm:android:clear-password")

@ -23,13 +23,13 @@
<parent>
<artifactId>android-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.ui</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<name>WSO2 Carbon - Mobile Android UI</name>
<packaging>pom</packaging>

@ -1,4 +1,5 @@
{{unit "cdmf.unit.device.type.android.leaflet"}}
{{unit "cdmf.unit.lib.editable"}}
{{unit "cdmf.unit.lib.qrcode"}}
{{unit "cdmf.unit.device.type.qr-modal"}}
@ -51,14 +52,41 @@
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i>Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i>Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i>Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i>Removed</span>{{/equal}}
{{#if permissions.CHANGE_DEVICE_STATUS}}
{{#equal device.status "ACTIVE"}}<span><i id="statusIcon"
class="fw fw-success icon-success"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Active"></a>
</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i id="statusIcon"
class="fw fw-warning icon-warning"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Inactive"></a>
</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i id="statusIcon"
class="fw fw-remove icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Blocked"></a>
</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i id="statusIcon"
class="fw fw-delete icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Removed"></a>
</span>{{/equal}}
{{else}}
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i> Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
{{/if}}
</td>
</tr>
{{/if}}

@ -210,7 +210,10 @@ function onRequest(context) {
{"name" : "deviceId", "value" : deviceId}
];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var permissions = userModule.getUIPermissions();
deviceViewData["autoCompleteParams"] = autoCompleteParams;
deviceViewData["permissions"] = permissions;
deviceViewData["portalUrl"] = devicemgtProps['portalURL'];
deviceViewData["anchor"] = encodeURI(JSON.stringify({ "device" : { "id" : deviceId, "type" : deviceType}}));

@ -81,6 +81,62 @@ var InitiateViewOption = null;
}
});
$('#status').on('save', function (e, params) {
var deviceStatus = params.submitValue.toUpperCase();
var serviceUrl = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceIdentifier
+ "/changestatus?newStatus=" + deviceStatus;
var payload = null;
if (serviceUrl) {
var successCallback = function (jqXHR, status, resp) {
if (resp.status == 200) {
setTimeout(function () {
if (deviceStatus == "REMOVED") {
$('#statusIcon').removeClass().addClass('fw fw-delete icon-danger');
} else if (deviceStatus == "INACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-warning icon-warning');
} else if (deviceStatus == "ACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-success icon-success');
}
$("#statusIcon").show();
}, 1500);
} else {
console.log(resp.status);
}
};
invokerUtil.put(serviceUrl, payload,
successCallback, function (message) {
console.log(message);
});
}
});
$("#status").click(function () {
$("#statusIcon").hide();
});
$.fn.editable.defaults.mode = 'inline';
$('#status').editable({
value: $('#status').attr("selectedValue"),
source: [
{value: 'Active', text: 'Active'},
{value: "Inactive", text: 'Inactive'},
{value: "Removed", text: 'Removed'}
],
success: this.update_elements
});
$.fn.editableform.buttons =
'<button id="checkedBtn" type="submit" class="btn btn-primary btn-sm editable-submit">' +
'<i class="fw fw-check"></i>' +
'</button>' +
'<button type="button" class="btn btn-secondary btn-sm editable-cancel">' +
'<i class="fw fw-cancel"></i>' +
'</button>';
function positionArrow(selectedTab) {
var selectedTabHeight = $(selectedTab).innerHeight();

@ -19,8 +19,11 @@
var map;
function loadLeafletMap() {
var deviceLocationID = "#device-location",
locations = $(deviceLocationID).data("locations"),
location_lat = $(deviceLocationID).data("lat"),
location_long = $(deviceLocationID).data("long"),
container = "device-location",
zoomLevel = 13,
tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
@ -46,6 +49,19 @@ function loadLeafletMap() {
$("#map-error").hide();
$("#device-location").show();
} else if (location_long && location_lat) {
map = L.map(container).setView([location_lat, location_long], zoomLevel);
L.tileLayer(tileSet, {attribution: attribution}).addTo(map);
var m = L.marker([location_lat, location_long], {"opacity": opacVal}).addTo(map).bindPopup("Your device is here");
m.on('mouseover', function (e) {
this.openPopup();
});
m.on('mouseout', function (e) {
this.closePopup();
});
} else {
$("#device-location").hide();
$("#map-error").show();
@ -56,4 +72,4 @@ $(document).ready(function () {
$(".location_tab").on("click", function () {
loadLeafletMap();
});
});
});

@ -22,7 +22,7 @@
<parent>
<artifactId>android-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>mobile-plugins</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -21,7 +21,7 @@
<parent>
<artifactId>windows-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -179,7 +179,7 @@ public interface DeviceManagementAdminService {
value = "Dis-enrol the windows Devices",
notes = "Dis-enroll on Android devices",
response = Activity.class,
tags = "Windows Device Management Administrative Service.",
tags = "Windows Device Management Administrative Service",
extensions = {
@Extension(properties = {
@ExtensionProperty(name = Constants.SCOPE, value = "perm:windows:disenroll")

@ -41,6 +41,7 @@ import javax.xml.ws.soap.SOAPBinding;
@BindingType(value = SOAPBinding.SOAP12HTTP_BINDING)
public interface DiscoveryService {
@POST
@RequestWrapper(localName = "Discover", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)
@WebMethod(operationName = "Discover")
@ResponseWrapper(localName = "DiscoverResponse", targetNamespace = PluginConstants.DISCOVERY_SERVICE_TARGET_NAMESPACE)

@ -17,7 +17,10 @@
*/
package org.wso2.carbon.device.mgt.mobile.windows.api.services.syncml;
import org.w3c.dom.Document;
import org.wso2.carbon.apimgt.annotations.api.Scope;
import org.wso2.carbon.apimgt.annotations.api.Scopes;
import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagementException;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.PluginConstants;
import org.wso2.carbon.device.mgt.mobile.windows.api.common.exceptions.WindowsConfigurationException;
@ -36,6 +39,16 @@ import javax.ws.rs.core.Response;
*/
@Path("/devicemanagement")
@Scopes(
scopes = {
@Scope(
name = "Pending operations",
description = "Register an Windows device",
key = "perm:windows:enroll",
permissions = {"/device-mgt/devices/enroll/windows"}
)
}
)
public interface SyncmlService {
@Path("/request")

@ -23,13 +23,13 @@
<parent>
<artifactId>windows-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.windows.ui</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<name>WSO2 Carbon - Mobile Windows UI</name>
<packaging>pom</packaging>

@ -1,4 +1,5 @@
{{unit "cdmf.unit.device.type.windows.leaflet"}}
{{unit "cdmf.unit.lib.editable"}}
{{unit "cdmf.unit.lib.qrcode"}}
{{unit "cdmf.unit.device.type.qr-modal"}}
@ -51,14 +52,41 @@
<tr role="row" class="even">
<td class="sorting_1" style="padding:10px 15px; width: 15%;">Status</td>
<td style="padding:10px 15px;">
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i>Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i>Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i>Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i>Removed</span>{{/equal}}
{{#if permissions.CHANGE_DEVICE_STATUS}}
{{#equal device.status "ACTIVE"}}<span><i id="statusIcon"
class="fw fw-success icon-success"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Active"></a>
</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i id="statusIcon"
class="fw fw-warning icon-warning"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Inactive"></a>
</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i id="statusIcon"
class="fw fw-remove icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Blocked"></a>
</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i id="statusIcon"
class="fw fw-delete icon-danger"></i>
<a href="#" id="status" data-type="select" data-pk="1"
data-title="Select status"
selectedValue="Removed"></a>
</span>{{/equal}}
{{else}}
{{#equal device.status "ACTIVE"}}<span><i
class="fw fw-success icon-success"></i> Active</span>{{/equal}}
{{#equal device.status "INACTIVE"}}<span><i
class="fw fw-warning icon-warning"></i> Inactive</span>{{/equal}}
{{#equal device.status "BLOCKED"}}<span><i
class="fw fw-remove icon-danger"></i> Blocked</span>{{/equal}}
{{#equal device.status "REMOVED"}}<span><i
class="fw fw-delete icon-danger"></i> Removed</span>{{/equal}}
{{/if}}
</td>
</tr>
{{/if}}

@ -112,6 +112,9 @@ function onRequest(context) {
{"name" : "deviceId", "value" : deviceId}
];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var permissions = userModule.getUIPermissions();
deviceViewData["autoCompleteParams"] = autoCompleteParams;
deviceViewData["permissions"] = permissions;
return deviceViewData;
}

@ -69,8 +69,7 @@ var InitiateViewOption = null;
activeTabPaneCaret.removeClass("fw-up").addClass("fw-down");
activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up");
});
$('.media.tab-responsive a[data-toggle="collapse"]').on('click',function(){
var clickedPanel = $(this).attr('href');
@ -81,6 +80,62 @@ var InitiateViewOption = null;
}
});
$('#status').on('save', function (e, params) {
var deviceStatus = params.submitValue.toUpperCase();
var serviceUrl = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceIdentifier
+ "/changestatus?newStatus=" + deviceStatus;
var payload = null;
if (serviceUrl) {
var successCallback = function (jqXHR, status, resp) {
if (resp.status == 200) {
setTimeout(function () {
if (deviceStatus == "REMOVED") {
$('#statusIcon').removeClass().addClass('fw fw-delete icon-danger');
} else if (deviceStatus == "INACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-warning icon-warning');
} else if (deviceStatus == "ACTIVE") {
$('#statusIcon').removeClass().addClass('fw fw-success icon-success');
}
$("#statusIcon").show();
}, 1500);
} else {
console.log(resp.status);
}
};
invokerUtil.put(serviceUrl, payload,
successCallback, function (message) {
console.log(message);
});
}
});
$("#status").click(function () {
$("#statusIcon").hide();
});
$.fn.editable.defaults.mode = 'inline';
$('#status').editable({
value: $('#status').attr("selectedValue"),
source: [
{value: 'Active', text: 'Active'},
{value: "Inactive", text: 'Inactive'},
{value: "Removed", text: 'Removed'}
],
success: this.update_elements
});
$.fn.editableform.buttons =
'<button id="checkedBtn" type="submit" class="btn btn-primary btn-sm editable-submit">' +
'<i class="fw fw-check"></i>' +
'</button>' +
'<button type="button" class="btn btn-secondary btn-sm editable-cancel">' +
'<i class="fw fw-cancel"></i>' +
'</button>';
function positionArrow(selectedTab) {
var selectedTabHeight = $(selectedTab).innerHeight();

@ -22,7 +22,7 @@
<parent>
<artifactId>windows-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>mobile-plugins</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,13 +23,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>analytics-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.analytics.feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - IoT Server Analytics Feature</name>
<url>http://wso2.org</url>

@ -23,13 +23,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>analytics-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.iot.device.statistics.dashboard.feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - IoT Server Analytics Feature</name>
<url>http://wso2.org</url>

@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>analytics-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

@ -23,13 +23,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>androidsense-plugin-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.androidsense.feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - IoT Server Android Sense Feature</name>
<url>http://wso2.org</url>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>arduino-plugin-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,13 +22,13 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>carbon-device-mgt-plugins-parent</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>device-types-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Device Management IoT Plugins Feature</name>
<url>http://wso2.org</url>

@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>raspberrypi-plugin-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -1,23 +1,3 @@
#"""
#/**
#* 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.
#**/
#"""
#!/bin/sh
### BEGIN INIT INFO
@ -35,7 +15,7 @@ DESC="This service is used to publish events from the Raspberry Pi to the WSO2 D
NAME=RaspberryStats
DIR=/usr/local/src/RaspberryAgent/src/
DAEMON=$DIR/RaspberryAgent.py
DAEMON=python $DIR/RaspberryAgent.py
DAEMON_NAME=$NAME
SCRIPTNAME=RaspberryService.sh

@ -23,6 +23,7 @@ import logging, logging.handlers
import sys, os, signal, argparse
import running_mode
import time, threading, datetime, calendar
import iotUtils, mqttConnector, Adafruit_DHT, httpServer
# import httplib, ssl
# from functools import wraps
@ -40,7 +41,7 @@ import time, threading, datetime, calendar
# return bar
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PUSH_INTERVAL = 5000 # time interval between successive data pushes in seconds
PUSH_INTERVAL = 2 # time interval between successive data pushes in seconds
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -82,7 +83,7 @@ if args.mode:
running_mode.RUNNING_MODE = args.mode
iotUtils = __import__('iotUtils')
mqttConnector = __import__('mqttConnector')
# httpServer = __import__('httpServer') # python script used to start a http-server to listen for operations
httpServer = __import__('httpServer') # python script used to start a http-server to listen for operations
# (includes the TEMPERATURE global variable)
if running_mode.RUNNING_MODE == 'N':
@ -329,6 +330,7 @@ def main():
# ListenHTTPServerThread() # starts an HTTP Server that listens for operational commands to switch ON/OFF Led
SubscribeToMQTTQueue() # connects and subscribes to an MQTT Queue that receives MQTT commands from the server
TemperatureReaderThread() # initiates and runs the thread to continuously read temperature from DHT Sensor
# time.sleep(2) #wait for agent to connect to broker before publishing data
while True:
try:
if iotUtils.LAST_TEMP > 0: # Push data only if there had been a successful temperature read

@ -72,9 +72,11 @@ def on_publish(client, userdata, mid):
# The callback for when a PUBLISH message to the server when door is open or close
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def publish(msg):
# global mqttClient
global mqttClient
mqttClient.publish(TOPIC_TO_PUBLISH, msg)
def on_subscribe(client, userdata, mid, granted_qos):
print "Successfully subscribed to " + TOPIC_TO_SUBSCRIBE
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# The Main method of the server script
@ -103,6 +105,7 @@ def main():
mqttClient.on_connect = on_connect
mqttClient.on_message = on_message
mqttClient.on_publish = on_publish
mqttClient.on_subscribe = on_subscribe
mqttClient.username_pw_set(iotUtils.AUTH_TOKEN, password = "")
while True:

@ -33,6 +33,17 @@ if [ ! -d "$destination" ]
then
mkdir $destination
fi
# installing dependencies
echo ===Installing Dependencies
sudo apt-get update
sudo apt-get install python-pip
sudo pip install paho-mqtt
#installing ada
sudo apt-get install build-essential python-dev
unzip Adafruit_Python_DHT
sudo python Adafruit_Python_DHT/setup.py install
sudo cp $currentDir/deviceConfig.properties $currentDir/src
sudo cp -r $currentDir/src $destination
sudo chmod +x $destination/src/RaspberryAgent.py

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>virtual-fire-alarm-plugin-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -22,7 +22,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-types-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@ -23,7 +23,7 @@
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions-feature</artifactId>
<version>3.0.11-SNAPSHOT</version>
<version>3.0.12-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save