mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
few changes in real time analytics
This commit is contained in:
parent
22f4a9e2af
commit
d650e86e00
@ -20,6 +20,6 @@
|
|||||||
<eventPublisher name="android_sense_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
<eventPublisher name="android_sense_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
||||||
<from streamName="org.wso2.iot.android.sense" version="1.0.0"/>
|
<from streamName="org.wso2.iot.android.sense" version="1.0.0"/>
|
||||||
<mapping customMapping="disable" type="wso2event"/>
|
<mapping customMapping="disable" type="wso2event"/>
|
||||||
<to eventAdapterType="iot-ui"/>
|
<to eventAdapterType="secured-ui"/>
|
||||||
</eventPublisher>
|
</eventPublisher>
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,6 @@
|
|||||||
<eventPublisher name="temperature_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
<eventPublisher name="temperature_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
||||||
<from streamName="org.wso2.iot.devices.temperature" version="1.0.0"/>
|
<from streamName="org.wso2.iot.devices.temperature" version="1.0.0"/>
|
||||||
<mapping customMapping="disable" type="wso2event"/>
|
<mapping customMapping="disable" type="wso2event"/>
|
||||||
<to eventAdapterType="iot-ui"/>
|
<to eventAdapterType="secured-ui"/>
|
||||||
</eventPublisher>
|
</eventPublisher>
|
||||||
|
|
||||||
|
|||||||
@ -135,8 +135,17 @@
|
|||||||
org.wso2.carbon.databridge.commons,
|
org.wso2.carbon.databridge.commons,
|
||||||
org.wso2.carbon.event.stream.core,
|
org.wso2.carbon.event.stream.core,
|
||||||
org.wso2.carbon.event.stream.core.exception,
|
org.wso2.carbon.event.stream.core.exception,
|
||||||
org.wso2.carbon.utils
|
org.wso2.carbon.utils,
|
||||||
|
javax.xml.bind,
|
||||||
|
javax.xml.bind.annotation,
|
||||||
|
javax.xml.parsers; version=0.0.0,
|
||||||
|
org.w3c.dom,
|
||||||
|
org.wso2.carbon.identity.oauth2.stub,
|
||||||
|
org.wso2.carbon.identity.oauth2.stub.dto,
|
||||||
|
org.wso2.carbon.user.api,
|
||||||
|
org.wso2.carbon.utils.multitenancy
|
||||||
</Import-Package>
|
</Import-Package>
|
||||||
|
<DynamicImport-Package>*</DynamicImport-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||||||
})
|
})
|
||||||
public class Authenticator {
|
public class Authenticator {
|
||||||
|
|
||||||
@XmlElement(name = "Properties", required = true)
|
@XmlElement(name = "Properties", required = false)
|
||||||
protected Properties properties;
|
protected Properties properties;
|
||||||
@XmlAttribute(name = "class")
|
@XmlAttribute(name = "class")
|
||||||
protected String clazz;
|
protected String clazz;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||||||
})
|
})
|
||||||
public class Authorizer {
|
public class Authorizer {
|
||||||
|
|
||||||
@XmlElement(name = "Properties", required = true)
|
@XmlElement(name = "Properties", required = false)
|
||||||
protected Properties properties;
|
protected Properties properties;
|
||||||
@XmlAttribute(name = "class")
|
@XmlAttribute(name = "class")
|
||||||
protected String clazz;
|
protected String clazz;
|
||||||
|
|||||||
@ -38,9 +38,6 @@ public class WebsocketConfig {
|
|||||||
Unmarshaller unmarshaller = ctx.createUnmarshaller();
|
Unmarshaller unmarshaller = ctx.createUnmarshaller();
|
||||||
//unmarshaller.setSchema(getSchema());
|
//unmarshaller.setSchema(getSchema());
|
||||||
websocketValidationConfigs = (WebsocketValidationConfigs) unmarshaller.unmarshal(doc);
|
websocketValidationConfigs = (WebsocketValidationConfigs) unmarshaller.unmarshal(doc);
|
||||||
if (websocketValidationConfigs != null) {
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
throw new WebsocketValidationConfigurationFailedException("Error occurred while un-marshalling Websocket" +
|
throw new WebsocketValidationConfigurationFailedException("Error occurred while un-marshalling Websocket" +
|
||||||
" Config", e);
|
" Config", e);
|
||||||
|
|||||||
@ -4,6 +4,7 @@ package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config;
|
|||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
|
|
||||||
@ -27,11 +28,9 @@ import javax.xml.bind.annotation.XmlType;
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@XmlRootElement(name = "WebsocketValidationConfigs")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
@XmlType(name = "WebsocketValidationConfigs", propOrder = {
|
|
||||||
"authenticator",
|
|
||||||
"authorizer"
|
|
||||||
})
|
|
||||||
public class WebsocketValidationConfigs {
|
public class WebsocketValidationConfigs {
|
||||||
|
|
||||||
@XmlElement(name = "Authenticator", required = true)
|
@XmlElement(name = "Authenticator", required = true)
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class UIEventAdapterConstants {
|
|||||||
private 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_PREFIX = "ui.usage.tips_prefix";
|
||||||
public static final String ADAPTER_USAGE_TIPS_POSTFIX = "ui.usage.tips_postfix";
|
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";
|
public static final String ADAPTER_UI_DEFAULT_OUTPUT_STREAM_VERSION = "1.0.0";
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl;
|
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.io.FileUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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 MQTT_PROTOCOL = "MQTT";
|
||||||
private static final String KEY_TYPE = "PRODUCTION";
|
private static final String KEY_TYPE = "PRODUCTION";
|
||||||
private static ApiApplicationKey apiApplicationKey;
|
private static ApiApplicationKey apiApplicationKey;
|
||||||
|
private static final String DEVICE_MGT_SCOPE_IDENTIFIER = "device-mgt";
|
||||||
private static Log log = LogFactory.getLog(VirtualFireAlarmServiceImpl.class);
|
private static Log log = LogFactory.getLog(VirtualFireAlarmServiceImpl.class);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@ -309,10 +311,13 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService {
|
|||||||
VirtualFireAlarmConstants.DEVICE_TYPE, tags, KEY_TYPE, applicationUsername, true);
|
VirtualFireAlarmConstants.DEVICE_TYPE, tags, KEY_TYPE, applicationUsername, true);
|
||||||
}
|
}
|
||||||
JWTClient jwtClient = APIUtil.getJWTClientManagerService().getJWTClient();
|
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<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("device", Base64.encodeBase64String(device.getBytes()));
|
||||||
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(),
|
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(),
|
||||||
apiApplicationKey.getConsumerSecret(), owner,
|
apiApplicationKey.getConsumerSecret(), owner,
|
||||||
scopes);
|
null, params);
|
||||||
String accessToken = accessTokenInfo.getAccessToken();
|
String accessToken = accessTokenInfo.getAccessToken();
|
||||||
String refreshToken = accessTokenInfo.getRefreshToken();
|
String refreshToken = accessTokenInfo.getRefreshToken();
|
||||||
XmppAccount newXmppAccount = new XmppAccount();
|
XmppAccount newXmppAccount = new XmppAccount();
|
||||||
|
|||||||
@ -22,12 +22,23 @@ function onRequest(context) {
|
|||||||
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
|
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
|
||||||
var constants = require("/app/modules/constants.js");
|
var constants = require("/app/modules/constants.js");
|
||||||
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
|
var websocketEndpoint = devicemgtProps["wssURL"].replace("https", "wss");
|
||||||
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
|
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 = "";
|
var token = "";
|
||||||
if (tokenPair) {
|
if (tokenPair) {
|
||||||
token = tokenPair.accessToken;
|
token = tokenPair.accessToken;
|
||||||
}
|
}
|
||||||
websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" +
|
websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.devices.temperature/1.0.0?" +
|
||||||
"token=" + token + "&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
|
"token=" + token + "&deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type;
|
||||||
|
}
|
||||||
return {"device": device, "websocketEndpoint" : websocketEndpoint};
|
return {"device": device, "websocketEndpoint" : websocketEndpoint};
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user