forked from community/device-mgt-plugins
Merge branch 'master' of https://github.com/wso2/carbon-device-mgt-plugins
commit
a254d9efc4
18
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/AuthenticationInfo.java → 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/authentication/AuthenticationInfo.java
18
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/AuthenticationInfo.java → 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/authentication/AuthenticationInfo.java
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.authentication;
|
||||
|
||||
import javax.websocket.Session;
|
||||
|
||||
/**
|
||||
* This interface is used to authenticate a websocket session
|
||||
*/
|
||||
public interface Authenticator {
|
||||
|
||||
/**
|
||||
* Check whether the client is authenticated to connect.
|
||||
* @param session user object.
|
||||
* @return AuthenicationInfo which contains authentication client information.
|
||||
*/
|
||||
AuthenticationInfo isAutenticated(Session session);
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed 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.authentication;
|
||||
|
||||
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.OAuthTokenValdiator;
|
||||
import javax.websocket.Session;
|
||||
|
||||
public class OAuthAuthenticator implements Authenticator {
|
||||
|
||||
@Override
|
||||
public AuthenticationInfo isAutenticated(Session session) {
|
||||
return OAuthTokenValdiator.getInstance().validateToken(session);
|
||||
}
|
||||
}
|
31
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/oauth/OAuthTokenValdiator.java → 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/authentication/oauth/OAuthTokenValdiator.java
31
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/oauth/OAuthTokenValdiator.java → 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/authentication/oauth/OAuthTokenValdiator.java
20
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/oauth/OAuthTokenValidaterStubFactory.java → 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/authentication/oauth/OAuthTokenValidaterStubFactory.java
20
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/oauth/OAuthTokenValidaterStubFactory.java → 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/authentication/oauth/OAuthTokenValidaterStubFactory.java
13
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/oauth/exception/OAuthTokenValidationException.java → 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/authentication/oauth/exception/OAuthTokenValidationException.java
13
components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/oauth/exception/OAuthTokenValidationException.java → 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/authentication/oauth/exception/OAuthTokenValidationException.java
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.authorization;
|
||||
|
||||
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo;
|
||||
|
||||
import javax.websocket.Session;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Check whether the client is authorized to connect.
|
||||
*/
|
||||
public interface Authorizer {
|
||||
|
||||
/**
|
||||
* Check whether the client is authorized to connect with the stream.
|
||||
* @param authenticationInfo authenticated client information.
|
||||
* @param session request session of the client.
|
||||
* @param stream stream name of the client connecting to.
|
||||
* @return true if authorized else return false.
|
||||
*/
|
||||
boolean isAuthorized(AuthenticationInfo authenticationInfo, Session session, String stream);
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* you may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization;
|
||||
|
||||
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo;
|
||||
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.constants.WebsocketConstants;
|
||||
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.WebSocketSessionRequest;
|
||||
|
||||
import javax.websocket.Session;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This authorizer crossvalidates the request with device id and device type.
|
||||
*/
|
||||
public class DeviceAuthorizer implements Authorizer {
|
||||
private static final String STATS_SCOPE_IDENTIFIER = "stats";
|
||||
private static final String DEVICE_MGT_SCOPE_IDENTIFIER = "device-mgt";
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(AuthenticationInfo authenticationInfo, Session session, String stream) {
|
||||
WebSocketSessionRequest webSocketSessionRequest = new WebSocketSessionRequest(session);
|
||||
Map<String, String> queryParams = webSocketSessionRequest.getQueryParamValuePairs();
|
||||
String deviceId = queryParams.get("deviceId");
|
||||
String deviceType = queryParams.get("deviceType");
|
||||
Object scopeObject = authenticationInfo.getProperties().get(WebsocketConstants.SCOPE_IDENTIFIER);
|
||||
|
||||
if (deviceId != null && !deviceId.isEmpty() && deviceType != null && !deviceType.isEmpty()
|
||||
&& scopeObject != null) {
|
||||
String scopes[] = (String[]) scopeObject;
|
||||
String requiredScope = DEVICE_MGT_SCOPE_IDENTIFIER + ":" + deviceType + ":" + deviceId + ":"
|
||||
+ STATS_SCOPE_IDENTIFIER;
|
||||
for (String scope : scopes) {
|
||||
if (requiredScope.equals(scope)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for Authenticator complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Authenticator">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="Properties" type="{}Properties"/>
|
||||
* </sequence>
|
||||
* <attribute name="class" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "Authenticator", propOrder = {
|
||||
"properties"
|
||||
})
|
||||
public class Authenticator {
|
||||
|
||||
@XmlElement(name = "Properties", required = false)
|
||||
protected Properties properties;
|
||||
@XmlAttribute(name = "class")
|
||||
protected String clazz;
|
||||
|
||||
/**
|
||||
* Gets the value of the properties property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Properties }
|
||||
*
|
||||
*/
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the properties property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Properties }
|
||||
*
|
||||
*/
|
||||
public void setProperties(Properties value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the clazz property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the clazz property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setClazz(String value) {
|
||||
this.clazz = value;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for Authorizer complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Authorizer">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="Properties" type="{}Properties"/>
|
||||
* </sequence>
|
||||
* <attribute name="class" type="{http://www.w3.org/2001/XMLSchema}string" />
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "Authorizer", propOrder = {
|
||||
"properties"
|
||||
})
|
||||
public class Authorizer {
|
||||
|
||||
@XmlElement(name = "Properties", required = false)
|
||||
protected Properties properties;
|
||||
@XmlAttribute(name = "class")
|
||||
protected String clazz;
|
||||
|
||||
/**
|
||||
* Gets the value of the properties property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link Properties }
|
||||
*
|
||||
*/
|
||||
public Properties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the properties property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link Properties }
|
||||
*
|
||||
*/
|
||||
public void setProperties(Properties value) {
|
||||
this.properties = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the clazz property.
|
||||
*
|
||||
* @return
|
||||
* possible object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public String getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the clazz property.
|
||||
*
|
||||
* @param value
|
||||
* allowed object is
|
||||
* {@link String }
|
||||
*
|
||||
*/
|
||||
public void setClazz(String value) {
|
||||
this.clazz = value;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.XmlType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for Properties complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <complexType name="Properties">
|
||||
* <complexContent>
|
||||
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
|
||||
* <sequence>
|
||||
* <element name="Property" type="{}Property" maxOccurs="unbounded" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* </restriction>
|
||||
* </complexContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "Properties", propOrder = {
|
||||
"property"
|
||||
})
|
||||
public class Properties {
|
||||
|
||||
@XmlElement(name = "Property")
|
||||
protected List<Property> property;
|
||||
|
||||
/**
|
||||
* Gets the value of the property property.
|
||||
*
|
||||
* <p>
|
||||
* 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 <CODE>set</CODE> method for the property property.
|
||||
*
|
||||
* <p>
|
||||
* For example, to add a new item, do as follows:
|
||||
* <pre>
|
||||
* getProperty().add(newItem);
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Objects of the following type(s) are allowed in the list
|
||||
* {@link Property }
|
||||
*
|
||||
*
|
||||
*/
|
||||
public List<Property> getProperty() {
|
||||
if (property == null) {
|
||||
property = new ArrayList<Property>();
|
||||
}
|
||||
return this.property;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for Property complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <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>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Java class for WebsocketValidationConfigs complex type.
|
||||
*
|
||||
* <p>The following schema fragment specifies the expected content contained within this class.
|
||||
*
|
||||
* <pre>
|
||||
* <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>
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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";
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
29
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 → 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
29
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 → 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
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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"}}
|
||||
<span class="icon fw-stack">
|
||||
<i class="fw fw-tiles fw-stack-1x toggle-icon-up"></i>
|
||||
</span>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "navMenu-items"}}
|
||||
{{#if permissions.VIEW_DASHBOARD}}
|
||||
<li>
|
||||
<a href="{{@app.context}}">
|
||||
<i class="fw fw-dashboard"></i>
|
||||
Admin Dashboard
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{#if permissions.LIST_DEVICES_ADMIN}}
|
||||
<li>
|
||||
<a href="{{@app.context}}/devices">
|
||||
<i class="fw fw-mobile"></i>
|
||||
Device Management
|
||||
</a>
|
||||
</li>
|
||||
{{else}}
|
||||
{{#if permissions.LIST_OWN_DEVICES}}
|
||||
<li>
|
||||
<a href="{{@app.context}}/devices">
|
||||
<i class="fw fw-mobile"></i>
|
||||
Device Management
|
||||
</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
<li><a><i class="fw fw-user"></i>User Management</a>
|
||||
<ul>
|
||||
{{#if permissions.LIST_USERS}}
|
||||
<li><a href="{{@app.context}}/users"><i class="fw fw-user"></i>Users</a></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if permissions.LIST_ROLES}}
|
||||
<li><a href="{{@app.context}}/roles"><i class="fw fw-bookmark"></i>Roles</a></li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</li>
|
||||
{{#if permissions.LIST_POLICIES}}
|
||||
<li><a href="{{@app.context}}/policies"><i class="fw fw-policy"></i>Policy Management</a></li>
|
||||
{{/if}}
|
||||
<li><a><i class="fw fw-settings"></i>Configuration Management</a>
|
||||
<ul>
|
||||
{{#if permissions.TENANT_CONFIGURATION}}
|
||||
<li><a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>Platform Configurations</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
<!-- todo change the permission and get the related permission -->
|
||||
{{#if permissions.TENANT_CONFIGURATION}}
|
||||
<li><a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>Certificate Configurations</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "navbarCollapsableRightItems"}}
|
||||
<ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right">
|
||||
<li class="visible-inline-block">
|
||||
<!--<a href="{{appContext}}notification-listing" title="Failures of operations on the device side will be listed here">-->
|
||||
<a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content"
|
||||
aria-expanded="false" rel="notifications-sidebar">
|
||||
<span class="icon fw-stack">
|
||||
<i class="fw fw-notification fw-stack-1x"></i>
|
||||
</span>
|
||||
<span class="hidden-xs">Notifications</span>
|
||||
<span class="badge notifications" id="notification-bubble"></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{{/zone}}
|
||||
{{#zone "sidePanes"}}
|
||||
<div class="sidebar-wrapper" id="right-sidebar" is-authorized="{{isAuthorizedForNotifications}}"
|
||||
data-side="right" data-width="320" data-sidebar-fixed="true" data-fixed-offset="50" data-spy="affix"
|
||||
data-offset-top="80">
|
||||
<ul class="sidebar-messages">
|
||||
</ul>
|
||||
<h4 class="text-center"><a href="{{appContext}}notification-listing" class="text-center">Show all notifications</a>
|
||||
</h4>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
<script id="notifications" data-current-user="{{currentUser.username}}"
|
||||
data-image-resource="{{self.publicURL}}/images/" src="{{self.publicURL}}/templates/notifications.hbs"
|
||||
type="text/x-handlebars-template"></script>
|
||||
{{js "js/nav-menu.js"}}
|
||||
{{/zone}}
|
@ -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;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"extends": "cdmf.unit.ui.navbar.nav-menu"
|
||||
}
|
0
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 → 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
vendored
0
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 → 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
vendored
@ -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("<h4 class='text-center'>No new notifications found...</h4>");
|
||||
}
|
||||
} else {
|
||||
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while loading new notifications.</h4>");
|
||||
}
|
||||
}
|
||||
};
|
||||
var errorCallback = function (jqXHR) {
|
||||
if (jqXHR.status = 500) {
|
||||
$(messageSideBar).html("<h4 class ='message-danger'>Unexpected error occurred while trying " +
|
||||
"to retrieve any new notifications.</h4>");
|
||||
}
|
||||
};
|
||||
invokerUtil.get(serviceURL, successCallback, errorCallback);
|
||||
});
|
||||
} else {
|
||||
$(messageSideBar).html("<h4 class ='message-danger'>You are not authorized to view notifications</h4>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 = "<li class='message message-danger'><h4><i class='icon fw fw-error'></i>Warning</h4>" +
|
||||
"<p>Unexpected error occurred while loading notification. Please refresh the page and" +
|
||||
" try again</p></li>";
|
||||
$(messageSideBar).html(content);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
if (typeof $.fn.collapse == 'function') {
|
||||
$('.navbar-collapse.tiles').on('shown.bs.collapse', function () {
|
||||
$(this).collapse_nav_sub();
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,14 @@
|
||||
{{#each notifications}}
|
||||
<li class="message message-info" data-type="selectable" >
|
||||
<h4>
|
||||
<i class="icon fw fw-info"></i>
|
||||
<a href="device?type={{deviceIdentifier.type}}&id={{deviceIdentifier.id}}"
|
||||
data-id="{{notificationId}}"
|
||||
data-url="device?type={{deviceIdentifier.type}}&id={{deviceIdentifier.id}}"
|
||||
class="new-notification" data-click-event="remove-form">
|
||||
Device Type : {{deviceIdentifier.type}}
|
||||
</a>
|
||||
</h4>
|
||||
<p>{{description}}</p>
|
||||
</li>
|
||||
{{/each}}
|
@ -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);\
|
||||
|
@ -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
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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 configuration file represents the configuration that are needed
|
||||
for websocket connection validation
|
||||
-->
|
||||
<WebsocketValidationConfigs>
|
||||
|
||||
<!--Authenticator is holds the information of authticator that is used for websocket-->
|
||||
<Authenticator class="org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.OAuthAuthenticator">
|
||||
<Properties>
|
||||
<Property name="tokenValidationEndpoint">https://localhost:9443/services/OAuth2TokenValidationService</Property>
|
||||
<Property name="username">admin</Property>
|
||||
<Property name="password">admin</Property>
|
||||
<Property name="maximumHttpConnectionPerHost">2</Property>
|
||||
<Property name="maximumTotalHttpConnection">100</Property>
|
||||
</Properties>
|
||||
</Authenticator>
|
||||
|
||||
<!--Authorizer holds the information of the authorizer that is used authorize a connection.-->
|
||||
<Authorizer class="org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.DeviceAuthorizer"></Authorizer>
|
||||
</WebsocketValidationConfigs>
|
Loading…
Reference in new issue