The following schema fragment specifies the expected content contained within this class.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
property;
+
+ /**
+ * Gets the value of the property property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set
method for the property property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getProperty().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link Property }
+ *
+ *
+ */
+ public List getProperty() {
+ if (property == null) {
+ property = new ArrayList();
+ }
+ return this.property;
+ }
+
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Property.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Property.java
new file mode 100644
index 000000000..252e3ae48
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Property.java
@@ -0,0 +1,104 @@
+/*
+ * 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.output.adapter.ui.config;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+
+
+/**
+ * Java class for Property complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ * <complexType name="Property">
+ * <simpleContent>
+ * <extension base="<http://www.w3.org/2001/XMLSchema>string">
+ * <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ * </extension>
+ * </simpleContent>
+ * </complexType>
+ *
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "Property", propOrder = {
+ "value"
+})
+public class Property {
+
+ @XmlValue
+ protected String value;
+ @XmlAttribute(name = "name")
+ protected String name;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the name property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setName(String value) {
+ this.name = value;
+ }
+
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketConfig.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketConfig.java
new file mode 100644
index 000000000..ee44677d3
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketConfig.java
@@ -0,0 +1,71 @@
+/*
+ * 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.output.adapter.ui.config;
+
+import org.w3c.dom.Document;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.WebsocketUtils;
+import org.wso2.carbon.utils.CarbonUtils;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.File;
+
+/**
+ * This class represents the configuration that are needed for scopes to permission map.
+ */
+public class WebsocketConfig {
+
+ private static WebsocketConfig config = new WebsocketConfig();
+ private WebsocketValidationConfigs websocketValidationConfigs;
+
+ private static final String WEBSOCKET_VALIDATION_CONFIG_PATH =
+ CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + "websocket-validation.xml";
+
+ private WebsocketConfig() {
+ }
+
+ public static WebsocketConfig getInstance() {
+ return config;
+ }
+
+ public void init() throws WebsocketValidationConfigurationFailedException {
+ try {
+ File deviceMgtConfig = new File(WEBSOCKET_VALIDATION_CONFIG_PATH);
+ Document doc = WebsocketUtils.convertToDocument(deviceMgtConfig);
+
+ /* Un-marshaling DeviceMGtScope configuration */
+ JAXBContext ctx = JAXBContext.newInstance(WebsocketValidationConfigs.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ //unmarshaller.setSchema(getSchema());
+ websocketValidationConfigs = (WebsocketValidationConfigs) unmarshaller.unmarshal(doc);
+ } catch (JAXBException e) {
+ throw new WebsocketValidationConfigurationFailedException("Error occurred while un-marshalling Websocket" +
+ " Config", e);
+ }
+ }
+
+ public WebsocketValidationConfigs getWebsocketValidationConfigs() {
+ return websocketValidationConfigs;
+ }
+
+ public void setWebsocketValidationConfigs(WebsocketValidationConfigs websocketValidationConfigs) {
+ websocketValidationConfigs = websocketValidationConfigs;
+ }
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigs.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigs.java
new file mode 100644
index 000000000..cf82fecd5
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigs.java
@@ -0,0 +1,106 @@
+/*
+ * 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.output.adapter.ui.config;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * Java class for WebsocketValidationConfigs complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ * <complexType name="WebsocketValidationConfigs">
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <sequence>
+ * <element name="Authenticator" type="{}Authenticator"/>
+ * <element name="Authorizer" type="{}Authorizer"/>
+ * </sequence>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ *
+ *
+ *
+ */
+
+@XmlRootElement(name = "WebsocketValidationConfigs")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class WebsocketValidationConfigs {
+
+ @XmlElement(name = "Authenticator", required = true)
+ protected Authenticator authenticator;
+ @XmlElement(name = "Authorizer", required = true)
+ protected Authorizer authorizer;
+
+ /**
+ * Gets the value of the authenticator property.
+ *
+ * @return
+ * possible object is
+ * {@link Authenticator }
+ *
+ */
+ public Authenticator getAuthenticator() {
+ return authenticator;
+ }
+
+ /**
+ * Sets the value of the authenticator property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Authenticator }
+ *
+ */
+ public void setAuthenticator(Authenticator value) {
+ this.authenticator = value;
+ }
+
+ /**
+ * Gets the value of the authorizer property.
+ *
+ * @return
+ * possible object is
+ * {@link Authorizer }
+ *
+ */
+ public Authorizer getAuthorizer() {
+ return authorizer;
+ }
+
+ /**
+ * Sets the value of the authorizer property.
+ *
+ * @param value
+ * allowed object is
+ * {@link Authorizer }
+ *
+ */
+ public void setAuthorizer(Authorizer value) {
+ this.authorizer = value;
+ }
+
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigurationFailedException.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigurationFailedException.java
new file mode 100644
index 000000000..766eea3ee
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigurationFailedException.java
@@ -0,0 +1,44 @@
+/*
+ * 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.output.adapter.ui.config;
+
+public class WebsocketValidationConfigurationFailedException extends Exception {
+
+ private static final long serialVersionUID = -3151279329290703928L;
+
+ public WebsocketValidationConfigurationFailedException(String msg, Exception nestedEx) {
+ super(msg, nestedEx);
+ }
+
+ public WebsocketValidationConfigurationFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public WebsocketValidationConfigurationFailedException(String msg) {
+ super(msg);
+ }
+
+ public WebsocketValidationConfigurationFailedException() {
+ super();
+ }
+
+ public WebsocketValidationConfigurationFailedException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java
new file mode 100644
index 000000000..31a9f1dd4
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java
@@ -0,0 +1,35 @@
+/*
+ * 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.output.adapter.ui.constants;
+
+/**
+ * This holds the constants related to this feature
+ */
+public class WebsocketConstants {
+
+ private WebsocketConstants() {
+ }
+
+ public static final String SCOPE_IDENTIFIER = "scopes";
+ public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection";
+ public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost";
+ public static final String TOKEN_VALIDATION_ENDPOINT_URL = "tokenValidationEndpoint";
+ public static final String USERNAME = "username";
+ public static final String PASSWORD = "password";
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java
index dd0894985..024c0228e 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java
@@ -1,5 +1,4 @@
/*
- *
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
@@ -31,10 +30,10 @@ import java.util.concurrent.LinkedBlockingDeque;
public final class UIEventAdaptorServiceDataHolder {
private static UIOutputCallbackControllerServiceImpl UIOutputCallbackRegisterServiceImpl;
- private static ConcurrentHashMap>
- tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap>();
+ private static ConcurrentHashMap>
+ tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap>>
- tenantSpecificStreamEventMap = new ConcurrentHashMap>>();
+ tenantSpecificStreamEventMap = new ConcurrentHashMap<>();
private static EventStreamService eventStreamService;
public static void registerEventStreamService(EventStreamService eventBuilderService) {
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java
index 341d4b377..7e8a12277 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java
@@ -1,5 +1,4 @@
/*
- *
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
@@ -24,6 +23,12 @@ import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIEventAdapterFactory;
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIOutputCallbackControllerServiceImpl;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketConfig;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketValidationConfigurationFailedException;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.service.WebsocketValidationService;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.service.WebsocketValidationServiceImpl;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory;
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIOutputCallbackControllerService;
import org.wso2.carbon.event.stream.core.EventStreamService;
@@ -58,8 +63,37 @@ public class UILocalEventAdapterServiceComponent {
if (log.isDebugEnabled()) {
log.debug("Successfully deployed the output ui adapter service");
}
+ try {
+ WebsocketConfig.getInstance().init();
+ WebsocketValidationServiceImpl websocketValidationService = new WebsocketValidationServiceImpl();
+ String authenticatorClassName = WebsocketConfig.getInstance().getWebsocketValidationConfigs()
+ .getAuthenticator().getClazz();
+ String authorizerClassName = WebsocketConfig.getInstance().getWebsocketValidationConfigs()
+ .getAuthorizer().getClazz();
+ if (authenticatorClassName != null && !authenticatorClassName.isEmpty()) {
+ Class extends Authenticator> authenticatorClass = Class.forName(authenticatorClassName)
+ .asSubclass(Authenticator.class);
+ Authenticator authenticator = authenticatorClass.newInstance();
+ websocketValidationService.setAuthenticator(authenticator);
+ }
+ if (authorizerClassName != null && !authorizerClassName.isEmpty()) {
+ Class extends Authorizer> authorizerClass = Class.forName(authorizerClassName)
+ .asSubclass(Authorizer.class);
+ Authorizer authorizer = authorizerClass.newInstance();
+ websocketValidationService.setAuthorizer(authorizer);
+ }
+ context.getBundleContext().registerService(
+ WebsocketValidationService.class.getName(), websocketValidationService, null);
+ } catch (WebsocketValidationConfigurationFailedException e) {
+ log.error("Failed to initialize configuration for websocket.", e);
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
+ log.error("Failed to initialize the class authentication and authorization given " +
+ "in the websocket validation configuration.", e);
+ }
} catch (RuntimeException e) {
log.error("Can not create the output ui adapter service ", e);
+ } catch (Throwable e) {
+ log.error("Error occurred while activating UI Event Adapter Service Component", e);
}
}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationService.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationService.java
new file mode 100644
index 000000000..7df67d969
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationService.java
@@ -0,0 +1,33 @@
+/*
+ * 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.output.adapter.ui.service;
+
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer;
+
+/**
+ * This returns the configured authenticator and authorizer for websocket.
+ */
+public interface WebsocketValidationService {
+
+ Authenticator getAuthenticator();
+
+ Authorizer getAuthorizer();
+
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationServiceImpl.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationServiceImpl.java
new file mode 100644
index 000000000..e9f6d3d96
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationServiceImpl.java
@@ -0,0 +1,48 @@
+/*
+ * 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.output.adapter.ui.service;
+
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer;
+
+/**
+ * This returns the configured authenticator and authorizer for websocket.
+ */
+public class WebsocketValidationServiceImpl implements WebsocketValidationService{
+ private Authenticator authenticator;
+ private Authorizer authorizer;
+
+ @Override
+ public Authenticator getAuthenticator() {
+ return authenticator;
+ }
+
+ @Override
+ public Authorizer getAuthorizer() {
+ return authorizer;
+ }
+
+ public void setAuthenticator(Authenticator authenticator) {
+ this.authenticator = authenticator;
+ }
+
+ public void setAuthorizer(Authorizer authorizer) {
+ this.authorizer = authorizer;
+ }
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java
index 8fdea199c..d64c1ce4d 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java
@@ -1,22 +1,21 @@
/*
+ * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
- * Copyright (c) 2014-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
*
- * 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.
+ * 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.output.adapter.ui.util;
/**
@@ -27,7 +26,7 @@ public class UIEventAdapterConstants {
private UIEventAdapterConstants() {
}
- public static final String ADAPTER_TYPE_UI = "iot-ui";
+ public static final String ADAPTER_TYPE_UI = "secured-ui";
public static final String ADAPTER_USAGE_TIPS_PREFIX = "ui.usage.tips_prefix";
public static final String ADAPTER_USAGE_TIPS_POSTFIX = "ui.usage.tips_postfix";
public static final String ADAPTER_UI_DEFAULT_OUTPUT_STREAM_VERSION = "1.0.0";
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionUtil.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionRequest.java
similarity index 72%
rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionUtil.java
rename to components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionRequest.java
index 7c083f8f0..822028089 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionUtil.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionRequest.java
@@ -1,5 +1,22 @@
-package org.wso2.carbon.device.mgt.iot.output.adapter.ui.util;
+/*
+ * 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.output.adapter.ui.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -13,15 +30,15 @@ import java.util.Map;
* of the Session object derived from processing some of the (default) existing attributes.
* Ex: Query-String's [Key:Value] Map derived from the queryString attribute of the original class.
*/
-public class WebSocketSessionUtil {
- private static final Log log = LogFactory.getLog(WebSocketSessionUtil.class);
+public class WebSocketSessionRequest {
+ private static final Log log = LogFactory.getLog(WebSocketSessionRequest.class);
private static final String QUERY_STRING_SEPERATOR = "&";
private static final String QUERY_KEY_VALUE_SEPERATOR = "=";
private Map queryParamValuePairs = null;
private Session session;
- public WebSocketSessionUtil(Session session) {
+ public WebSocketSessionRequest(Session session) {
this.session = session;
setQueryParamValuePairs();
}
@@ -42,19 +59,15 @@ public class WebSocketSessionUtil {
if (session.getQueryString() != null) {
String queryString = session.getQueryString();
String[] allQueryParamPairs = queryString.split(QUERY_STRING_SEPERATOR);
-
for (String keyValuePair : allQueryParamPairs) {
String[] thisQueryParamPair = keyValuePair.split(QUERY_KEY_VALUE_SEPERATOR);
-
if (thisQueryParamPair.length != 2) {
log.warn("Invalid query string [" + queryString + "] passed in.");
break;
}
-
if (queryParamValuePairs == null) {
queryParamValuePairs = new HashMap<>();
}
-
queryParamValuePairs.put(thisQueryParamPair[0], thisQueryParamPair[1]);
}
}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebsocketUtils.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebsocketUtils.java
new file mode 100644
index 000000000..c049e4540
--- /dev/null
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebsocketUtils.java
@@ -0,0 +1,45 @@
+/*
+ * 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.output.adapter.ui.util;
+
+import org.w3c.dom.Document;
+import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketValidationConfigurationFailedException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+
+/**
+ * This class holds util methods used by OAuth extension bundle.
+ */
+public class WebsocketUtils {
+
+ public static Document convertToDocument(File file) throws WebsocketValidationConfigurationFailedException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ try {
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ return docBuilder.parse(file);
+ } catch (Exception e) {
+ throw new WebsocketValidationConfigurationFailedException("Error occurred while parsing file, while converting " +
+ "to a org.w3c.dom.Document", e);
+ }
+ }
+
+}
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag
index fb9e2215d..43379ec75 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag
@@ -23,7 +23,7 @@ var uriMatcher = new URIMatcher(String(uri));
var log = new Log("api/policy-api.jag");
var constants = require("/app/modules/constants.js");
-var policyModule = require("/app/modules/policy.js").policyModule;
+var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"];
var deviceType, deviceId;
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js
index 49f417285..d1a58b9bd 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js
@@ -18,7 +18,7 @@
function onRequest(context) {
var log = new Log("operation.js");
- var operationModule = require("/app/modules/operation.js").operationModule;
+ var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"];
var device = context.unit.params.device;
var autoCompleteParams = context.unit.params.autoCompleteParams;
var controlOperations = operationModule.getControlOperations(device.type);
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js
index 36b130ca0..3f4446f30 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js
@@ -19,7 +19,7 @@
function onRequest(context) {
var log = new Log("policy-view-edit-unit backend js");
log.debug("calling policy-view-edit-unit");
- var userModule = require("/app/modules/user.js").userModule;
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
context.roles = userModule.getRoles().content;
return context;
}
\ No newline at end of file
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js
index 36b130ca0..3f4446f30 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js
@@ -19,7 +19,7 @@
function onRequest(context) {
var log = new Log("policy-view-edit-unit backend js");
log.debug("calling policy-view-edit-unit");
- var userModule = require("/app/modules/user.js").userModule;
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
context.roles = userModule.getRoles().content;
return context;
}
\ No newline at end of file
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js
index 49c02f84a..dfe34da91 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js
@@ -22,7 +22,7 @@ function onRequest(context) {
var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType";
var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label";
- var userModule = require("/app/modules/user.js")["userModule"];
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var utility = require('/app/modules/utility.js').utility;
var response = userModule.getRoles();
var wizardPage = {};
diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java
index 113015fce..fbdc9b37f 100644
--- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java
+++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot/src/main/java/org/wso2/carbon/device/mgt/iot/devicetype/DeviceTypeConfigServiceImpl.java
@@ -34,7 +34,7 @@ public class DeviceTypeConfigServiceImpl implements DeviceTypeConfigService {
String deviceType = deviceManagementConfiguration.getDeviceType();
String tenantDomain = deviceManagementConfiguration.getDeviceManagementConfigRepository()
.getProvisioningConfig().getTenantDomain();
- if ( deviceType != null && !deviceType.isEmpty() && tenantDomain != null
+ if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null
&& !tenantDomain.isEmpty()) {
deviceTypeConfigurationMap.put(new DeviceTypeConfigIdentifier(deviceType, tenantDomain),
deviceManagementConfiguration);
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java
index c5b26e978..b0c3858c7 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/plugin/impl/RaspberrypiManagerService.java
@@ -28,9 +28,13 @@ import org.wso2.carbon.device.mgt.iot.devicetype.config.DeviceManagementConfigur
import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.constants.RaspberrypiConstants;
import org.wso2.carbon.device.mgt.iot.raspberrypi.plugin.internal.RaspberrypiManagementDataHolder;
+import java.util.HashMap;
+import java.util.Map;
+
public class RaspberrypiManagerService implements DeviceManagementService {
private DeviceManager deviceManager;
+ private PushNotificationConfig pushNotificationConfig;
@Override
public String getType() {
@@ -40,6 +44,21 @@ public class RaspberrypiManagerService implements DeviceManagementService {
@Override
public void init() throws DeviceManagementException {
deviceManager = new RaspberrypiManager();
+ this.pushNotificationConfig = this.populatePushNotificationConfig();
+ }
+
+ private PushNotificationConfig populatePushNotificationConfig() {
+ DeviceManagementConfiguration deviceManagementConfiguration = RaspberrypiManagementDataHolder.getInstance()
+ .getDeviceTypeConfigService().getConfiguration(RaspberrypiConstants.DEVICE_TYPE,
+ RaspberrypiConstants.DEVICE_TYPE_PROVIDER_DOMAIN);
+ org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig sourceConfig =
+ deviceManagementConfiguration.getPushNotificationConfig();
+ Map staticProps = new HashMap<>();
+ for (org.wso2.carbon.device.mgt.iot.devicetype.config.PushNotificationConfig.Property
+ property : sourceConfig.getProperties()) {
+ staticProps.put(property.getName(), property.getValue());
+ }
+ return new PushNotificationConfig(sourceConfig.getPushNotificationProvider(), staticProps);
}
@Override
@@ -64,7 +83,7 @@ public class RaspberrypiManagerService implements DeviceManagementService {
@Override
public PushNotificationConfig getPushNotificationConfig() {
- return null;
+ return pushNotificationConfig;
}
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js
index 3d9d7ef10..d3dcd174b 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js
@@ -29,7 +29,7 @@ function onRequest(context) {
"backendApiUri": devicemgtProps["httpsURL"] + "/raspberrypi/device/stats/"
};
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
- var deviceModule = require("/app/modules/device.js").deviceModule;
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") {
return {
diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js
index e42064688..62305b58e 100644
--- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js
+++ b/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js
@@ -25,7 +25,7 @@ function onRequest(context) {
];
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
- var deviceModule = require("/app/modules/device.js").deviceModule;
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/raspberrypi/", "autoCompleteParams" : autoCompleteParams};
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java
index 315cdb37d..d67f1f300 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java
@@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl;
+import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -82,6 +83,7 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
private static final String MQTT_PROTOCOL = "MQTT";
private static final String KEY_TYPE = "PRODUCTION";
private static ApiApplicationKey apiApplicationKey;
+ private static final String DEVICE_MGT_SCOPE_IDENTIFIER = "device-mgt";
private static Log log = LogFactory.getLog(VirtualFireAlarmServiceImpl.class);
@POST
@@ -309,10 +311,13 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
VirtualFireAlarmConstants.DEVICE_TYPE, tags, KEY_TYPE, applicationUsername, true);
}
JWTClient jwtClient = APIUtil.getJWTClientManagerService().getJWTClient();
- String scopes = "cdmf/" + VirtualFireAlarmConstants.DEVICE_TYPE + "/" + deviceId;
+ String device = "{ \"scope\":\"mqtt-publisher mqtt-subscriber\", \"deviceIdentifiers\":[{\"id\":\""+deviceId+"\", " +
+ "\"type\":\""+VirtualFireAlarmConstants.DEVICE_TYPE+"\"}]}";
+ Map params = new HashMap();
+ params.put("device", Base64.encodeBase64String(device.getBytes()));
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(),
apiApplicationKey.getConsumerSecret(), owner,
- scopes);
+ null, params);
String accessToken = accessTokenInfo.getAccessToken();
String refreshToken = accessTokenInfo.getRefreshToken();
XmppAccount newXmppAccount = new XmppAccount();
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
index aed81d1e3..2ac57e0b8 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java
@@ -45,7 +45,7 @@ public class XmppConfig {
List properties = deviceManagementConfiguration.getPushNotificationConfig()
.getProperties();
String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider();
- if (provider.equals("XMPP")) {
+ if ("XMPP".equals(provider)) {
enabled = true;
}
if (enabled) {
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js
index 276b35824..3aa50cea1 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js
@@ -29,7 +29,7 @@ function onRequest(context) {
"backendApiUri": devicemgtProps["httpsURL"] + "/virtual_firealarm/device/stats/"
};
} else if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
- var deviceModule = require("/app/modules/device.js").deviceModule;
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") {
return {
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js
index 4dd97dd23..2e3ea2abf 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js
@@ -25,7 +25,7 @@ function onRequest(context) {
];
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
- var deviceModule = require("/app/modules/device.js").deviceModule;
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device && device.status != "error") {
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/virtual_firealarm/", "autoCompleteParams" : autoCompleteParams};
diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js
index d5b886085..7493d6897 100644
--- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js
+++ b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js
@@ -22,12 +22,23 @@ function onRequest(context) {
var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
var constants = require("/app/modules/constants.js");
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
- var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
- var token = "";
- if (tokenPair) {
- token = tokenPair.accessToken;
+ var jwtService = carbon.server.osgiService('org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService');
+ var jwtClient = jwtService.getJWTClient();
+ var encodedClientKeys = session.get(constants.ENCODED_CLIENT_KEYS_IDENTIFIER);
+ if (encodedClientKeys) {
+ var tokenUtil = require("/app/modules/util.js").util;
+ var resp = tokenUtil.decode(encodedClientKeys).split(",");
+ var user = session.get(constants.USER_SESSION_KEY);
+ var deviceParam = "{\"scope\":\"stats\",\"deviceIdentifiers\":[{\"id\":\""+device.deviceIdentifier+" \", \"type\":\""+device.type+"\"}]}";
+ var encodedScope = tokenUtil.encode(deviceParam);
+ var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], user.username, null,
+ "{\"device\": \"" +encodedScope+"\"}");
+ var token = "";
+ if (tokenPair) {
+ token = tokenPair.accessToken;
+ }
+ websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" +
+ "token=" + token + "&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
}
- websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" +
- "token="+ token +"&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
return {"device": device, "websocketEndpoint" : websocketEndpoint};
}
\ No newline at end of file
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java
index f324a2d0f..5d1ae59a7 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/exception/GlobalThrowableMapper.java
@@ -57,11 +57,6 @@ public class GlobalThrowableMapper implements ExceptionMapper {
if (e instanceof NotFoundException) {
return ((NotFoundException) e).getResponse();
}
- if (e instanceof ConstraintViolationException) {
- log.error("Constraint violation", e);
- return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json")
- .entity(400l).build();
- }
if (e instanceof UnexpectedServerErrorException) {
log.error("Unexpected server error", e);
return ((UnexpectedServerErrorException) e).getResponse();
@@ -70,9 +65,15 @@ public class GlobalThrowableMapper implements ExceptionMapper {
return ((ParameterValidationException) e).getResponse();
}
if (e instanceof IllegalArgumentException) {
- log.error("Illegal exception.", e);
- return Response.status(Response.Status.BAD_REQUEST).header("Content-Type", "application/json")
- .entity(400l).build();
+ ErrorDTO errorDetail = new ErrorDTO();
+ errorDetail.setCode((long) 400);
+ errorDetail.setMoreInfo("");
+ errorDetail.setMessage("");
+ errorDetail.setDescription(e.getMessage());
+ return Response
+ .status(Response.Status.BAD_REQUEST)
+ .entity(errorDetail)
+ .build();
}
if (e instanceof ClientErrorException) {
log.error("Client error", e);
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java
index 89fc4481a..323da65c0 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidAPIUtils.java
@@ -129,8 +129,14 @@ public class AndroidAPIUtils {
DeviceIDHolder deviceIDHolder = deviceUtils.validateDeviceIdentifiers(deviceIDs);
List validDeviceIds = deviceIDHolder.getValidDeviceIDList();
- Activity activity = getDeviceManagementService().addOperation(
- DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, validDeviceIds);
+ Activity activity = null;
+ if(validDeviceIds.size() > 0) {
+ activity = getDeviceManagementService().addOperation(
+ DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, operation, validDeviceIds);
+ } else {
+ throw new IllegalArgumentException("Invalid device Identifiers found");
+ }
+
// if (activity != null) {
// GCMService gcmService = getGCMService();
// if (gcmService.isGCMEnabled()) {
@@ -142,11 +148,7 @@ public class AndroidAPIUtils {
// getGCMService().sendNotification(operation.getCode(), devices);
// }
// }
- if (!deviceIDHolder.getErrorDeviceIdList().isEmpty()) {
- throw new BadRequestException(
- new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(deviceUtils.
- convertErrorMapIntoErrorMessage(deviceIDHolder.getErrorDeviceIdList())).build());
- }
+
return Response.status(Response.Status.CREATED).entity(activity).build();
}
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js
index da9c9809f..4407e222f 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js
@@ -22,7 +22,7 @@ function onRequest(context) {
var deviceId = request.getParameter("id");
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
- var deviceModule = require("/app/modules/device.js").deviceModule;
+ var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"];
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device) {
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
index 6e61307cd..65734a16c 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json
@@ -1,6 +1,5 @@
{
"appContext": "/emm/",
- "clientName": "emm",
"webAgentContext" : "/emm-web-agent/",
"apiContext": "api",
"httpsURL" : "%https.ip%",
@@ -12,13 +11,23 @@
"enrollmentDir": "/emm-web-agent/enrollment",
"iOSConfigRoot" : "%https.ip%/ios-enrollment/",
"iOSAPIRoot" : "%https.ip%/ios/",
- "dynamicClientRegistrationEndPoint" : "https://localhost:9443/dynamic-client-web/register/",
"adminService": "%https.ip%",
- "idPServer":"%https.ip%/oauth2/token",
- "callBackUrl":"%https.ip%/api/device-mgt/v1.0",
- "adminUser":"admin@carbon.super",
- "adminRole":"admin",
- "usernameLength":30,
+ "oauthProvider": {
+ "appRegistration": {
+ "appType": "webapp",
+ "clientName": "emm",
+ "owner": "admin@carbon.super",
+ "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register",
+ "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants",
+ "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer",
+ "tokenScope": "admin",
+ "callbackUrl": "%https.ip%/api/device-mgt/v1.0"
+ },
+ "tokenServiceURL": "%https.ip%/oauth2/token"
+ },
+ "adminUser": "admin@carbon.super",
+ "adminRole": "admin",
+ "usernameLength": 30,
"pageSize":10,
"ssoConfiguration" : {
"enabled" : false,
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs
index 6d2a34ffc..85b0141d7 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs
@@ -1,3 +1,4 @@
+{{unit "cdmf.unit.lib.qrcode"}}
{{#zone "content"}}
{{#if permissions.VIEW_DASHBOARD}}
{{#if permissions.LIST_DEVICES}}
@@ -47,7 +48,7 @@
View
{{#if permissions.ADD_POLICY}}
-
+
@@ -78,7 +79,7 @@
View
{{#if permissions.ADD_USER}}
-
+
@@ -109,7 +110,7 @@
View
{{#if permissions.ADD_ROLE}}
-
+
@@ -131,15 +132,12 @@
-
- Scan QR code to start enrollment
-
+
Scan QR code to start enrollment
Please scan the QR code using your mobile device to retrieve enrollment URL.
-
-
@@ -150,5 +148,4 @@
{{/zone}}
{{#zone "bottomJs"}}
{{js "js/dashboard.js"}}
- {{js "js/jquery.qrcode.min.js"}}
{{/zone}}
\ No newline at end of file
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js
index 8d4576dd9..8843a908e 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js
@@ -17,7 +17,7 @@
*/
function onRequest(context) {
- var userModule = require("/app/modules/user.js")["userModule"];
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var generalConfig = context.app.conf["generalConfig"];
context["permissions"] = userModule.getUIPermissions();
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js
index 3da1af08a..0b7df0705 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js
@@ -55,10 +55,4 @@ $(document).ready(function () {
if ($("#role-count").data("role-count")) {
updateStats("/api/device-mgt/v1.0/roles?offset=0&limit=1", "#role-count");
}
-});
-
-function toggleEnrollment() {
- $(".modalpopup-content").html($("#qr-code-modal").html());
- generateQRCode(".modalpopup-content .qr-code");
- showPopup();
-}
+});
\ No newline at end of file
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.platform.configuration/configuration.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.platform.configuration/configuration.js
index 354702f18..6265d6047 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.platform.configuration/configuration.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.platform.configuration/configuration.js
@@ -1,6 +1,6 @@
function onRequest(context) {
// var log = new Log("platform-configuration-unit backend js");
- var userModule = require("/app/modules/user.js")["userModule"];
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var typesListResponse = userModule.getPlatforms();
if (typesListResponse["status"] == "success") {
context["types"] = typesListResponse["content"];
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js
index 94f7423c1..836302069 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js
@@ -19,7 +19,7 @@
function onRequest(context) {
var log = new Log("policy-view-edit-unit backend js");
log.debug("calling policy-view-edit-unit");
- var userModule = require("/app/modules/user.js").userModule;
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
context.roles = userModule.getRoles().content;
context.users = userModule.getUsersByUsername().content;
return context;
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js
index 36b130ca0..3f4446f30 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js
@@ -19,7 +19,7 @@
function onRequest(context) {
var log = new Log("policy-view-edit-unit backend js");
log.debug("calling policy-view-edit-unit");
- var userModule = require("/app/modules/user.js").userModule;
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
context.roles = userModule.getRoles().content;
return context;
}
\ No newline at end of file
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js
index 2a2200640..10372ee19 100644
--- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js
@@ -17,7 +17,7 @@
*/
function onRequest(context) {
- var userModule = require("/app/modules/user.js")["userModule"];
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var utility = require('/app/modules/utility.js').utility;
var response = userModule.getRoles();
var wizardPage = {};
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs
new file mode 100644
index 000000000..a89cb0031
--- /dev/null
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs
@@ -0,0 +1,110 @@
+{{!
+ 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.
+}}
+{{#zone "navMenu-icon"}}
+
+
+
+{{/zone}}
+
+{{#zone "navMenu-items"}}
+ {{#if permissions.VIEW_DASHBOARD}}
+
+
+
+ Admin Dashboard
+
+
+ {{/if}}
+ {{#if permissions.LIST_DEVICES_ADMIN}}
+
+
+
+ Device Management
+
+
+ {{else}}
+ {{#if permissions.LIST_OWN_DEVICES}}
+
+
+
+ Device Management
+
+
+ {{/if}}
+ {{/if}}
+
+
User Management
+
+ {{#if permissions.LIST_USERS}}
+ - Users
+ {{/if}}
+
+ {{#if permissions.LIST_ROLES}}
+ - Roles
+ {{/if}}
+
+
+ {{#if permissions.LIST_POLICIES}}
+
Policy Management
+ {{/if}}
+
Configuration Management
+
+
+{{/zone}}
+
+{{#zone "navbarCollapsableRightItems"}}
+
+{{/zone}}
+{{#zone "sidePanes"}}
+
+{{/zone}}
+{{#zone "bottomJs"}}
+
+ {{js "js/nav-menu.js"}}
+{{/zone}}
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js
new file mode 100644
index 000000000..1c257453f
--- /dev/null
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+
+function onRequest(context) {
+ context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
+ if (arguments.length < 3) {
+ throw new Error("Handlebars Helper equal needs 2 parameters");
+ }
+ if (lvalue != rvalue) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+ });
+ var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
+ var mdmProps = require('/app/conf/reader/main.js')["conf"];
+ var constants = require("/app/modules/constants.js");
+ var uiPermissions = userModule.getUIPermissions();
+ context["permissions"] = uiPermissions;
+
+ var links = {
+ "user-mgt": [],
+ "role-mgt": [],
+ "policy-mgt": [],
+ "device-mgt": []
+ };
+
+ // following context.link value comes here based on the value passed at the point
+ // where units are attached to a page zone.
+ // eg: {{unit "appbar" pageLink="users" title="User Management"}}
+ context["currentActions"] = links[context["pageLink"]];
+ context["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"];
+ var isAuthorizedForNotifications =
+ userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/view");
+ var currentUser = session.get(constants["USER_SESSION_KEY"]);
+ context["isAuthorizedForNotifications"] = isAuthorizedForNotifications;
+ context["currentUser"] = currentUser;
+ context["appContext"] = mdmProps["appContext"];
+
+ return context;
+}
\ No newline at end of file
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json
new file mode 100644
index 000000000..6512cb94f
--- /dev/null
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json
@@ -0,0 +1,4 @@
+{
+ "version": "1.0.0",
+ "extends": "cdmf.unit.ui.navbar.nav-menu"
+}
\ No newline at end of file
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/jquery.qrcode.min.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js
old mode 100644
new mode 100755
similarity index 100%
rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/jquery.qrcode.min.js
rename to components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js
new file mode 100644
index 000000000..c15f80b26
--- /dev/null
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js
@@ -0,0 +1,351 @@
+/*
+ * 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.
+ */
+
+var modalPopup = ".wr-modalpopup",
+ modalPopupContainer = modalPopup + " .modalpopup-container",
+ modalPopupContent = modalPopup + " .modalpopup-content";
+
+var emmAdminBasePath = "/api/device-mgt/v1.0";
+
+/*
+ * set popup maximum height function.
+ */
+function setPopupMaxHeight() {
+ var maxHeight = "max-height";
+ var marginTop = "margin-top";
+ var body = "body";
+ $(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30)));
+ $(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2)));
+}
+
+/*
+ * show popup function.
+ */
+function showPopup() {
+ $(modalPopup).show();
+ setPopupMaxHeight();
+}
+
+/*
+ * hide popup function.
+ */
+function hidePopup() {
+ $(modalPopupContent).html("");
+ $(modalPopupContent).removeClass("operation-data");
+ $(modalPopup).hide();
+}
+
+var updateNotificationCount = function (data, textStatus, jqXHR) {
+ if (jqXHR.status == 200 && data) {
+ var responsePayload = JSON.parse(data);
+ var newNotificationsCount = responsePayload.count;
+ if (newNotificationsCount > 0) {
+ $("#notification-bubble").html(newNotificationsCount);
+ }
+// } else {
+// $("#notification-bubble").html("Error");
+// }
+ }
+};
+
+function loadNotificationsPanel() {
+ if ("true" == $("#right-sidebar").attr("is-authorized")) {
+ var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
+ invokerUtil.get(serviceURL, updateNotificationCount, hideNotificationCount);
+ loadNewNotifications();
+ } else {
+ $("#notification-bubble-wrapper").remove();
+ }
+}
+
+function hideNotificationCount(jqXHR) {
+ if (jqXHR.status == 404) {
+ // this means "no new notifications to show"
+ $("#notification-bubble").hide();
+ } else {
+ $("#notification-bubble").html("Error");
+ }
+}
+
+function loadNewNotifications() {
+ var messageSideBar = ".sidebar-messages";
+ if ($("#right-sidebar").attr("is-authorized") == "true") {
+ var notifications = $("#notifications");
+ var currentUser = notifications.data("currentUser");
+
+ $.template("notification-listing", notifications.attr("src"), function (template) {
+ var serviceURL = emmAdminBasePath + "/notifications?status=NEW";
+
+ var successCallback = function (data, textStatus, jqXHR) {
+ if (jqXHR.status == 200 && data) {
+ var viewModel = {};
+ var responsePayload = JSON.parse(data);
+
+ if (responsePayload.notifications) {
+ viewModel.notifications = responsePayload.notifications;
+ if (responsePayload.count > 0) {
+ $(messageSideBar).html(template(viewModel));
+ } else {
+ $(messageSideBar).html("
No new notifications found...
");
+ }
+ } else {
+ $(messageSideBar).html("
Unexpected error occurred while loading new notifications.
");
+ }
+ }
+ };
+ var errorCallback = function (jqXHR) {
+ if (jqXHR.status = 500) {
+ $(messageSideBar).html("
Unexpected error occurred while trying " +
+ "to retrieve any new notifications.
");
+ }
+ };
+ invokerUtil.get(serviceURL, successCallback, errorCallback);
+ });
+ } else {
+ $(messageSideBar).html("
You are not authorized to view notifications
");
+ }
+}
+
+/**
+ * Toggle function for
+ * notification listing sidebar.
+ * @return {Null}
+ */
+$.sidebar_toggle = function (action, target, container) {
+ var elem = '[data-toggle=sidebar]',
+ button,
+ containerOffsetLeft,
+ containerOffsetRight,
+ targetOffsetLeft,
+ targetOffsetRight,
+ targetWidth,
+ targetSide,
+ relationship,
+ pushType,
+ buttonParent;
+
+ var sidebar_window = {
+ update: function (target, container, button) {
+ containerOffsetLeft = $(container).data('offset-left') ? $(container).data('offset-left') : 0;
+ containerOffsetRight = $(container).data('offset-right') ? $(container).data('offset-right') : 0;
+ targetOffsetLeft = $(target).data('offset-left') ? $(target).data('offset-left') : 0;
+ targetOffsetRight = $(target).data('offset-right') ? $(target).data('offset-right') : 0;
+ targetWidth = $(target).data('width');
+ targetSide = $(target).data("side");
+ pushType = $(container).parent().is('body') == true ? 'padding' : 'margin';
+
+ if (button !== undefined) {
+ relationship = button.attr('rel') ? button.attr('rel') : '';
+ buttonParent = $(button).parent();
+ }
+ },
+
+ show: function () {
+ if ($(target).data('sidebar-fixed') == true) {
+ $(target).height($(window).height() - $(target).data('fixed-offset'));
+ }
+ $(target).trigger('show.sidebar');
+ if (targetWidth !== undefined) {
+ $(target).css('width', targetWidth);
+ }
+ $(target).addClass('toggled');
+ if (button !== undefined) {
+ if (relationship !== '') {
+ // Removing active class from all relative buttons
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active");
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false');
+ }
+ // Adding active class to button
+ if (button.attr('data-handle') !== 'close') {
+ button.addClass("active");
+ button.attr('aria-expanded', 'true');
+ }
+ if (buttonParent.is('li')) {
+ if (relationship !== '') {
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().
+ attr('aria-expanded', 'false');
+ }
+ buttonParent.addClass("active");
+ buttonParent.attr('aria-expanded', 'true');
+ }
+ }
+ // Sidebar open function
+ if (targetSide == 'left') {
+ if ((button !== undefined) && (button.attr('data-container-divide'))) {
+ $(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetLeft);
+ }
+ $(target).css(targetSide, targetOffsetLeft);
+ } else if (targetSide == 'right') {
+ if ((button !== undefined) && (button.attr('data-container-divide'))) {
+ $(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetRight);
+ }
+ $(target).css(targetSide, targetOffsetRight);
+ }
+ $(target).trigger('shown.sidebar');
+ },
+
+ hide: function () {
+ $(target).trigger('hide.sidebar');
+ $(target).removeClass('toggled');
+ if (button !== undefined) {
+ if (relationship !== '') {
+ // Removing active class from all relative buttons
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active");
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false');
+ }
+ // Removing active class from button
+ if (button.attr('data-handle') !== 'close') {
+ button.removeClass("active");
+ button.attr('aria-expanded', 'false');
+ }
+ if ($(button).parent().is('li')) {
+ if (relationship !== '') {
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active");
+ $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().
+ attr('aria-expanded', 'false');
+ }
+ }
+ }
+ // Sidebar close function
+ if (targetSide == 'left') {
+ if ((button !== undefined) && (button.attr('data-container-divide'))) {
+ $(container).css(pushType + '-' + targetSide, targetOffsetLeft);
+ }
+ $(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft));
+ } else if (targetSide == 'right') {
+ if ((button !== undefined) && (button.attr('data-container-divide'))) {
+ $(container).css(pushType + '-' + targetSide, targetOffsetRight);
+ }
+ $(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight));
+ }
+ $(target).trigger('hidden.sidebar');
+ }
+ };
+ if (action === 'show') {
+ sidebar_window.update(target, container);
+ sidebar_window.show();
+ }
+ if (action === 'hide') {
+ sidebar_window.update(target, container);
+ sidebar_window.hide();
+ }
+ // binding click function
+ var body = 'body';
+ $(body).off('click', elem);
+ $(body).on('click', elem, function (e) {
+ e.preventDefault();
+ button = $(this);
+ container = button.data('container');
+ target = button.data('target');
+ sidebar_window.update(target, container, button);
+ /**
+ * Sidebar function on data container divide
+ * @return {Null}
+ */
+ if (button.attr('aria-expanded') == 'false') {
+ sidebar_window.show();
+ } else if (button.attr('aria-expanded') == 'true') {
+ sidebar_window.hide();
+ }
+ });
+};
+
+$.fn.collapse_nav_sub = function () {
+ var navSelector = 'ul.nav';
+
+ if (!$(navSelector).hasClass('collapse-nav-sub')) {
+ $(navSelector + ' > li', this).each(function () {
+ var position = $(this).offset().left - $(this).parent().scrollLeft();
+ $(this).attr('data-absolute-position', (position + 5));
+ });
+
+ $(navSelector + ' li', this).each(function () {
+ if ($('ul', this).length !== 0) {
+ $(this).addClass('has-sub');
+ }
+ });
+
+ $(navSelector + ' > li', this).each(function () {
+ $(this).css({
+ 'left': $(this).data('absolute-position'),
+ 'position': 'absolute'
+ });
+ });
+
+ $(navSelector + ' li.has-sub', this).on('click', function () {
+ var elem = $(this);
+ if (elem.attr('aria-expanded') !== 'true') {
+ elem.siblings().fadeOut(100, function () {
+ elem.animate({'left': '15'}, 200, function () {
+ $(elem).first().children('ul').fadeIn(200);
+ });
+ });
+ elem.siblings().attr('aria-expanded', 'false');
+ elem.attr('aria-expanded', 'true');
+ } else {
+ $(elem).first().children('ul').fadeOut(100, function () {
+ elem.animate({'left': $(elem).data('absolute-position')}, 200, function () {
+ elem.siblings().fadeIn(100);
+ });
+ });
+ elem.siblings().attr('aria-expanded', 'false');
+ elem.attr('aria-expanded', 'false');
+ }
+ });
+
+ $(navSelector + ' > li.has-sub ul', this).on('click', function (e) {
+ e.stopPropagation();
+ });
+ $(navSelector).addClass('collapse-nav-sub');
+ }
+};
+
+$(document).ready(function () {
+ loadNotificationsPanel();
+ $.sidebar_toggle();
+
+ $("#right-sidebar").on("click", ".new-notification", function () {
+ var notificationId = $(this).data("id");
+ var redirectUrl = $(this).data("url");
+ var markAsReadNotificationsAPI = "/mdm-admin/notifications/" + notificationId + "/CHECKED";
+ var messageSideBar = ".sidebar-messages";
+
+ invokerUtil.put(
+ markAsReadNotificationsAPI,
+ null,
+ function (data) {
+ data = JSON.parse(data);
+ if (data.statusCode == responseCodes["ACCEPTED"]) {
+ location.href = redirectUrl;
+ }
+ }, function () {
+ var content = "
Warning
" +
+ "Unexpected error occurred while loading notification. Please refresh the page and" +
+ " try again
";
+ $(messageSideBar).html(content);
+ }
+ );
+ });
+
+ if (typeof $.fn.collapse == 'function') {
+ $('.navbar-collapse.tiles').on('shown.bs.collapse', function () {
+ $(this).collapse_nav_sub();
+ });
+ }
+});
diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs
new file mode 100644
index 000000000..82edfc498
--- /dev/null
+++ b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs
@@ -0,0 +1,14 @@
+{{#each notifications}}
+
+
+ {{description}}
+
+{{/each}}
\ No newline at end of file
diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf
index c1df69e78..833314fd0 100644
--- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf
+++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf
@@ -1,4 +1,4 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.adapter_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
-org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.adapter_${feature.version}/websocket-validation.properties,target:${installFolder}/../../conf/etc/websocket-validation.properties,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.adapter_${feature.version}/websocket-validation.xml,target:${installFolder}/../../conf/etc/websocket-validation.xml,overwrite:true);\
diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.properties b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.properties
deleted file mode 100644
index f4b75e2a1..000000000
--- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.properties
+++ /dev/null
@@ -1,25 +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.
-#
-
-#This hold the properties that is used for token validation for the the websocket
-
-tokenValidationEndpoint=https://localhost:9443/services/OAuth2TokenValidationService
-username=admin
-password=admin
-maximumHttpConnectionPerHost=2
-maximumTotalHttpConnection=100
\ No newline at end of file
diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.xml
new file mode 100644
index 000000000..ec880fe00
--- /dev/null
+++ b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+ https://localhost:9443/services/OAuth2TokenValidationService
+ admin
+ admin
+ 2
+ 100
+
+
+
+
+
+
\ No newline at end of file