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

revert-dabc3590
Imesh Chandrasiri 8 years ago
commit 6464fcb615

@ -96,7 +96,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
} }
synchronized(tokenInfo) { synchronized(this) {
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) { if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());

@ -79,10 +79,12 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password); tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
} }
synchronized (this) {
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) { if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token()); tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in()); tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
} }
}
String headerValue = "Bearer " + tokenInfo.getAccess_token(); String headerValue = "Bearer " + tokenInfo.getAccess_token();
template.header("Authorization", headerValue); template.header("Authorization", headerValue);
} }

@ -15,7 +15,7 @@
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
}} }}
{{#if control_operations}} {{#if controlOperations}}
<div class="wr-operations" style="height: 87px; display: block;" <div class="wr-operations" style="height: 87px; display: block;"
xmlns="http://www.w3.org/1999/html"> xmlns="http://www.w3.org/1999/html">
<style> <style>
@ -35,7 +35,7 @@
color: #B8B8B8; color: #B8B8B8;
} }
</style> </style>
{{#each control_operations}} {{#each controlOperations}}
<a href="javascript:operationSelect('{{operation}}')"> <a href="javascript:operationSelect('{{operation}}')">
{{#if iconFont}} {{#if iconFont}}
<i class="fw {{iconFont}}"></i> <i class="fw {{iconFont}}"></i>

@ -19,28 +19,37 @@
function onRequest(context) { function onRequest(context) {
var log = new Log("operation.js"); var log = new Log("operation.js");
var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"]; var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var device = context.unit.params.device; var device = context.unit.params.device;
var autoCompleteParams = context.unit.params.autoCompleteParams; var autoCompleteParams = context.unit.params.autoCompleteParams;
var encodedFeaturePayloads = context.unit.params.encodedFeaturePayloads; var encodedFeaturePayloads = context.unit.params.encodedFeaturePayloads;
var controlOperations = operationModule.getControlOperations(device.type); var allControlOps = operationModule.getControlOperations(device.type);
var filteredControlOps = [];
var queryParams = []; var queryParams = [];
var formParams = []; var formParams = [];
var pathParams = []; var pathParams = [];
for (var i = 0; i < controlOperations.length; i++) { for (var i = 0; i < allControlOps.length; i++) {
var currentParamList = controlOperations[i]["params"]; var controlOperation = {};
var uiParamList = controlOperations[i]["uiParams"]; var uiPermission = allControlOps[i]["uiPermission"];
if (uiPermission && !userModule.isAuthorized("/permission/admin/" + uiPermission)) {
continue;
}
controlOperation = allControlOps[i];
var currentParamList = allControlOps[i]["params"];
for (var j = 0; j < currentParamList.length; j++) { for (var j = 0; j < currentParamList.length; j++) {
var currentParam = currentParamList[j]; var currentParam = currentParamList[j];
currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams); currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams);
currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams); currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams);
currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams); currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams);
} }
controlOperations[i]["uiParams"] = uiParamList; controlOperation["params"] = currentParamList;
if (encodedFeaturePayloads) { if (encodedFeaturePayloads) {
controlOperations[i]["payload"] = getPayload(encodedFeaturePayloads, controlOperations[i]["operation"]); allControlOps[i]["payload"] = getPayload(encodedFeaturePayloads, allControlOps[i]["operation"]);
} }
filteredControlOps.push(controlOperation);
} }
return {"control_operations": controlOperations, "device": device}; return {"controlOperations": filteredControlOps, "device": device};
} }
function processParams(paramsList, autoCompleteParams) { function processParams(paramsList, autoCompleteParams) {

@ -6,7 +6,8 @@
"groupingEnabled": "false", "groupingEnabled": "false",
"features": { "features": {
"DEVICE_RING": { "DEVICE_RING": {
"icon": "fw-dial-up" "icon": "fw-dial-up",
"permission": "/device-mgt/devices/owning-device/operations/android/ring"
}, },
"DEVICE_LOCK": { "DEVICE_LOCK": {
"icon": "fw-lock", "icon": "fw-lock",
@ -22,16 +23,20 @@
"optional": true, "optional": true,
"label": "Hard lock enabled" "label": "Hard lock enabled"
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/lock"
}, },
"DEVICE_LOCATION": { "DEVICE_LOCATION": {
"icon": "fw-map-location" "icon": "fw-map-location",
"permission": "/device-mgt/devices/owning-device/operations/android/location"
}, },
"CLEAR_PASSWORD": { "CLEAR_PASSWORD": {
"icon": "fw-clear" "icon": "fw-clear",
"permission": "/device-mgt/devices/owning-device/operations/android/clear-password"
}, },
"DEVICE_REBOOT": { "DEVICE_REBOOT": {
"icon": "fw-refresh" "icon": "fw-refresh",
"permission": "/device-mgt/devices/owning-device/operations/android/reboot"
}, },
"UPGRADE_FIRMWARE": { "UPGRADE_FIRMWARE": {
"icon": "fw-hardware", "icon": "fw-hardware",
@ -55,10 +60,12 @@
"optional": true, "optional": true,
"label": "Enter firmware upgrade server URL (ie. http://abc.com or http://abc.com/ota)" "label": "Enter firmware upgrade server URL (ie. http://abc.com or http://abc.com/ota)"
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/upgrade"
}, },
"DEVICE_MUTE": { "DEVICE_MUTE": {
"icon": "fw-mute" "icon": "fw-mute",
"permission": "/device-mgt/devices/owning-device/operations/android/mute"
}, },
"NOTIFICATION": { "NOTIFICATION": {
"icon": "fw-message", "icon": "fw-message",
@ -75,7 +82,8 @@
"optional": false, "optional": false,
"label": "Message Here..." "label": "Message Here..."
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/send-notification"
}, },
"CHANGE_LOCK_CODE": { "CHANGE_LOCK_CODE": {
"icon": "fw-security", "icon": "fw-security",
@ -86,10 +94,12 @@
"optional": false, "optional": false,
"label": "Lock Code" "label": "Lock Code"
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/change-lock-code"
}, },
"ENTERPRISE_WIPE": { "ENTERPRISE_WIPE": {
"icon": "fw-block" "icon": "fw-block",
"permission": "/device-mgt/devices/owning-device/operations/android/enterprise-wipe"
}, },
"WIPE_DATA": { "WIPE_DATA": {
"icon": "fw-delete", "icon": "fw-delete",
@ -100,7 +110,8 @@
"optional": false, "optional": false,
"label": "Enter PIN code* of the device." "label": "Enter PIN code* of the device."
} }
] ],
"permission": "/device-mgt/devices/owning-device/operations/android/wipe"
} }
} }
} }

Loading…
Cancel
Save