Merge branch 'release-2.0.x' of https://github.com/wso2/carbon-device-mgt into release-2.0.x

merge-requests/7/head
kamidu 8 years ago
commit fb89476e16

@ -144,6 +144,7 @@
org.wso2.carbon.event.output.adapter.core, org.wso2.carbon.event.output.adapter.core,
org.wso2.carbon.event.output.adapter.core.exception, org.wso2.carbon.event.output.adapter.core.exception,
org.osgi.framework, org.osgi.framework,
org.wso2.carbon.device.mgt.core.operation.mgt,
org.wso2.carbon.core org.wso2.carbon.core
</Import-Package> </Import-Package>
</instructions> </instructions>

@ -22,17 +22,21 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.policy.mgt.Profile;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext; import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException; import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder; import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder;
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants; import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants;
import org.wso2.carbon.event.output.adapter.core.MessageType; import org.wso2.carbon.event.output.adapter.core.MessageType;
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration;
import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException;
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -57,7 +61,7 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME, configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME,
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME)); config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME));
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD, configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD,
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD)); config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_PASSWORD));
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION, configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION,
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION)); config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION));
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_SCOPES, configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_SCOPES,
@ -79,23 +83,48 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
@Override @Override
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException { public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
Map<String, String> dynamicProperties = new HashMap<>();
Operation operation = ctx.getOperation(); Operation operation = ctx.getOperation();
Properties properties = operation.getProperties(); Properties properties = operation.getProperties();
if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) { if (properties != null && properties.get(MQTT_ADAPTER_TOPIC) != null) {
Map<String, String> dynamicProperties = new HashMap<>();
dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC)); dynamicProperties.put("topic", (String) properties.get(MQTT_ADAPTER_TOPIC));
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
operation.getPayLoad());
} else { } else {
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/" if (PolicyOperation.POLICY_OPERATION_CODE.equals(operation.getCode())) {
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType() PolicyOperation policyOperation = (PolicyOperation) operation;
.toString().toLowerCase() + "/" + operation.getCode(); List<ProfileOperation> profileOperations = policyOperation.getProfileOperations();
dynamicProperties.put("topic", topic); String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true);
if (operation.getPayLoad() == null) { String deviceType = ctx.getDeviceId().getType();
operation.setPayLoad(""); String deviceId = ctx.getDeviceId().getId();
for (ProfileOperation profileOperation : profileOperations) {
Map<String, String> dynamicProperties = new HashMap<>();
String topic = tenantDomain + "/"
+ deviceType + "/" + deviceId + "/" + profileOperation.getType()
.toString().toLowerCase() + "/" + profileOperation.getCode().toLowerCase();
dynamicProperties.put("topic", topic);
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
profileOperation.getPayLoad());
}
} else {
Map<String, String> dynamicProperties = new HashMap<>();
String topic = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain(true) + "/"
+ ctx.getDeviceId().getType() + "/" + ctx.getDeviceId().getId() + "/" + operation.getType()
.toString().toLowerCase() + "/" + operation.getCode();
dynamicProperties.put("topic", topic);
if (operation.getPayLoad() == null) {
operation.setPayLoad("");
}
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
operation.getPayLoad());
} }
} }
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(mqttAdapterName, dynamicProperties,
operation.getPayLoad());
} }
@Override @Override
@ -109,3 +138,4 @@ public class MQTTNotificationStrategy implements NotificationStrategy {
} }
} }

@ -72,7 +72,7 @@ import javax.ws.rs.core.Response;
"Further, this is strictly restricted to admin users only ") "Further, this is strictly restricted to admin users only ")
public interface UserManagementAdminService { public interface UserManagementAdminService {
@PUT @POST
@Path("/{username}/credentials") @Path("/{username}/credentials")
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,

@ -89,7 +89,7 @@
<filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class> <filter-class>org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter</filter-class>
<init-param> <init-param>
<param-name>patterns</param-name> <param-name>patterns</param-name>
<param-value>"text/html*","application/json*","text/plain*"</param-value> <param-value>text/html" ,application/json" ,text/plain</param-value>
</init-param> </init-param>
<init-param> <init-param>
<param-name>filterAction</param-name> <param-name>filterAction</param-name>

@ -141,6 +141,39 @@
"perm:admin:certificates:view", "perm:admin:certificates:view",
"perm:admin:certificates:add", "perm:admin:certificates:add",
"perm:admin:certificates:verify", "perm:admin:certificates:verify",
"perm:ios:enroll",
"perm:ios:view-device",
"perm:ios:apn",
"perm:ios:ldap",
"perm:ios:enterprise-app",
"perm:ios:store-application",
"perm:ios:remove-application",
"perm:ios:app-list",
"perm:ios:profile-list",
"perm:ios:lock",
"perm:ios:enterprise-wipe",
"perm:ios:device-info",
"perm:ios:restriction",
"perm:ios:email",
"perm:ios:cellular",
"perm:ios:applications",
"perm:ios:wifi",
"perm:ios:ring",
"perm:ios:location",
"perm:ios:notification",
"perm:ios:airplay",
"perm:ios:caldav",
"perm:ios:cal-subscription",
"perm:ios:passcode-policy",
"perm:ios:webclip",
"perm:ios:vpn",
"perm:ios:per-app-vpn",
"perm:ios:app-to-per-app-vpn",
"perm:ios:app-lock",
"perm:ios:clear-passcode",
"perm:ios:remove-profile",
"perm:ios:get-restrictions",
"perm:ios:wipe-data",
"perm:admin" "perm:admin"
], ],
"isOAuthEnabled" : true, "isOAuthEnabled" : true,

@ -29,7 +29,8 @@ var carbonServer = new carbonModule.server.Server({
application.put("carbonServer", carbonServer); application.put("carbonServer", carbonServer);
var permissions = { var permissions = {
"/permission/admin/Login": ["ui.execute"] "/permission/admin/Login": ["ui.execute"],
"/permission/admin/manage/api/subscribe": ["ui.execute"]
}; };
var adminPermissions = { var adminPermissions = {

@ -117,15 +117,44 @@ var invokers = function () {
log.debug("Response status : " + xmlHttpRequest.status); log.debug("Response status : " + xmlHttpRequest.status);
log.debug("Response payload if any : " + xmlHttpRequest.responseText); log.debug("Response payload if any : " + xmlHttpRequest.responseText);
if (xmlHttpRequest.status == 401 && (xmlHttpRequest.responseText == TOKEN_EXPIRED || if (xmlHttpRequest.status == 401) {
xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) { if ((xmlHttpRequest.responseText == TOKEN_EXPIRED ||
tokenUtil.refreshTokenPair(); xmlHttpRequest.responseText == TOKEN_INVALID ) && count < 5) {
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers); tokenUtil.refreshTokenPair();
} else { return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
} else if (privateMethods.isInvalidCredential(xmlHttpRequest.responseText)) {
tokenUtil.refreshTokenPair();
return privateMethods.execute(httpMethod, requestPayload, endpoint, responseCallback, ++count, headers);
}
} else {
return responseCallback(xmlHttpRequest); return responseCallback(xmlHttpRequest);
} }
}; };
/**
* This method verify whether the access token is expired using response payload.
* This is required when using API gateway.
* @param responsePayload response payload.
* return true if it is invalid otherwise false.
*/
privateMethods["isInvalidCredential"] =
function (responsePayload) {
if (responsePayload) {
try {
payload = parse(responsePayload);
if (payload["fault"]["code"] == 900901) {
log.debug("Access token is invalid: " + payload["fault"]["code"]);
log.debug(payload["fault"]["description"]);
return true;
}
} catch (err) {
// do nothing
}
}
return false;
};
/** /**
* This method add Oauth authentication header to outgoing XML-HTTP Requests if Oauth authentication is enabled. * This method add Oauth authentication header to outgoing XML-HTTP Requests if Oauth authentication is enabled.
* @param httpMethod HTTP request type. * @param httpMethod HTTP request type.

@ -273,6 +273,7 @@ $.fn.datatables_extended_serverside_paging = function (settings, url, dataFilter
thisTable.removeClass("table-selectable"); thisTable.removeClass("table-selectable");
$(button).addClass("active").html('Select'); $(button).addClass("active").html('Select');
$(button).parent().next().children().addClass("disabled"); $(button).parent().next().children().addClass("disabled");
$('.DTTT_selected.selected').removeClass(rowSelectedClass);
// EMM related function // EMM related function
$(document).on('click', '.viewEnabledIcon', InitiateViewOption); $(document).on('click', '.viewEnabledIcon', InitiateViewOption);
//--- End of EMM related codes //--- End of EMM related codes

Loading…
Cancel
Save