few changes in real time analytics

application-manager-new
ayyoob 9 years ago
parent 2df0515585
commit 971fd80b83

@ -1213,7 +1213,7 @@
</file> </file>
<file> <file>
<source> <source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/websocket-validation.properties ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/websocket-validation.xml
</source> </source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/etc</outputDirectory> <outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/etc</outputDirectory>
<filtered>true</filtered> <filtered>true</filtered>
@ -1246,6 +1246,15 @@
<fileMode>644</fileMode> <fileMode>644</fileMode>
</file> </file>
<!-- Copying remote-appmanager-config.xml --> <!-- Copying remote-appmanager-config.xml -->
<file>
<source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/device-mgt-scopes.xml
</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/etc</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<!-- Copying devi-appmanager-config.xml -->
<file> <file>
<source> <source>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/remote-appmanager-config.xml ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/remote-appmanager-config.xml

@ -356,11 +356,6 @@
<Scope>device_scope</Scope> <Scope>device_scope</Scope>
</ScopeWhitelist> </ScopeWhitelist>
<!-- This hold the prefix of device scopes. If a device specific token needs to be issues then token
needs to be sent with the prefix of Device Scope with the format of
DeviceScope/DeviceType/DeviceId -->
<DeviceScope>cdmf</DeviceScope>
</APIKeyValidator> </APIKeyValidator>
<!-- <!--

@ -130,7 +130,7 @@
</SupportedGrantType> </SupportedGrantType>
<SupportedGrantType> <SupportedGrantType>
<GrantTypeName>password</GrantTypeName> <GrantTypeName>password</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedPasswordGrantHandler</GrantTypeHandlerImplClass> <GrantTypeHandlerImplClass>org.wso2.carbon.apimgt.keymgt.handlers.ExtendedPasswordGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType> </SupportedGrantType>
<SupportedGrantType> <SupportedGrantType>
<GrantTypeName>refresh_token</GrantTypeName> <GrantTypeName>refresh_token</GrantTypeName>
@ -150,8 +150,13 @@
</SupportedGrantType> </SupportedGrantType>
<SupportedGrantType> <SupportedGrantType>
<GrantTypeName>urn:ietf:params:oauth:grant-type:jwt-bearer</GrantTypeName> <GrantTypeName>urn:ietf:params:oauth:grant-type:jwt-bearer</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedJWTBearerGrantHandler</GrantTypeHandlerImplClass> <GrantTypeHandlerImplClass>org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedDeviceMgtJWTBearerGrantHandler</GrantTypeHandlerImplClass>
<GrantTypeValidatorImplClass>org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator</GrantTypeValidatorImplClass> <GrantTypeValidatorImplClass>org.wso2.carbon.device.mgt.oauth.extensions.validators.ExtendedDeviceJWTGrantValidator</GrantTypeValidatorImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>device-mgt:password</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.device.mgt.oauth.extensions.handlers.grant.ExtendedDeviceMgtPasswordGrantHandler</GrantTypeHandlerImplClass>
<GrantTypeValidatorImplClass>org.wso2.carbon.device.mgt.oauth.extensions.validators.ExtendedDevicePasswordGrantValidator</GrantTypeValidatorImplClass>
</SupportedGrantType> </SupportedGrantType>
</SupportedGrantTypes> </SupportedGrantTypes>
<OAuthCallbackHandlers> <OAuthCallbackHandlers>

@ -40,9 +40,10 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
private static final String CONNECTION_PERMISSION = "/permission/admin/device-mgt/user"; private static final String CONNECTION_PERMISSION = "/permission/admin/device-mgt/user";
private static final String ADMIN_PERMISSION = "/permission/admin/device-mgt/admin"; private static final String ADMIN_PERMISSION = "/permission/admin/device-mgt/admin";
private static final String SCOPE_IDENTIFIER = "scope"; private static final String SCOPE_IDENTIFIER = "scope";
private static final String CDMF_SCOPE_PREFIX = "cdmf";
private static final String CDMF_SCOPE_SEPERATOR = "/";
private static final String UI_EXECUTE = "ui.execute"; private static final String UI_EXECUTE = "ui.execute";
private static final String MQTT_PUBLISHER_SCOPE_IDENTIFIER = "mqtt-publisher";
private static final String MQTT_SUBSCRIBER_SCOPE_IDENTIFIER = "mqtt-subscriber";
private static final String DEVICE_MGT_SCOPE_IDENTIFIER = "device-mgt";
/** /**
* {@inheritDoc} Authorize the user against carbon device mgt model. * {@inheritDoc} Authorize the user against carbon device mgt model.
@ -61,18 +62,21 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
if (!tenantIdFromTopic.equals(authorizationSubject.getTenantDomain())) { if (!tenantIdFromTopic.equals(authorizationSubject.getTenantDomain())) {
return false; return false;
} }
String deviceTypeFromTopic = topics[1]; String deviceType = topics[1];
String deviceIdFromTopic = topics[2]; String deviceId = topics[2];
List<String> scopes = (List<String>) authorizationSubject.getProperties().get(SCOPE_IDENTIFIER); Object scopeObject = authorizationSubject.getProperties().get(SCOPE_IDENTIFIER);
if (scopes != null) {
if (!deviceId.isEmpty() && !deviceType.isEmpty() && scopeObject != null) {
List<String> scopes = (List<String>) scopeObject;
String permissionScope = MQTT_PUBLISHER_SCOPE_IDENTIFIER;
if (permissionLevel == MQTTAuthoriztionPermissionLevel.SUBSCRIBE) {
permissionScope = MQTT_SUBSCRIBER_SCOPE_IDENTIFIER;
}
String requiredScope = DEVICE_MGT_SCOPE_IDENTIFIER + ":" + deviceType + ":" + deviceId + ":"
+ permissionScope;
for (String scope : scopes) { for (String scope : scopes) {
if (scope.startsWith(CDMF_SCOPE_PREFIX)) { if (requiredScope.equals(scope)) {
String deviceId[] = scope.split(CDMF_SCOPE_SEPERATOR); return true;
if (deviceId.length == 3) {
if (deviceIdFromTopic.equals(deviceId[2]) && deviceTypeFromTopic.equals(deviceId[1])) {
return true;
}
}
} }
} }
} }

@ -20,6 +20,6 @@
<eventPublisher name="connected_cup_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <eventPublisher name="connected_cup_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.connectedcup" version="1.0.0"/> <from streamName="org.wso2.iot.connectedcup" 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="EventPublisher_ConnectedLap" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <eventPublisher name="EventPublisher_ConnectedLap" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.connectedlap" version="1.0.0"/> <from streamName="org.wso2.iot.connectedlap" 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="EventPublisher_droneStats" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <eventPublisher name="EventPublisher_droneStats" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.devices.droneStats" version="1.0.0"/> <from streamName="org.wso2.iot.devices.droneStats" 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="firealarm_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <eventPublisher name="firealarm_publisher" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.firealarm" version="1.0.0"/> <from streamName="org.wso2.iot.firealarm" 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>

@ -20,6 +20,6 @@
<eventPublisher name="EventPublisher_${nameOfTheSensor}" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher"> <eventPublisher name="EventPublisher_${nameOfTheSensor}" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
<from streamName="org.wso2.iot.devices.${nameOfTheSensor}" version="1.0.0"/> <from streamName="org.wso2.iot.devices.${nameOfTheSensor}" version="1.0.0"/>
<mapping customMapping="disable" type="wso2event"/> <mapping customMapping="disable" type="wso2event"/>
<to eventAdapterType="iot-ui"/> <to eventAdapterType="secured-ui"/>
</eventPublisher> </eventPublisher>

Loading…
Cancel
Save