From 4af2a37d9d0757114e64a1ecc20b229876a1d96e Mon Sep 17 00:00:00 2001 From: Megala Date: Sat, 1 Oct 2016 22:00:59 +0530 Subject: [PATCH 01/12] Fixing SSO problem --- .../main/resources/jaggeryapps/devicemgt/app/modules/login.js | 2 +- .../jaggeryapps/uuf-template-app/lib/modules/auth/auth.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js index 87f840d3ce..001188f0e6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js @@ -26,7 +26,7 @@ var onFail; var utility = require("/app/modules/utility.js").utility; var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; if (context.input.samlToken) { - apiWrapperUtil.setupTokenPairBySamlGrantType(context.input.username, context.input.samlToken); + apiWrapperUtil.setupTokenPairBySamlGrantType(context.user.username, context.input.samlToken); } else { apiWrapperUtil.setupTokenPairByPasswordGrantType(context.input.username, context.input.password); } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index fff0a77e50..9f009cb6cf 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -364,10 +364,10 @@ var module = {}; * samlToken: string}>} SSO sessions */ function getSsoSessions() { - var ssoSessions = session.get(constants.CACHE_KEY_SSO_SESSIONS); + var ssoSessions = application.get('sso_sessions'); if (!ssoSessions) { ssoSessions = {}; - session.put(constants.CACHE_KEY_SSO_SESSIONS, ssoSessions); + application.put('sso_sessions', ssoSessions); } return ssoSessions; } From b10c3235821162e56926aae0189292dbd8ebcc69 Mon Sep 17 00:00:00 2001 From: Megala Date: Sun, 2 Oct 2016 21:26:13 +0530 Subject: [PATCH 02/12] Fixing the problem in login --- .../resources/jaggeryapps/devicemgt/app/modules/login.js | 8 +++++--- .../jaggeryapps/uuf-template-app/lib/constants.js | 2 +- .../jaggeryapps/uuf-template-app/lib/modules/auth/auth.js | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js index 001188f0e6..d36e7af0ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js @@ -26,14 +26,16 @@ var onFail; var utility = require("/app/modules/utility.js").utility; var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; if (context.input.samlToken) { - apiWrapperUtil.setupTokenPairBySamlGrantType(context.user.username, context.input.samlToken); + apiWrapperUtil.setupTokenPairBySamlGrantType(context.user.username + '@' + context.user.domain, context.input.samlToken); } else { apiWrapperUtil.setupTokenPairByPasswordGrantType(context.input.username, context.input.password); } var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; var carbonServer = require("carbon").server; - (new carbonServer.Server({url: devicemgtProps["adminService"]})) - .login(context.input.username, context.input.password); + if (!context.input.samlToken) { + (new carbonServer.Server({url: devicemgtProps["adminService"]})) + .login(context.input.username, context.input.password); + } }; onFail = function (error) { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/constants.js index f7806238b6..8a4e0677f1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/constants.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/constants.js @@ -105,7 +105,7 @@ var constants = { CACHE_KEY_APP_CONF_FILE_LMD: "_UUF_APP_CONF_FILE_LMD", CACHE_KEY_LOOKUP_TABLE: "_UUF_LOOKUP_TABLE", CACHE_KEY_USER: "_UUF_USER", - CACHE_KEY_SSO_SESSIONS: "_UUF_SSO_SESSIONS", + CACHE_KEY_SSO_SESSIONS: "sso_sessions", CACHE_KEY_HANDLEBARS_ROOT: "_UUF_HANDLEBARS_ROOT", // URL Query Params URL_PARAM_REFERER: "referer" diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index 9f009cb6cf..e9bc8e8ca4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -364,10 +364,10 @@ var module = {}; * samlToken: string}>} SSO sessions */ function getSsoSessions() { - var ssoSessions = application.get('sso_sessions'); + var ssoSessions = application.get(constants.CACHE_KEY_SSO_SESSIONS); if (!ssoSessions) { ssoSessions = {}; - application.put('sso_sessions', ssoSessions); + application.put(constants.CACHE_KEY_SSO_SESSIONS, ssoSessions); } return ssoSessions; } From e5870e13062b54763afda51b4fccc30ad5358a4c Mon Sep 17 00:00:00 2001 From: Megala Date: Sun, 2 Oct 2016 23:15:25 +0530 Subject: [PATCH 03/12] Fixing the problem of common log out --- .../uuf-template-app/lib/modules/auth/auth.js | 115 ++++++++++-------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index e9bc8e8ca4..c3343731fd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -486,67 +486,74 @@ var module = {}; */ module.ssoAcs = function (request, response) { var samlResponse = request.getParameter("SAMLResponse"); - if (!samlResponse) { - var msg = "SAML response is not found in request parameters."; - log.error(msg); - response.sendError(400, msg); - return; - } + var samlRequest = request.getParameter('SAMLRequest'); var ssoClient = require("sso").client; var samlResponseObj; - try { - samlResponseObj = ssoClient.getSamlObject(samlResponse); - } catch (e) { - log.error(e.message, e); - response.sendError(500, e.message); - return; - } - if (ssoClient.isLogoutResponse(samlResponseObj)) { - // This is a logout response. - module.logout(response); - } else { - // This is a login response. - var ssoConfigs = getSsoConfigurations(); - var rsEnabled = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_RESPONSE_SIGNING_ENABLED]; - if (utils.parseBoolean(rsEnabled)) { - var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils; - var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password"); - var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location"); - var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS]; - var keyStoreParams = { - KEY_STORE_NAME: keyStoreName, - KEY_STORE_PASSWORD: keyStorePassword, - IDP_ALIAS: identityAlias, - USE_ST_KEY: !ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_USE_ST_KEY] - }; - if (!ssoClient.validateSignature(samlResponseObj, keyStoreParams)) { - var msg = "Invalid signature found in the SAML response."; + + if (samlResponse) { + try { + samlResponseObj = ssoClient.getSamlObject(samlResponse); + } catch (e) { + log.error(e.message, e); + response.sendError(500, e.message); + return; + } + if (ssoClient.isLogoutResponse(samlResponseObj)) { + // This is a logout response. + module.logout(response); + } else { + // This is a login response. + var ssoConfigs = getSsoConfigurations(); + var rsEnabled = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_RESPONSE_SIGNING_ENABLED]; + if (utils.parseBoolean(rsEnabled)) { + var CarbonUtils = Packages.org.wso2.carbon.utils.CarbonUtils; + var keyStorePassword = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Password"); + var keyStoreName = CarbonUtils.getServerConfiguration().getFirstProperty("Security.TrustStore.Location"); + var identityAlias = ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_IDENTITY_ALIAS]; + var keyStoreParams = { + KEY_STORE_NAME: keyStoreName, + KEY_STORE_PASSWORD: keyStorePassword, + IDP_ALIAS: identityAlias, + USE_ST_KEY: !ssoConfigs[constants.APP_CONF_AUTH_MODULE_SSO_USE_ST_KEY] + }; + if (!ssoClient.validateSignature(samlResponseObj, keyStoreParams)) { + var msg = "Invalid signature found in the SAML response."; + log.error(msg); + response.sendError(500, msg); + return; + } + } + /** + * @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken: + * string}} + */ + var ssoSession = ssoClient.decodeSAMLLoginResponse(samlResponseObj, samlResponse, + session.getId()); + if (ssoSession.sessionId) { + var ssoSessions = getSsoSessions(); + ssoSessions[ssoSession.sessionId] = ssoSession; + if (ssoSessions.sessionIndex != null || ssoSessions.sessionIndex != 'undefined') { + module.loadTenant(ssoSessions.loggedInUser); + var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser); + utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId); + var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()}; + handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument); + } + } else { + var msg = "Cannot decode SAML login response."; log.error(msg); response.sendError(500, msg); - return; } } - /** - * @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken: - * string}} - */ - var ssoSession = ssoClient.decodeSAMLLoginResponse(samlResponseObj, samlResponse, - session.getId()); - if (ssoSession.sessionId) { - var ssoSessions = getSsoSessions(); - ssoSessions[ssoSession.sessionId] = ssoSession; - if (ssoSessions.sessionIndex != null || ssoSessions.sessionIndex != 'undefined') { - module.loadTenant(ssoSessions.loggedInUser); - var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser); - utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId); - var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()}; - handleEvent(OPERATION_LOGIN, EVENT_SUCCESS, scriptArgument); - } - } else { - var msg = "Cannot decode SAML login response."; - log.error(msg); - response.sendError(500, msg); + } + if (samlRequest) { + var index = ssoClient.decodeSAMLLogoutRequest(ssoClient.getSamlObject(samlRequest)); + if (log.isDebugEnabled()) { + log.debug("Back end log out request received for the session Id : " + index); } + var jSessionId = getSsoSessions()[index]; + delete getSsoSessions()[index]; + session.invalidate(); } }; From a0586ca9771a941ef7aa592588528511a17b6c0c Mon Sep 17 00:00:00 2001 From: Megala Date: Mon, 3 Oct 2016 11:34:00 +0530 Subject: [PATCH 04/12] Adding comment --- .../jaggeryapps/uuf-template-app/lib/modules/auth/auth.js | 1 + 1 file changed, 1 insertion(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index c3343731fd..34d3387284 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -546,6 +546,7 @@ var module = {}; } } } + // If it is a logout request if (samlRequest) { var index = ssoClient.decodeSAMLLogoutRequest(ssoClient.getSamlObject(samlRequest)); if (log.isDebugEnabled()) { From ee97631eacab25f438b99755d70ef4c3d38a69e3 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 3 Oct 2016 12:16:01 +0530 Subject: [PATCH 05/12] Updated MSSQL scripts to have IF-NOT-EXISTS statements --- .../resources/dbscripts/certMgt/mssql.sql | 1 + .../main/resources/dbscripts/cdm/mssql.sql | 45 ++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/dbscripts/certMgt/mssql.sql b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/dbscripts/certMgt/mssql.sql index 7abe97f1df..316b06d726 100644 --- a/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/dbscripts/certMgt/mssql.sql +++ b/features/certificate-mgt/org.wso2.carbon.certificate.mgt.server.feature/src/main/resources/dbscripts/certMgt/mssql.sql @@ -1,3 +1,4 @@ +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_CERTIFICATE]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_CERTIFICATE ( ID INTEGER IDENTITY(1,1) NOT NULL, SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql index 0495a390d9..40adb654e0 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -1,3 +1,4 @@ +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_TYPE]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_TYPE ( ID INTEGER IDENTITY(1,1) NOT NULL, NAME VARCHAR(300) DEFAULT NULL, @@ -7,8 +8,10 @@ CREATE TABLE DM_DEVICE_TYPE ( CONSTRAINT DEVICE_TYPE_NAME UNIQUE(NAME) ); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DEVICE_TYPE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_TYPE')) CREATE INDEX IDX_DEVICE_TYPE ON DM_DEVICE_TYPE (NAME); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE ( ID INTEGER IDENTITY(1,1) NOT NULL, DESCRIPTION VARCHAR(MAX) DEFAULT NULL, @@ -22,8 +25,10 @@ CREATE TABLE DM_DEVICE ( REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_DM_DEVICE' AND OBJECT_ID = OBJECT_ID('DM_DEVICE')) CREATE INDEX IDX_DM_DEVICE ON DM_DEVICE(TENANT_ID, DEVICE_TYPE_ID); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_OPERATION]') AND TYPE IN (N'U')) CREATE TABLE DM_OPERATION ( ID INTEGER IDENTITY(1,1) NOT NULL, TYPE VARCHAR(20) NOT NULL, @@ -33,6 +38,7 @@ CREATE TABLE DM_OPERATION ( PRIMARY KEY (ID) ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_CONFIG_OPERATION]') AND TYPE IN (N'U')) CREATE TABLE DM_CONFIG_OPERATION ( OPERATION_ID INTEGER NOT NULL, OPERATION_CONFIG VARBINARY(MAX) DEFAULT NULL, @@ -41,6 +47,7 @@ CREATE TABLE DM_CONFIG_OPERATION ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_COMMAND_OPERATION]') AND TYPE IN (N'U')) CREATE TABLE DM_COMMAND_OPERATION ( OPERATION_ID INTEGER NOT NULL, ENABLED BIT NOT NULL DEFAULT 0, @@ -49,6 +56,7 @@ CREATE TABLE DM_COMMAND_OPERATION ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_OPERATION]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY_OPERATION ( OPERATION_ID INTEGER NOT NULL, ENABLED INTEGER NOT NULL DEFAULT 0, @@ -58,6 +66,7 @@ CREATE TABLE DM_POLICY_OPERATION ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_PROFILE_OPERATION]') AND TYPE IN (N'U')) CREATE TABLE DM_PROFILE_OPERATION ( OPERATION_ID INTEGER NOT NULL, ENABLED INTEGER NOT NULL DEFAULT 0, @@ -67,6 +76,7 @@ CREATE TABLE DM_PROFILE_OPERATION ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ENROLMENT]') AND TYPE IN (N'U')) CREATE TABLE DM_ENROLMENT ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, @@ -81,9 +91,12 @@ CREATE TABLE DM_ENROLMENT ( DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_FK_DEVICE_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT')) CREATE INDEX IDX_ENROLMENT_FK_DEVICE_ID ON DM_ENROLMENT(DEVICE_ID); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_DEVICE_ID_TENANT_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT')) CREATE INDEX IDX_ENROLMENT_DEVICE_ID_TENANT_ID ON DM_ENROLMENT(DEVICE_ID, TENANT_ID); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ENROLMENT_OP_MAPPING]') AND TYPE IN (N'U')) CREATE TABLE DM_ENROLMENT_OP_MAPPING ( ID INTEGER IDENTITY(1,1) NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -98,10 +111,14 @@ CREATE TABLE DM_ENROLMENT_OP_MAPPING ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENROLMENT_OP_MAPPING' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING')) CREATE INDEX IDX_ENROLMENT_OP_MAPPING ON DM_ENROLMENT_OP_MAPPING (UPDATED_TIMESTAMP); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_EN_OP_MAPPING_EN_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING')) CREATE INDEX IDX_EN_OP_MAPPING_EN_ID ON DM_ENROLMENT_OP_MAPPING(ENROLMENT_ID); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_EN_OP_MAPPING_OP_ID' AND OBJECT_ID = OBJECT_ID('DM_ENROLMENT_OP_MAPPING')) CREATE INDEX IDX_EN_OP_MAPPING_OP_ID ON DM_ENROLMENT_OP_MAPPING(OPERATION_ID); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_OPERATION_RESPONSE]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_OPERATION_RESPONSE ( ID INTEGER IDENTITY(1,1) NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -115,10 +132,12 @@ CREATE TABLE DM_DEVICE_OPERATION_RESPONSE ( DM_OPERATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IDX_ENID_OPID' AND OBJECT_ID = OBJECT_ID('DM_DEVICE_OPERATION_RESPONSE')) CREATE INDEX IDX_ENID_OPID ON DM_DEVICE_OPERATION_RESPONSE(OPERATION_ID, ENROLMENT_ID); -- POLICY RELATED TABLES -- +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_PROFILE]') AND TYPE IN (N'U')) CREATE TABLE DM_PROFILE ( ID INTEGER IDENTITY(1,1) NOT NULL, PROFILE_NAME VARCHAR(45) NOT NULL , @@ -131,6 +150,7 @@ CREATE TABLE DM_PROFILE ( DM_DEVICE_TYPE (NAME) ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, NAME VARCHAR(45) DEFAULT NULL , @@ -147,6 +167,7 @@ CREATE TABLE DM_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL , @@ -160,6 +181,7 @@ CREATE TABLE DM_DEVICE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_TYPE_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_TYPE_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_TYPE_ID INTEGER NOT NULL , @@ -171,6 +193,7 @@ CREATE TABLE DM_DEVICE_TYPE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_PROFILE_FEATURES]') AND TYPE IN (N'U')) CREATE TABLE DM_PROFILE_FEATURES ( ID INTEGER IDENTITY(1,1) NOT NULL, PROFILE_ID INTEGER NOT NULL, @@ -183,6 +206,7 @@ CREATE TABLE DM_PROFILE_FEATURES ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_ROLE_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_ROLE_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, ROLE_NAME VARCHAR(45) NOT NULL , @@ -192,6 +216,7 @@ CREATE TABLE DM_ROLE_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_USER_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_USER_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, POLICY_ID INTEGER NOT NULL , @@ -201,6 +226,7 @@ CREATE TABLE DM_USER_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_POLICY_APPLIED]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_POLICY_APPLIED ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL , @@ -217,6 +243,7 @@ CREATE TABLE DM_USER_POLICY ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_CRITERIA]') AND TYPE IN (N'U')) CREATE TABLE DM_CRITERIA ( ID INTEGER IDENTITY(1,1) NOT NULL, TENANT_ID INTEGER NOT NULL, @@ -224,6 +251,7 @@ CREATE TABLE DM_CRITERIA ( PRIMARY KEY (ID) ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CRITERIA]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY_CRITERIA ( ID INTEGER IDENTITY(1,1) NOT NULL, CRITERIA_ID INTEGER NOT NULL, @@ -235,6 +263,7 @@ CREATE TABLE DM_POLICY_CRITERIA ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CRITERIA_PROPERTIES]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES ( ID INTEGER IDENTITY(1,1) NOT NULL, POLICY_CRITERION_ID INTEGER NOT NULL, @@ -246,6 +275,7 @@ CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES ( ON DELETE CASCADE ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_COMPLIANCE_STATUS]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, @@ -260,6 +290,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( PRIMARY KEY (ID) ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_CHANGE_MGT]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY_CHANGE_MGT ( ID INTEGER IDENTITY(1,1) NOT NULL, POLICY_ID INTEGER NOT NULL, @@ -268,6 +299,7 @@ CREATE TABLE DM_POLICY_CHANGE_MGT ( PRIMARY KEY (ID) ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_POLICY_COMPLIANCE_FEATURES]') AND TYPE IN (N'U')) CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES ( ID INTEGER IDENTITY(1,1) NOT NULL, COMPLIANCE_STATUS_ID INTEGER NOT NULL, @@ -279,6 +311,7 @@ CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES ( ON DELETE NO ACTION ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_APPLICATION]') AND TYPE IN (N'U')) CREATE TABLE DM_APPLICATION ( ID INTEGER IDENTITY(1,1) NOT NULL, NAME VARCHAR(150) NOT NULL, @@ -296,6 +329,7 @@ CREATE TABLE DM_APPLICATION ( PRIMARY KEY (ID) ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_APPLICATION_MAPPING]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, @@ -312,7 +346,7 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( -- DEVICE GROUP TABLES -- - +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_GROUP]') AND TYPE IN (N'U')) CREATE TABLE DM_GROUP ( ID INTEGER IDENTITY(1,1) NOT NULL, GROUP_NAME VARCHAR(100) DEFAULT NULL, @@ -324,6 +358,7 @@ CREATE TABLE DM_GROUP ( PRIMARY KEY (ID) ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_GROUP_MAP]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_GROUP_MAP ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER DEFAULT NULL, @@ -339,7 +374,7 @@ CREATE TABLE DM_DEVICE_GROUP_MAP ( -- END OF DEVICE GROUP TABLES -- -- POLICY AND DEVICE GROUP MAPPING -- - +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_GROUP_POLICY]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_GROUP_POLICY ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_GROUP_ID INTEGER NOT NULL, @@ -361,6 +396,7 @@ CREATE TABLE DM_DEVICE_GROUP_POLICY ( -- END OF POLICY AND DEVICE GROUP MAPPING -- -- NOTIFICATION TABLE -- +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_NOTIFICATION]') AND TYPE IN (N'U')) CREATE TABLE DM_NOTIFICATION ( NOTIFICATION_ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, @@ -376,6 +412,7 @@ CREATE TABLE DM_NOTIFICATION ( ); -- NOTIFICATION TABLE END -- +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_INFO]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_INFO ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NULL, @@ -387,6 +424,7 @@ CREATE TABLE DM_DEVICE_INFO ( ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_LOCATION]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_LOCATION ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NULL, @@ -408,6 +446,7 @@ CREATE TABLE DM_DEVICE_LOCATION ( ON UPDATE NO ACTION ); +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_DETAIL]') AND TYPE IN (N'U')) CREATE TABLE DM_DEVICE_DETAIL ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, @@ -438,6 +477,7 @@ CREATE TABLE DM_DEVICE_DETAIL ( -- DASHBOARD RELATED VIEWS -- +IF NOT EXISTS (SELECT * FROM SYS.VIEWS WHERE NAME = 'POLICY_COMPLIANCE_INFO') exec('CREATE VIEW POLICY_COMPLIANCE_INFO AS SELECT TOP 100 PERCENT DEVICE_INFO.DEVICE_ID, @@ -469,6 +509,7 @@ DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID ORDER BY DEVICE_INFO.DEVICE_ID'); +IF NOT EXISTS (SELECT * FROM SYS.VIEWS WHERE NAME = 'CREATE VIEW FEATURE_NON_COMPLIANCE_INFO') exec('CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS SELECT TOP 100 PERCENT DM_DEVICE.ID AS DEVICE_ID, From befb5b0ad86ebd44b7fd32ea4712ac0f5b999103 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 3 Oct 2016 14:13:06 +0530 Subject: [PATCH 06/12] EMM-1658:Changed the API contract to not to send username parameter. User can only change his own password. --- .../service/api/UserManagementService.java | 5 ----- .../impl/UserManagementServiceImpl.java | 6 +++--- .../CredentialManagementResponseBuilder.java | 18 ++++++++---------- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index 356aa7afef..9be8afd4eb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -472,11 +472,6 @@ public interface UserManagementService { }) @Permission(name = "Reset user password", permission = "/login") Response resetPassword( - @ApiParam( - name = "username", - value = "Username of the user.", - required = true) - @PathParam("username") String username, @ApiParam( name = "credentials", value = "Credential.", 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 294e52928c..43f52d812a 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 @@ -373,10 +373,10 @@ public class UserManagementServiceImpl implements UserManagementService { } @PUT - @Path("/{username}/credentials") + @Path("/credentials") @Override - public Response resetPassword(@PathParam("username") String username, OldPasswordResetWrapper credentials) { - return CredentialManagementResponseBuilder.buildChangePasswordResponse(username, credentials); + public Response resetPassword(OldPasswordResetWrapper credentials) { + return CredentialManagementResponseBuilder.buildChangePasswordResponse(credentials); } /** diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java index 09371c3c5d..7007aa0d3e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/util/CredentialManagementResponseBuilder.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.jaxrs.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse; import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PasswordResetWrapper; @@ -43,26 +44,23 @@ public class CredentialManagementResponseBuilder { /** * Builds the response to change the password of a user * - * @param username - Username of the user. * @param credentials - User credentials * @return Response Object */ - public static Response buildChangePasswordResponse(String username, OldPasswordResetWrapper credentials) { + public static Response buildChangePasswordResponse(OldPasswordResetWrapper credentials) { + String username = ""; try { - UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); - if (!userStoreManager.isExistingUser(username)) { - return Response.status(Response.Status.NOT_FOUND).entity( - new ErrorResponse.ErrorResponseBuilder().setMessage("No user found with the username '" - + username + "'").build()).build(); - } RequestValidationUtil.validateCredentials(credentials); - if (!validateCredential(credentials.getNewPassword())) { String errorMsg = DeviceMgtAPIUtils.getRealmService().getBootstrapRealmConfiguration() - .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG); + .getUserStoreProperty(PASSWORD_VALIDATION_ERROR_MSG_TAG); return Response.status(Response.Status.BAD_REQUEST).entity( new ErrorResponse.ErrorResponseBuilder().setMessage(errorMsg).build()).build(); } + + UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); + // this is the user who initiates the request + username = CarbonContext.getThreadLocalCarbonContext().getUsername(); userStoreManager.updateCredential(username, credentials.getNewPassword(), credentials.getOldPassword()); return Response.status(Response.Status.OK).entity("UserImpl password by username: " + From e8eb0123c7b44cad0f686d9ca772dceb1c6e910f Mon Sep 17 00:00:00 2001 From: Megala Date: Mon, 3 Oct 2016 14:18:43 +0530 Subject: [PATCH 07/12] Fixing the tenant loading problem when sso is enabled --- .../resources/jaggeryapps/devicemgt/app/modules/login.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js index d36e7af0ab..612d0d41dd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js @@ -35,6 +35,11 @@ var onFail; if (!context.input.samlToken) { (new carbonServer.Server({url: devicemgtProps["adminService"]})) .login(context.input.username, context.input.password); + } else { + var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext; + PrivilegedCarbonContext.startTenantFlow(); + var cxt = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + cxt.setTenantDomain(context.user.domain, true); } }; From 672de3a09e464bf0ff5244bd4106799e91a8b2fd Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 3 Oct 2016 14:57:46 +0530 Subject: [PATCH 08/12] Device status change fix for iOS --- .../mgt/core/operation/mgt/OperationManagerImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java index 284a3bc892..5fc20e67d8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/operation/mgt/OperationManagerImpl.java @@ -431,6 +431,18 @@ public class OperationManagerImpl implements OperationManager { "Identifier:" + deviceId.getId() + " and given type" + deviceId.getType()); } + int enrolmentId = enrolmentInfo.getId(); + //Changing the enrollment status & attempt count if the device is marked as inactive or unreachable + switch (enrolmentInfo.getStatus()) { + case ACTIVE: + this.resetAttemptCount(enrolmentId); + break; + case INACTIVE: + case UNREACHABLE: + this.resetAttemptCount(enrolmentId); + this.setEnrolmentStatus(enrolmentId, EnrolmentInfo.Status.ACTIVE); + break; + } try { OperationManagementDAOFactory.openConnection(); From 359bd8f3177b652e0960ee7d24746c087445f92c Mon Sep 17 00:00:00 2001 From: Megala Date: Mon, 3 Oct 2016 15:15:27 +0530 Subject: [PATCH 09/12] Fixing tenant loading problem --- .../resources/jaggeryapps/devicemgt/app/modules/login.js | 5 ----- .../jaggeryapps/uuf-template-app/lib/modules/auth/auth.js | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js index 612d0d41dd..d36e7af0ab 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js @@ -35,11 +35,6 @@ var onFail; if (!context.input.samlToken) { (new carbonServer.Server({url: devicemgtProps["adminService"]})) .login(context.input.username, context.input.password); - } else { - var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext; - PrivilegedCarbonContext.startTenantFlow(); - var cxt = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - cxt.setTenantDomain(context.user.domain, true); } }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js index 34d3387284..07cd7dee72 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/modules/auth/auth.js @@ -525,15 +525,15 @@ var module = {}; } /** * @type {{sessionId: string, loggedInUser: string, sessionIndex: string, samlToken: - * string}} + * string}} */ var ssoSession = ssoClient.decodeSAMLLoginResponse(samlResponseObj, samlResponse, session.getId()); if (ssoSession.sessionId) { var ssoSessions = getSsoSessions(); ssoSessions[ssoSession.sessionId] = ssoSession; - if (ssoSessions.sessionIndex != null || ssoSessions.sessionIndex != 'undefined') { - module.loadTenant(ssoSessions.loggedInUser); + if (ssoSession.sessionIndex != null || ssoSession.sessionIndex != 'undefined') { + module.loadTenant(ssoSession.loggedInUser); var carbonUser = (require("carbon")).server.tenantUser(ssoSession.loggedInUser); utils.setCurrentUser(carbonUser.username, carbonUser.domain, carbonUser.tenantId); var scriptArgument = {input: {samlToken: ssoSession.samlToken}, user: module.getCurrentUser()}; From 0290c710e1b3b36387a54dc017ac228df6f0c417 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 3 Oct 2016 10:09:15 +0530 Subject: [PATCH 10/12] Fixing enrollment url for device types --- .../public/templates/listing.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs index f243c444f4..3d17d9a10f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.types.listing/public/templates/listing.hbs @@ -1,5 +1,5 @@ + data-href="{{appContext}}/device/{{deviceTypeName}}/enroll" class="clickable-row">
@@ -9,7 +9,7 @@ {{deviceTypeLabel}} - From 35c23174be8062243505855792653e9d9444a771 Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Mon, 3 Oct 2016 16:04:12 +0530 Subject: [PATCH 11/12] Fixing android sense download issue --- .../main/resources/jaggeryapps/devicemgt/app/conf/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json index 9625762d80..97b955ae7d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json @@ -61,7 +61,7 @@ "roleNameHelpMsg" : "should be in minimum 3 characters long and do not include any whitespaces." }, "generalConfig" : { - "host" : "https://localhost:9443", + "host" : "%http.ip%", "companyName" : "WSO2 Carbon Device Manager", "browserTitle" : "WSO2 Device Manager", "copyrightPrefix" : "\u00A9 %date-year%, ", From a4538a6d6c7d51f7794c99c4b1ee85f9791f4667 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 3 Oct 2016 18:27:20 +0530 Subject: [PATCH 12/12] Removed unnecessary params from paginated queries --- .../device/mgt/jaxrs/beans/ActivityList.java | 2 -- .../mgt/jaxrs/beans/BasePaginatedResult.java | 32 +------------------ .../device/mgt/jaxrs/beans/BasicUserInfo.java | 2 +- .../mgt/jaxrs/beans/BasicUserInfoList.java | 2 -- .../device/mgt/jaxrs/beans/DeviceList.java | 2 -- .../mgt/jaxrs/beans/DeviceTypeList.java | 2 -- .../mgt/jaxrs/beans/NotificationList.java | 2 -- .../device/mgt/jaxrs/beans/OperationList.java | 2 -- .../device/mgt/jaxrs/beans/PolicyList.java | 2 -- .../device/mgt/jaxrs/beans/RoleList.java | 2 -- .../device/mgt/jaxrs/beans/UserInfoList.java | 2 -- .../service/api/UserManagementService.java | 2 +- 12 files changed, 3 insertions(+), 51 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java index 16e9f772a6..deb4f513ad 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/ActivityList.java @@ -48,8 +48,6 @@ public class ActivityList extends BasePaginatedResult { sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" devices: [").append(activities).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java index e423f56708..b3a60032e1 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasePaginatedResult.java @@ -39,34 +39,4 @@ public class BasePaginatedResult { public void setCount(int count) { this.count = count; } - - - /** - * Link to the next subset of resources qualified. \nEmpty if no more resources are to be returned. - */ - @ApiModelProperty(value = "Link to the next subset of resources qualified. \n " + - "Empty if no more resources are to be returned.") - @JsonProperty("next") - public String getNext() { - return next; - } - - public void setNext(String next) { - this.next = next; - } - - /** - * Link to the previous subset of resources qualified. \nEmpty if current subset is the first subset returned. - */ - @ApiModelProperty(value = "Link to the previous subset of resources qualified. \n" + - "Empty if current subset is the first subset returned.") - @JsonProperty("previous") - public String getPrevious() { - return previous; - } - - public void setPrevious(String previous) { - this.previous = previous; - } - -} +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfo.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfo.java index 467fd8afb5..d7c82a9edc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfo.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfo.java @@ -24,8 +24,8 @@ import io.swagger.annotations.ApiModelProperty; @ApiModel(value = "BasicUserInfo", description = "Basic user information and the roles of the user.") public class BasicUserInfo { + @ApiModelProperty(name = "username", value = "The login name of the user.", required = true ) private String username; - @ApiModelProperty(name = "firstname", value = "The first name of the user.", required = true ) private String firstname; @ApiModelProperty(name = "lastname", value = "The last name of the user.", required = true ) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfoList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfoList.java index c8e58383c0..3cf94cbb97 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfoList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/BasicUserInfoList.java @@ -47,8 +47,6 @@ public class BasicUserInfoList extends BasePaginatedResult { sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" users: [").append(users).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceList.java index 11e7505efc..5adb83af03 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceList.java @@ -45,8 +45,6 @@ public class DeviceList extends BasePaginatedResult { sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" devices: [").append(devices).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceTypeList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceTypeList.java index 0398b6c7cf..c33150631e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceTypeList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/DeviceTypeList.java @@ -90,8 +90,6 @@ public class DeviceTypeList { sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" deviceTypes: [").append(deviceTypes).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/NotificationList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/NotificationList.java index ad2297af85..7a7b013b0e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/NotificationList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/NotificationList.java @@ -46,8 +46,6 @@ public class NotificationList extends BasePaginatedResult { sb.append("{"); sb.append(" count: ").append(getCount()).append(","); - sb.append(" next: ").append(getNext()).append(","); - sb.append(" previous: ").append(getPrevious()).append(","); sb.append(" notifications: [").append(notifications).append(""); sb.append("]}"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OperationList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OperationList.java index 0080c8db8c..855f682f1b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OperationList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/OperationList.java @@ -42,8 +42,6 @@ public class OperationList extends BasePaginatedResult { StringBuilder sb = new StringBuilder(); sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" operations: [").append(operations).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java index b7f4436283..8710f2bb74 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/PolicyList.java @@ -45,8 +45,6 @@ public class PolicyList extends BasePaginatedResult { StringBuilder sb = new StringBuilder(); sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" policies: [").append(policies).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java index 11cfaa3ddc..311c4e0634 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/RoleList.java @@ -44,8 +44,6 @@ public class RoleList extends BasePaginatedResult { StringBuilder sb = new StringBuilder(); sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" roles: [").append(roles).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/UserInfoList.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/UserInfoList.java index 6598ca83fb..fc3f575f75 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/UserInfoList.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/beans/UserInfoList.java @@ -46,8 +46,6 @@ public class UserInfoList extends BasePaginatedResult { StringBuilder sb = new StringBuilder(); sb.append("{\n"); sb.append(" count: ").append(getCount()).append(",\n"); - sb.append(" next: ").append(getNext()).append(",\n"); - sb.append(" previous: ").append(getPrevious()).append(",\n"); sb.append(" users: [").append(users).append("\n"); sb.append("]}\n"); return sb.toString(); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java index 9be8afd4eb..7ea6d8d5c5 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/api/UserManagementService.java @@ -440,7 +440,7 @@ public interface UserManagementService { @QueryParam("limit") int limit); @PUT - @Path("/{username}/credentials") + @Path("/credentials") @ApiOperation( consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,