diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java index e12b259fbb4..0be452585f9 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/UserManagementServiceImpl.java @@ -134,14 +134,14 @@ public class UserManagementServiceImpl implements UserManagementService { public Response updateUser(@PathParam("username") String username, UserInfo userInfo) { try { UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); - if (!userStoreManager.isExistingUser(userInfo.getUsername())) { + if (!userStoreManager.isExistingUser(username)) { if (log.isDebugEnabled()) { - log.debug("User by username: " + userInfo.getUsername() + - " doesn't exists. Therefore, request made to update user was refused."); + log.debug("User by username: " + username + + " doesn't exists. Therefore, request made to update user was refused."); } return Response.status(Response.Status.NOT_FOUND).entity( new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + - userInfo.getUsername() + " doesn't exist.").build()).build(); + username + " doesn't exist.").build()).build(); } Map defaultUserClaims = @@ -149,11 +149,11 @@ public class UserManagementServiceImpl implements UserManagementService { userInfo.getEmailAddress()); if (StringUtils.isNotEmpty(userInfo.getPassword())) { // Decoding Base64 encoded password - userStoreManager.updateCredentialByAdmin(userInfo.getUsername(), - userInfo.getPassword()); - log.debug("User credential of username: " + userInfo.getUsername() + " has been changed"); + userStoreManager.updateCredentialByAdmin(username, + userInfo.getPassword()); + log.debug("User credential of username: " + username + " has been changed"); } - List currentRoles = this.getFilteredRoles(userStoreManager, userInfo.getUsername()); + List currentRoles = this.getFilteredRoles(userStoreManager, username); List newRoles = Arrays.asList(userInfo.getRoles()); List rolesToAdd = new ArrayList<>(newRoles); @@ -167,19 +167,19 @@ public class UserManagementServiceImpl implements UserManagementService { } } rolesToDelete.remove(ROLE_EVERYONE); - userStoreManager.updateRoleListOfUser(userInfo.getUsername(), - rolesToDelete.toArray(new String[rolesToDelete.size()]), - rolesToAdd.toArray(new String[rolesToAdd.size()])); - userStoreManager.setUserClaimValues(userInfo.getUsername(), defaultUserClaims, null); + userStoreManager.updateRoleListOfUser(username, + rolesToDelete.toArray(new String[rolesToDelete.size()]), + rolesToAdd.toArray(new String[rolesToAdd.size()])); + userStoreManager.setUserClaimValues(username, defaultUserClaims, null); // Outputting debug message upon successful addition of user if (log.isDebugEnabled()) { - log.debug("User by username: " + userInfo.getUsername() + " was successfully updated."); + log.debug("User by username: " + username + " was successfully updated."); } BasicUserInfo updatedUserInfo = this.getBasicUserInfo(username); return Response.ok().entity(updatedUserInfo).build(); } catch (UserStoreException e) { - String msg = "Error occurred while trying to update user '" + userInfo.getUsername() + "'"; + String msg = "Error occurred while trying to update user '" + username + "'"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/SCEPManagerServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/SCEPManagerServiceComponent.java deleted file mode 100644 index e5d9058bdfc..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/SCEPManagerServiceComponent.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.wso2.carbon.device.mgt.core.internal; - -///** -// * @scr.component name="org.wso2.carbon.certificate.mgt.core.scep" immediate="true" -// * @scr.reference name="app.mgt.service" -// * interface="org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementProviderService" -// * cardinality="1..1" -// * policy="dynamic" -// * bind="setApplicationManagementProviderService" -// * unbind="unsetApplicationManagementProviderService" -// */ -//public class SCEPManagerServiceComponent { -// -// private static final Log log = LogFactory.getLog(SCEPManagerServiceComponent.class); -// -// protected void activate(ComponentContext componentContext) { -// -// try { -// if (log.isDebugEnabled()) { -// log.debug("Initializing SCEP core bundle"); -// } -// -// BundleContext bundleContext = componentContext.getBundleContext(); -// bundleContext.registerService(SCEPManager.class.getName(), -// new SCEPManagerImpl(), null); -// -// if (log.isDebugEnabled()) { -// log.debug("SCEP core bundle has been successfully initialized"); -// } -// } catch (Throwable e) { -// String msg = "Error occurred while initializing SCEP core bundle"; -// log.error(msg, e); -// } -// } -// -// protected void deactivate(ComponentContext ctx) { -// if (log.isDebugEnabled()) { -// log.debug("Deactivating SCEP core bundle"); -// } -// } -// -// protected void unsetApplicationManagementProviderService(ApplicationManagementProviderService -// applicationManagementProviderService) { -// //do nothing -// } -// -// protected void setApplicationManagementProviderService(ApplicationManagementProviderService -// applicationManagementProviderService) { -// //do nothing -// } -// -//} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag index 05ca19906ae..0fb2945cf49 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag @@ -35,18 +35,20 @@ function appendQueryParam (url, queryParam , value) { if (uriMatcher.match("/{context}/api/data-tables/invoker")) { var url = request.getParameter("url"); var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url"); + //noinspection JSUnresolvedFunction getAllParameters var allParams = request.getAllParameters(); - for (var key in allParams) { - if (allParams.hasOwnProperty(key)) { - if(key == "limit" || key == "offset"){ - targetURL = appendQueryParam(targetURL, key, allParams[key]); - } - if(key == "filter"){ - if(allParams[key]){ - var searchPayload = JSON.parse(allParams[key]); - for (var key in searchPayload) { - targetURL = appendQueryParam(targetURL, key, searchPayload[key]); + for (var allParamsKey in allParams) { + if (allParams.hasOwnProperty(allParamsKey)) { + if (allParamsKey == "limit" || allParamsKey == "offset") { + targetURL = appendQueryParam(targetURL, allParamsKey, allParams[allParamsKey]); + } else if (allParamsKey == "filter") { + if (allParams[allParamsKey]) { + var searchPayload = JSON.parse(allParams[allParamsKey]); + for (var searchPayloadKey in searchPayload) { + if (searchPayload.hasOwnProperty(searchPayloadKey)) { + targetURL = appendQueryParam(targetURL, searchPayloadKey, searchPayload[searchPayloadKey]); + } } } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag index c6dca893214..7465f21649a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/operation-api.jag @@ -32,8 +32,8 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) { var length = request.getParameter("length"); var search = request.getParameter("search[value]"); - var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/" + - deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length; + var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + + "/devices/" + deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length; serviceInvokers.XMLHttp.get( restAPIEndpoint, @@ -46,7 +46,7 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) { paginatedResult["recordsFiltered"] = responsePayload["count"]; paginatedResult["data"] = responsePayload["operations"]; - response["status"] = 200; + response["status"] = restAPIResponse["status"]; response["content"] = paginatedResult; } else { response["status"] = restAPIResponse["status"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag index 212a0875394..465e8961813 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/user-api.jag @@ -26,11 +26,11 @@ var constants = require("/app/modules/constants.js"); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; -var utility = require("/app/modules/utility.js").utility; +var utility = require("/app/modules/utility.js")["utility"]; var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; var util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; -var responseProcessor = require('utils').response; +var responseProcessor = require("utils").response; var result; @@ -69,9 +69,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) { apiWrapperUtil.setupTokenPairByPasswordGrantType(username, password); var permissions = userModule.getUIPermissions(); if (permissions.VIEW_DASHBOARD) { - response.sendRedirect(constants.WEB_APP_CONTEXT); + response.sendRedirect(devicemgtProps["appContext"]); } else { - response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); + response.sendRedirect(devicemgtProps["appContext"] + "devices"); } }, function () { response.sendRedirect(devicemgtProps.appContext + "login?#auth-failed"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index 21360452c1d..4b205346d9a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -22,7 +22,7 @@ deviceModule = function () { var utility = require('/app/modules/utility.js').utility; var constants = require('/app/modules/constants.js'); - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; // var ArrayList = Packages.java.util.ArrayList; @@ -244,7 +244,7 @@ deviceModule = function () { try { utility.startTenantFlow(carbonUser); //var url = mdmProps["httpsURL"] + "/mdm-admin/devices/view?type=" + deviceType + "&id=" + deviceId; - var url = mdmProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId; + var url = devicemgtProps["httpsURL"] + "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId; return serviceInvokers.XMLHttp.get( url, function (backendResponse) { @@ -294,10 +294,11 @@ deviceModule = function () { var uiPermissions = userModule.getUIPermissions(); var url; if (uiPermissions.LIST_DEVICES) { - url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count"; + url = devicemgtProps["httpsURL"] + + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/count"; } else if (uiPermissions.LIST_OWN_DEVICES) { - url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username - + "/count"; + url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + + "/devices/user/" + carbonUser.username + "/count"; } else { log.error("Access denied for user: " + carbonUser.username); return -1; @@ -351,7 +352,8 @@ deviceModule = function () { // }; publicMethods.getDevices = function (userName) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName; + var url = devicemgtProps["httpsURL"] + + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/user/" + userName; return serviceInvokers.XMLHttp.get( url, function (responsePayload) { for (var i = 0; i < responsePayload.length; i++) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js index 02b2198b48c..fcbeea8a5a3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js @@ -26,7 +26,8 @@ var groupModule = {}; var utility = require("/app/modules/utility.js").utility; var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - var groupServiceEndpoint = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/groups"; + var groupServiceEndpoint = devicemgtProps["httpsURL"] + + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/groups"; var user = session.get(constants.USER_SESSION_KEY); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js index e96ffcdec19..6be734ec27d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/operation.js @@ -38,7 +38,7 @@ var operationModule = function () { } privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/features/" + deviceType; + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/features/" + deviceType; var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { var features = responsePayload; var featureList = []; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js index 79aa46e5de5..5cafff394d3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js @@ -16,9 +16,6 @@ * under the License. */ -var WEB_APP_TITLE = "WSO2 CDM"; -var WEB_APP_CONTEXT = "/devicemgt"; -var ADMIN_SERVICE_CONTEXT = "/api/device-mgt/v1.0"; var USER_SESSION_KEY = "_UUF_USER"; var UNSPECIFIED = "Unspecified"; var httpURL = "httpURL"; @@ -72,12 +69,6 @@ var HTTP_GET = "GET"; var HTTP_POST = "POST"; var HTTP_PUT = "PUT"; var HTTP_DELETE = "DELETE"; -var REFERER = "referer" - -var GRANT_TYPE_PASSWORD = "password"; -var GRANT_TYPE_SAML = "saml"; - -var MQTT_QUEUE_CONFIG_NAME = "MQTT"; var HTTP_CONFLICT = 409; var HTTP_CREATED = 201; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js index d9f442cdd4e..1c367b38f5c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/init.js @@ -18,17 +18,20 @@ var carbonModule = require("carbon"); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; +var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; +var utility = require("/app/modules/utility.js")["utility"]; + +//noinspection JSUnresolvedFunction Server var carbonServer = new carbonModule.server.Server({ tenanted: true, url: devicemgtProps["httpsURL"] + "/admin" }); + application.put("carbonServer", carbonServer); -var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -var utility = require("/app/modules/utility.js")["utility"]; +//var permissions = { +// "/permission/admin/device-mgt/user": ["ui.execute"], +// "/permission/admin/manage/api/subscribe": ["ui.execute"] +//}; -var permissions = { - '/permission/admin/device-mgt/user': ['ui.execute'], - '/permission/admin/manage/api/subscribe': ['ui.execute'] -}; //userModule.addRole("internal/devicemgt-user", ["admin"], permissions); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js index ba7827173bb..f31e72622c3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handler-utils.js @@ -84,7 +84,7 @@ var utils = function () { if (!username || !jwtToken) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + "based client app credentials. No username or jwt token is found " + - "as input - getTenantBasedClientAppCredentials(x, y)"); + "as input - getTenantBasedClientAppCredentials(x, y)"); return null; } else { //noinspection JSUnresolvedFunction, JSUnresolvedVariable @@ -92,7 +92,7 @@ var utils = function () { if (!tenantDomain) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + "based client application credentials. Unable to obtain a valid tenant domain for provided " + - "username - getTenantBasedClientAppCredentials(x, y)"); + "username - getTenantBasedClientAppCredentials(x, y)"); return null; } else { var cachedTenantBasedClientAppCredentials = privateMethods. @@ -104,7 +104,7 @@ var utils = function () { var applicationName = "webapp_" + tenantDomain; var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] ["apiManagerClientAppRegistrationServiceURL"] + - "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; + "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; var xhr = new XMLHttpRequest(); xhr.open("POST", requestURL, false); @@ -123,7 +123,7 @@ var utils = function () { } else { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + "based client application credentials from API " + - "Manager - getTenantBasedClientAppCredentials(x, y)"); + "Manager - getTenantBasedClientAppCredentials(x, y)"); return null; } } @@ -152,11 +152,11 @@ var utils = function () { } }; - publicMethods["getTokenPairByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) { + publicMethods["getTokenPairAndScopesByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) { if (!username || !password || !encodedClientAppCredentials || !scopes) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " + "grant type. No username, password, encoded client app credentials or scopes are " + - "found - getTokenPairByPasswordGrantType(a, b, c, d)"); + "found - getTokenPairAndScopesByPasswordGrantType(a, b, c, d)"); return null; } else { // calling oauth provider token service endpoint @@ -179,17 +179,17 @@ var utils = function () { return tokenData; } else { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + - "by password grant type - getTokenPairByPasswordGrantType(a, b, c, d)"); + "by password grant type - getTokenPairAndScopesByPasswordGrantType(a, b, c, d)"); return null; } } }; - publicMethods["getTokenPairBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { + publicMethods["getTokenPairAndScopesBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { if (!assertion || !encodedClientAppCredentials || !scopes) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by saml " + "grant type. No assertion, encoded client app credentials or scopes are " + - "found - getTokenPairBySAMLGrantType(x, y, z)"); + "found - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); return null; } else { var assertionXML = publicMethods.decode(assertion); @@ -205,7 +205,7 @@ var utils = function () { var extractedAssertion; if (assertionStartIndex == -1 || assertionEndIndex == -1) { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access " + - "token by saml grant type. Issue in assertion format - getTokenPairBySAMLGrantType(x, y, z)"); + "token by saml grant type. Issue in assertion format - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); return null; } else { extractedAssertion = assertionXML. @@ -232,7 +232,7 @@ var utils = function () { return tokenData; } else { log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + - "by password grant type - getTokenPairBySAMLGrantType(x, y, z)"); + "by password grant type - getTokenPairAndScopesBySAMLGrantType(x, y, z)"); return null; } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js index fc1016eb851..8a41429ce65 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/oauth/token-handlers.js @@ -53,7 +53,7 @@ var handlers = function () { stringOfScopes += entry + " "; }); tokenData = tokenUtil. - getTokenPairByPasswordGrantType(username, + getTokenPairAndScopesByPasswordGrantType(username, encodeURIComponent(password), encodedClientAppCredentials, stringOfScopes); if (!tokenData) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up " + @@ -90,7 +90,7 @@ var handlers = function () { var tokenData; // accessTokenPair will include current access token as well as current refresh token tokenData = tokenUtil. - getTokenPairBySAMLGrantType(samlToken, encodedClientAppCredentials, "PRODUCTION"); + getTokenPairAndScopesBySAMLGrantType(samlToken, encodedClientAppCredentials, "PRODUCTION"); if (!tokenData) { throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up token " + "pair by password grant type. Error in token " + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js index f5dd896bc43..3af4f59e6a0 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/utility.js @@ -60,21 +60,6 @@ utility = function () { return getOsgiService("org.wso2.carbon.policy.mgt.core.PolicyManagerService"); }; - publicMethods.getIoTServerConfig = function (configName) { - var path = "/config/iot-config.json"; - var file = new File(path); - try { - file.open("r"); - var content = file.readAll(); - } catch (err) { - log.error("Error while reading IoT server config file `" + path + "`: " + err); - } finally { - file.close(); - } - var json = parse(content); - return json[configName]; - }; - publicMethods.getDeviceTypeConfig = function (deviceType) { var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view"); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js index ec98554ce10..06ac10ba3ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.dashboard/dashboard.js @@ -16,25 +16,25 @@ * under the License. */ -function onRequest(context) { +function onRequest() { var constants = require("/app/modules/constants.js"); - var user = session.get(constants.USER_SESSION_KEY); var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var permissions = userModule.getUIPermissions(); var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; + var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; + var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; + + var user = session.get(constants["USER_SESSION_KEY"]); + var permissions = userModule.getUIPermissions(); if (!permissions.VIEW_DASHBOARD) { - response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); + response.sendRedirect(devicemgtProps["appContext"] + "devices"); return; } var page = {}; page.permissions = permissions; page.enrollmentURL = devicemgtProps.enrollmentURL; - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var groupModule = require("/app/modules/business-controllers/group.js")["groupModule"]; - var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; - page.device_count = deviceModule.getDevicesCount(); page.group_count = groupModule.getGroupCount(); page.user_count = userModule.getUsers()["content"].length; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js index 5ba8114a045..a014415bc69 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.user.create/create.js @@ -31,6 +31,9 @@ function onRequest() { if (response["status"] == "success") { page["roles"] = response["content"]; } + + var userStores = userModule.getSecondaryUserStores(); + page["userStores"] = userStores; page["charLimit"] = devicemgtProps["usernameLength"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"]; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/iot-config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/iot-config.json deleted file mode 100644 index 708d1eca74b..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/iot-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "IoTMgtHost" : "localhost" -} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/service-provider.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/service-provider.json deleted file mode 100644 index b2041d5def7..00000000000 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/config/service-provider.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "grantType": "password urn:ietf:params:oauth:grant-type:saml2-bearer refresh_token", - "saasApp": true, - "tokenScope": "admin", - "requireDynamicClientRegistration": true, - "audience": "https://localhost:9443/oauth2/token", - "assertionConsumerURL": "https://localhost:9443/devicemgt/sso/acs", - "recepientValidationURL": "https://localhost:9443/oauth2/token" -}