hasuniea 8 years ago
commit b3582f9d47

@ -134,14 +134,14 @@ public class UserManagementServiceImpl implements UserManagementService {
public Response updateUser(@PathParam("username") String username, UserInfo userInfo) { public Response updateUser(@PathParam("username") String username, UserInfo userInfo) {
try { try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (!userStoreManager.isExistingUser(userInfo.getUsername())) { if (!userStoreManager.isExistingUser(username)) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("User by username: " + userInfo.getUsername() + log.debug("User by username: " + username +
" doesn't exists. Therefore, request made to update user was refused."); " doesn't exists. Therefore, request made to update user was refused.");
} }
return Response.status(Response.Status.NOT_FOUND).entity( return Response.status(Response.Status.NOT_FOUND).entity(
new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " + new ErrorResponse.ErrorResponseBuilder().setMessage("User by username: " +
userInfo.getUsername() + " doesn't exist.").build()).build(); username + " doesn't exist.").build()).build();
} }
Map<String, String> defaultUserClaims = Map<String, String> defaultUserClaims =
@ -149,11 +149,11 @@ public class UserManagementServiceImpl implements UserManagementService {
userInfo.getEmailAddress()); userInfo.getEmailAddress());
if (StringUtils.isNotEmpty(userInfo.getPassword())) { if (StringUtils.isNotEmpty(userInfo.getPassword())) {
// Decoding Base64 encoded password // Decoding Base64 encoded password
userStoreManager.updateCredentialByAdmin(userInfo.getUsername(), userStoreManager.updateCredentialByAdmin(username,
userInfo.getPassword()); userInfo.getPassword());
log.debug("User credential of username: " + userInfo.getUsername() + " has been changed"); log.debug("User credential of username: " + username + " has been changed");
} }
List<String> currentRoles = this.getFilteredRoles(userStoreManager, userInfo.getUsername()); List<String> currentRoles = this.getFilteredRoles(userStoreManager, username);
List<String> newRoles = Arrays.asList(userInfo.getRoles()); List<String> newRoles = Arrays.asList(userInfo.getRoles());
List<String> rolesToAdd = new ArrayList<>(newRoles); List<String> rolesToAdd = new ArrayList<>(newRoles);
@ -167,19 +167,19 @@ public class UserManagementServiceImpl implements UserManagementService {
} }
} }
rolesToDelete.remove(ROLE_EVERYONE); rolesToDelete.remove(ROLE_EVERYONE);
userStoreManager.updateRoleListOfUser(userInfo.getUsername(), userStoreManager.updateRoleListOfUser(username,
rolesToDelete.toArray(new String[rolesToDelete.size()]), rolesToDelete.toArray(new String[rolesToDelete.size()]),
rolesToAdd.toArray(new String[rolesToAdd.size()])); rolesToAdd.toArray(new String[rolesToAdd.size()]));
userStoreManager.setUserClaimValues(userInfo.getUsername(), defaultUserClaims, null); userStoreManager.setUserClaimValues(username, defaultUserClaims, null);
// Outputting debug message upon successful addition of user // Outputting debug message upon successful addition of user
if (log.isDebugEnabled()) { 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); BasicUserInfo updatedUserInfo = this.getBasicUserInfo(username);
return Response.ok().entity(updatedUserInfo).build(); return Response.ok().entity(updatedUserInfo).build();
} catch (UserStoreException e) { } 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); log.error(msg, e);
return Response.serverError().entity( return Response.serverError().entity(
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build();

@ -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
// }
//
//}

@ -35,18 +35,20 @@ function appendQueryParam (url, queryParam , value) {
if (uriMatcher.match("/{context}/api/data-tables/invoker")) { if (uriMatcher.match("/{context}/api/data-tables/invoker")) {
var url = request.getParameter("url"); var url = request.getParameter("url");
var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url"); var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url");
//noinspection JSUnresolvedFunction getAllParameters
var allParams = request.getAllParameters(); var allParams = request.getAllParameters();
for (var key in allParams) { for (var allParamsKey in allParams) {
if (allParams.hasOwnProperty(key)) { if (allParams.hasOwnProperty(allParamsKey)) {
if(key == "limit" || key == "offset"){ if (allParamsKey == "limit" || allParamsKey == "offset") {
targetURL = appendQueryParam(targetURL, key, allParams[key]); targetURL = appendQueryParam(targetURL, allParamsKey, allParams[allParamsKey]);
} } else if (allParamsKey == "filter") {
if(key == "filter"){ if (allParams[allParamsKey]) {
if(allParams[key]){ var searchPayload = JSON.parse(allParams[allParamsKey]);
var searchPayload = JSON.parse(allParams[key]); for (var searchPayloadKey in searchPayload) {
for (var key in searchPayload) { if (searchPayload.hasOwnProperty(searchPayloadKey)) {
targetURL = appendQueryParam(targetURL, key, searchPayload[key]); targetURL = appendQueryParam(targetURL, searchPayloadKey, searchPayload[searchPayloadKey]);
}
} }
} }
} }

@ -32,8 +32,8 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) {
var length = request.getParameter("length"); var length = request.getParameter("length");
var search = request.getParameter("search[value]"); var search = request.getParameter("search[value]");
var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/devices/" + var restAPIEndpoint = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length; "/devices/" + deviceType + "/" + deviceId + "/operations?offset=" + index + "&limit=" + length;
serviceInvokers.XMLHttp.get( serviceInvokers.XMLHttp.get(
restAPIEndpoint, restAPIEndpoint,
@ -46,7 +46,7 @@ if (uriMatcher.match("/{context}/api/operation/paginate")) {
paginatedResult["recordsFiltered"] = responsePayload["count"]; paginatedResult["recordsFiltered"] = responsePayload["count"];
paginatedResult["data"] = responsePayload["operations"]; paginatedResult["data"] = responsePayload["operations"];
response["status"] = 200; response["status"] = restAPIResponse["status"];
response["content"] = paginatedResult; response["content"] = paginatedResult;
} else { } else {
response["status"] = restAPIResponse["status"]; response["status"] = restAPIResponse["status"];

@ -26,11 +26,11 @@ var constants = require("/app/modules/constants.js");
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; 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 apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"];
var util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; var util = require("/app/modules/oauth/token-handler-utils.js")["utils"];
var responseProcessor = require('utils').response; var responseProcessor = require("utils").response;
var result; var result;
@ -69,9 +69,9 @@ if (uriMatcher.match("/{context}/api/user/authenticate")) {
apiWrapperUtil.setupTokenPairByPasswordGrantType(username, password); apiWrapperUtil.setupTokenPairByPasswordGrantType(username, password);
var permissions = userModule.getUIPermissions(); var permissions = userModule.getUIPermissions();
if (permissions.VIEW_DASHBOARD) { if (permissions.VIEW_DASHBOARD) {
response.sendRedirect(constants.WEB_APP_CONTEXT); response.sendRedirect(devicemgtProps["appContext"]);
} else { } else {
response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); response.sendRedirect(devicemgtProps["appContext"] + "devices");
} }
}, function () { }, function () {
response.sendRedirect(devicemgtProps.appContext + "login?#auth-failed"); response.sendRedirect(devicemgtProps.appContext + "login?#auth-failed");

@ -22,7 +22,7 @@ deviceModule = function () {
var utility = require('/app/modules/utility.js').utility; var utility = require('/app/modules/utility.js').utility;
var constants = require('/app/modules/constants.js'); 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 serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"];
// var ArrayList = Packages.java.util.ArrayList; // var ArrayList = Packages.java.util.ArrayList;
@ -244,7 +244,7 @@ deviceModule = function () {
try { try {
utility.startTenantFlow(carbonUser); utility.startTenantFlow(carbonUser);
//var url = mdmProps["httpsURL"] + "/mdm-admin/devices/view?type=" + deviceType + "&id=" + deviceId; //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( return serviceInvokers.XMLHttp.get(
url, url,
function (backendResponse) { function (backendResponse) {
@ -294,10 +294,11 @@ deviceModule = function () {
var uiPermissions = userModule.getUIPermissions(); var uiPermissions = userModule.getUIPermissions();
var url; var url;
if (uiPermissions.LIST_DEVICES) { 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) { } else if (uiPermissions.LIST_OWN_DEVICES) {
url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + carbonUser.username url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
+ "/count"; "/devices/user/" + carbonUser.username + "/count";
} else { } else {
log.error("Access denied for user: " + carbonUser.username); log.error("Access denied for user: " + carbonUser.username);
return -1; return -1;
@ -351,7 +352,8 @@ deviceModule = function () {
// }; // };
publicMethods.getDevices = function (userName) { 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( return serviceInvokers.XMLHttp.get(
url, function (responsePayload) { url, function (responsePayload) {
for (var i = 0; i < responsePayload.length; i++) { for (var i = 0; i < responsePayload.length; i++) {

@ -26,7 +26,8 @@ var groupModule = {};
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; 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); var user = session.get(constants.USER_SESSION_KEY);

@ -38,7 +38,7 @@ var operationModule = function () {
} }
privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { 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 featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) {
var features = responsePayload; var features = responsePayload;
var featureList = []; var featureList = [];

@ -16,9 +16,6 @@
* under the License. * 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 USER_SESSION_KEY = "_UUF_USER";
var UNSPECIFIED = "Unspecified"; var UNSPECIFIED = "Unspecified";
var httpURL = "httpURL"; var httpURL = "httpURL";
@ -72,12 +69,6 @@ var HTTP_GET = "GET";
var HTTP_POST = "POST"; var HTTP_POST = "POST";
var HTTP_PUT = "PUT"; var HTTP_PUT = "PUT";
var HTTP_DELETE = "DELETE"; 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_CONFLICT = 409;
var HTTP_CREATED = 201; var HTTP_CREATED = 201;

@ -18,17 +18,20 @@
var carbonModule = require("carbon"); var carbonModule = require("carbon");
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; 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({ var carbonServer = new carbonModule.server.Server({
tenanted: true, tenanted: true,
url: devicemgtProps["httpsURL"] + "/admin" url: devicemgtProps["httpsURL"] + "/admin"
}); });
application.put("carbonServer", carbonServer); application.put("carbonServer", carbonServer);
var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; //var permissions = {
var utility = require("/app/modules/utility.js")["utility"]; // "/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); //userModule.addRole("internal/devicemgt-user", ["admin"], permissions);

@ -84,7 +84,7 @@ var utils = function () {
if (!username || !jwtToken) { if (!username || !jwtToken) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
"based client app credentials. No username or jwt token is found " + "based client app credentials. No username or jwt token is found " +
"as input - getTenantBasedClientAppCredentials(x, y)"); "as input - getTenantBasedClientAppCredentials(x, y)");
return null; return null;
} else { } else {
//noinspection JSUnresolvedFunction, JSUnresolvedVariable //noinspection JSUnresolvedFunction, JSUnresolvedVariable
@ -92,7 +92,7 @@ var utils = function () {
if (!tenantDomain) { if (!tenantDomain) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + 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 " + "based client application credentials. Unable to obtain a valid tenant domain for provided " +
"username - getTenantBasedClientAppCredentials(x, y)"); "username - getTenantBasedClientAppCredentials(x, y)");
return null; return null;
} else { } else {
var cachedTenantBasedClientAppCredentials = privateMethods. var cachedTenantBasedClientAppCredentials = privateMethods.
@ -104,7 +104,7 @@ var utils = function () {
var applicationName = "webapp_" + tenantDomain; var applicationName = "webapp_" + tenantDomain;
var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"]
["apiManagerClientAppRegistrationServiceURL"] + ["apiManagerClientAppRegistrationServiceURL"] +
"?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName;
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open("POST", requestURL, false); xhr.open("POST", requestURL, false);
@ -123,7 +123,7 @@ var utils = function () {
} else { } else {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " +
"based client application credentials from API " + "based client application credentials from API " +
"Manager - getTenantBasedClientAppCredentials(x, y)"); "Manager - getTenantBasedClientAppCredentials(x, y)");
return null; 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) { if (!username || !password || !encodedClientAppCredentials || !scopes) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " + 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 " + "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; return null;
} else { } else {
// calling oauth provider token service endpoint // calling oauth provider token service endpoint
@ -179,17 +179,17 @@ var utils = function () {
return tokenData; return tokenData;
} else { } else {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + 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; return null;
} }
} }
}; };
publicMethods["getTokenPairBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { publicMethods["getTokenPairAndScopesBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) {
if (!assertion || !encodedClientAppCredentials || !scopes) { if (!assertion || !encodedClientAppCredentials || !scopes) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by saml " + 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 " + "grant type. No assertion, encoded client app credentials or scopes are " +
"found - getTokenPairBySAMLGrantType(x, y, z)"); "found - getTokenPairAndScopesBySAMLGrantType(x, y, z)");
return null; return null;
} else { } else {
var assertionXML = publicMethods.decode(assertion); var assertionXML = publicMethods.decode(assertion);
@ -205,7 +205,7 @@ var utils = function () {
var extractedAssertion; var extractedAssertion;
if (assertionStartIndex == -1 || assertionEndIndex == -1) { if (assertionStartIndex == -1 || assertionEndIndex == -1) {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access " + 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; return null;
} else { } else {
extractedAssertion = assertionXML. extractedAssertion = assertionXML.
@ -232,7 +232,7 @@ var utils = function () {
return tokenData; return tokenData;
} else { } else {
log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + 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; return null;
} }
} }

@ -53,7 +53,7 @@ var handlers = function () {
stringOfScopes += entry + " "; stringOfScopes += entry + " ";
}); });
tokenData = tokenUtil. tokenData = tokenUtil.
getTokenPairByPasswordGrantType(username, getTokenPairAndScopesByPasswordGrantType(username,
encodeURIComponent(password), encodedClientAppCredentials, stringOfScopes); encodeURIComponent(password), encodedClientAppCredentials, stringOfScopes);
if (!tokenData) { if (!tokenData) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up " +
@ -90,7 +90,7 @@ var handlers = function () {
var tokenData; var tokenData;
// accessTokenPair will include current access token as well as current refresh token // accessTokenPair will include current access token as well as current refresh token
tokenData = tokenUtil. tokenData = tokenUtil.
getTokenPairBySAMLGrantType(samlToken, encodedClientAppCredentials, "PRODUCTION"); getTokenPairAndScopesBySAMLGrantType(samlToken, encodedClientAppCredentials, "PRODUCTION");
if (!tokenData) { if (!tokenData) {
throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up token " + throw new Error("{/app/modules/oauth/token-handlers.js} Could not set up token " +
"pair by password grant type. Error in token " + "pair by password grant type. Error in token " +

@ -60,21 +60,6 @@ utility = function () {
return getOsgiService("org.wso2.carbon.policy.mgt.core.PolicyManagerService"); 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) { publicMethods.getDeviceTypeConfig = function (deviceType) {
var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view"); var unitName = publicMethods.getTenantedDeviceUnitName(deviceType, "type-view");

@ -16,25 +16,25 @@
* under the License. * under the License.
*/ */
function onRequest(context) { function onRequest() {
var constants = require("/app/modules/constants.js"); 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 userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var permissions = userModule.getUIPermissions();
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; 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) { if (!permissions.VIEW_DASHBOARD) {
response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); response.sendRedirect(devicemgtProps["appContext"] + "devices");
return; return;
} }
var page = {}; var page = {};
page.permissions = permissions; page.permissions = permissions;
page.enrollmentURL = devicemgtProps.enrollmentURL; 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.device_count = deviceModule.getDevicesCount();
page.group_count = groupModule.getGroupCount(); page.group_count = groupModule.getGroupCount();
page.user_count = userModule.getUsers()["content"].length; page.user_count = userModule.getUsers()["content"].length;

@ -31,6 +31,9 @@ function onRequest() {
if (response["status"] == "success") { if (response["status"] == "success") {
page["roles"] = response["content"]; page["roles"] = response["content"];
} }
var userStores = userModule.getSecondaryUserStores();
page["userStores"] = userStores;
page["charLimit"] = devicemgtProps["usernameLength"]; page["charLimit"] = devicemgtProps["usernameLength"];
page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"]; page["usernameJSRegEx"] = devicemgtProps["userValidationConfig"]["usernameJSRegEx"];
page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"]; page["usernameHelpMsg"] = devicemgtProps["userValidationConfig"]["usernameHelpMsg"];

@ -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"
}
Loading…
Cancel
Save