From 1fe9a801028d518c26afcc76b762b44e6da8f6d9 Mon Sep 17 00:00:00 2001 From: Hasitha Amal De Silva Date: Tue, 1 Nov 2016 00:30:39 -0400 Subject: [PATCH] removing MB references from IOTserver pack --- modules/distribution/src/assembly/bin.xml | 26 +++++++++---------- .../pom.xml | 1 + .../DeviceAccessBasedMQTTAuthorizer.java | 8 ++++++ modules/p2-profile-gen/pom.xml | 23 ---------------- pom.xml | 5 ---- 5 files changed, 22 insertions(+), 41 deletions(-) diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index 53cd5216..f936ceed 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -216,7 +216,7 @@ **/api-manager.xml **/sso-idp-config.xml **/application-authentication.xml - **/broker.xml + **/log4j.properties **/nhttp.properties **/passthru-http.properties @@ -574,7 +574,7 @@ 644 - + - + - + @@ -856,12 +856,12 @@ 644 - + @@ -937,11 +937,11 @@ 644 - + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml @@ -994,11 +994,11 @@ ${pom.artifactId}-${pom.version}/repository/database/ 644 - + diff --git a/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml b/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml index 61a8ba37..6bea07b3 100644 --- a/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml +++ b/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml @@ -45,6 +45,7 @@ org.wso2.andes.wso2 andes + 3.1.2 org.wso2.carbon diff --git a/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java b/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java index 3e0adfaf..bd122392 100644 --- a/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java +++ b/modules/iot-extensions/components/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/src/main/java/org/wso2/carbon/andes/extensions/device/mgt/mqtt/authorization/DeviceAccessBasedMQTTAuthorizer.java @@ -53,15 +53,19 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { @Override public boolean isAuthorizedForTopic(MQTTAuthorizationSubject authorizationSubject, String topic, MQTTAuthoriztionPermissionLevel permissionLevel) { + if (isUserAuthorized(authorizationSubject, ADMIN_PERMISSION, UI_EXECUTE)) { + System.out.println("isAuthorizedForTopic - user is auth success !"); return true; } String topics[] = topic.split("/"); if (topics.length < 3) { + System.out.println("isAuthorizedForTopic topic name invalid"); return false; } String tenantIdFromTopic = topics[0]; if (!tenantIdFromTopic.equals(authorizationSubject.getTenantDomain())) { + System.out.println("isAuthorizedForTopic tenantID invalid"); return false; } String deviceType = topics[1]; @@ -78,10 +82,12 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { + permissionScope; for (String scope : scopes) { if (requiredScope.equals(scope)) { + System.out.println("isAuthorizedForTopic - Pass"); return true; } } } + System.out.println("isAuthorizedForTopic - Failed"); return false; } @@ -113,10 +119,12 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer { if (userRealm != null && userRealm.getAuthorizationManager() != null) { return userRealm.getAuthorizationManager().isUserAuthorized(username, permission, action); } + System.out.println("isUserAuthorized failse"); return false; } catch (UserStoreException e) { String errorMsg = String.format("Unable to authorize the user : %s", username); logger.error(errorMsg, e); + System.out.println("isUserAuthorized failed"); return false; } finally { PrivilegedCarbonContext.endTenantFlow(); diff --git a/modules/p2-profile-gen/pom.xml b/modules/p2-profile-gen/pom.xml index 3de7933a..032519fc 100644 --- a/modules/p2-profile-gen/pom.xml +++ b/modules/p2-profile-gen/pom.xml @@ -695,9 +695,6 @@ - - org.wso2.carbon.messaging:org.wso2.carbon.andes.server.feature:${carbon.messaging.version} - org.wso2.carbon.metrics:org.wso2.carbon.metrics.feature:${carbon.metrics.version} @@ -831,10 +828,6 @@ org.wso2.iot.styles.feature.group ${carbon.iot.device.mgt.version} - - org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature.group - ${carbon.iot.device.mgt.version} - @@ -1531,10 +1524,6 @@ - - org.wso2.carbon.andes.server.feature.group - ${carbon.messaging.version} - org.wso2.carbon.metrics.feature.group ${carbon.metrics.version} @@ -1577,23 +1566,11 @@ org.wso2.iot.styles.feature.group ${carbon.iot.device.mgt.version} - - org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature.group - ${carbon.iot.device.mgt.version} - org.wso2.carbon.logging.mgt.feature.group ${carbon.commons.version} - - org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature.group - ${carbon.iot.device.mgt.version} - - - org.wso2.carbon.andes.server.feature.group - ${carbon.messaging.version} - org.wso2.carbon.metrics.feature.group ${carbon.metrics.version} diff --git a/pom.xml b/pom.xml index b5fda535..216a494c 100644 --- a/pom.xml +++ b/pom.xml @@ -1015,11 +1015,6 @@ org.eclipse.paho.client.mqttv3 ${eclipse.paho.version} - - org.wso2.andes.wso2 - andes - ${carbon.messaging.version} -