From 8573a284e092bcee1cb00cdc07b5d2b7b335a54d Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Date: Thu, 26 Nov 2015 11:39:11 +0530 Subject: [PATCH 1/4] Enable Domain name in the invitation main --- .../carbon/device/mgt/common/EmailMessageProperties.java | 9 +++++++++ .../carbon/device/mgt/core/email/EmailConstants.java | 1 + .../service/DeviceManagementProviderServiceImpl.java | 9 ++++++++- .../src/main/resources/conf/notification-messages.xml | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java index 2418e0247a8..7bac7098cc8 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/EmailMessageProperties.java @@ -31,6 +31,7 @@ public class EmailMessageProperties { private String title; private String password; private String userName; + private String domainName; public String getUserName() { return userName; @@ -40,6 +41,14 @@ public class EmailMessageProperties { this.userName = userName; } + public String getDomainName() { + return domainName; + } + + public void setDomainName(String domainName) { + this.domainName = domainName; + } + public String getMessageBody() { return messageBody; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java index 2fac0913196..270501a032b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java @@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.core.email; public final class EmailConstants { public static final class EnrolmentEmailConstants { + public static final String DOMAIN = "domain"; public static final String USERNAME = "user-name"; public static final String DOWNLOAD_URL = "downloadUrl"; public static final String ENCODED_SCHEME = "UTF-8"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 5e211a48848..04611b27574 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -588,7 +588,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv break; } } - +log.error("======================================================================"); + log.error(messageBody); +log.error("======================================================================"); StringBuilder messageBuilder = new StringBuilder(); try { @@ -609,6 +611,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv + "\\}", URLEncoder.encode(emailMessageProperties.getUserName(), EmailConstants.EnrolmentEmailConstants .ENCODED_SCHEME)); + messageBody = messageBody.trim().replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.DOMAIN + + "\\}", + URLEncoder.encode(emailMessageProperties.getDomainName(), EmailConstants.EnrolmentEmailConstants + .ENCODED_SCHEME)); messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.PASSWORD + "\\}", URLEncoder.encode(emailMessageProperties.getPassword(), EmailConstants.EnrolmentEmailConstants @@ -624,6 +630,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv messageFooter1.trim()); messageBuilder.append(System.getProperty("line.separator")).append(messageFooter2.trim()); messageBuilder.append(System.getProperty("line.separator")).append(messageFooter3.trim()); + log.info(messageBuilder.toString()); } catch (IOException e) { throw new DeviceManagementException("Error replacing tags in email template '" + diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml index 9b13c5d8088..9ee0a480041 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml @@ -21,6 +21,7 @@
Dear {first-name},
You have been registered to WSO2 MDM with following credentials. +Domain: {domain} Username: {user-name} Password: {password} Below is the link to enroll. From 53064516d3b60bcc2a58c8275f4ba22c56e05c38 Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Date: Thu, 26 Nov 2015 16:02:16 +0530 Subject: [PATCH 2/4] Fix for the Jira Issue EMM-989 --- .../device/mgt/core/email/EmailConstants.java | 2 +- .../DeviceManagementProviderServiceImpl.java | 58 +++++++------------ .../resources/conf/notification-messages.xml | 2 +- 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java index 270501a032b..139a845f85c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/email/EmailConstants.java @@ -20,7 +20,7 @@ package org.wso2.carbon.device.mgt.core.email; public final class EmailConstants { public static final class EnrolmentEmailConstants { - public static final String DOMAIN = "domain"; + public static final String DOMAIN = "domain-name"; public static final String USERNAME = "user-name"; public static final String DOWNLOAD_URL = "downloadUrl"; public static final String ENCODED_SCHEME = "UTF-8"; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 04611b27574..649d024646c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -142,7 +142,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv EnrolmentInfo newEnrolmentInfo = device.getEnrolmentInfo(); if (existingEnrolmentInfo != null && newEnrolmentInfo != null) { //Get all the enrollments of current user for the same device - List enrolmentInfos = this.getEnrollmentsOfUser(existingDevice.getId(), newEnrolmentInfo.getOwner()); + List enrolmentInfos = this.getEnrollmentsOfUser(existingDevice.getId(), + newEnrolmentInfo.getOwner()); for (EnrolmentInfo enrolmentInfo : enrolmentInfos) { //If the enrollments are same then we'll update the existing enrollment. if (enrolmentInfo.equals(newEnrolmentInfo)) { @@ -163,14 +164,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv existingEnrolmentInfo.setStatus(EnrolmentInfo.Status.REMOVED); updateStatus = enrollmentDAO.updateEnrollment(existingEnrolmentInfo); } - if ((updateStatus > 0) || EnrolmentInfo.Status.REMOVED.equals(existingEnrolmentInfo.getStatus())) { - enrolmentId = enrollmentDAO.addEnrollment(existingDevice.getId(), newEnrolmentInfo, tenantId); + if ((updateStatus > 0) || EnrolmentInfo.Status.REMOVED. + equals(existingEnrolmentInfo.getStatus())) { + enrolmentId = enrollmentDAO. + addEnrollment(existingDevice.getId(), newEnrolmentInfo, tenantId); DeviceManagementDAOFactory.commitTransaction(); if (log.isDebugEnabled()) { log.debug("An enrolment is successfully added with the id '" + enrolmentId + "' associated with " + "the device identified by key '" + device.getDeviceIdentifier() + "', which belongs to " + "platform '" + - device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + "'"); + device.getType() + " upon the user '" + device.getEnrolmentInfo().getOwner() + + "'"); } status = true; } else { @@ -232,11 +236,9 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv try { int tenantId = this.getTenantId(); DeviceManagementDAOFactory.beginTransaction(); - DeviceType type = deviceTypeDAO.getDeviceType(device.getType()); deviceDAO.updateDevice(type.getId(), device, tenantId); enrollmentDAO.updateEnrollment(device.getEnrolmentInfo()); - DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -257,8 +259,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv DeviceManagementDAOFactory.openConnection(); enrolmentInfos = enrollmentDAO.getEnrollmentsOfUser(deviceId, user, this.getTenantId()); } catch (DeviceManagementDAOException e) { - throw new DeviceManagementException("Error occurred while obtaining the enrollment information device for id " + - "'" + deviceId + "' and user : " + user, e); + throw new DeviceManagementException("Error occurred while obtaining the enrollment information device for" + + "id '" + deviceId + "' and user : " + user, e); } catch (SQLException e) { throw new DeviceManagementException("Error occurred while opening a connection to the data source", e); } finally { @@ -514,8 +516,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv for (NotificationMessages notificationMessage : notificationMessages) { if (org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailNotifications.ENROL_NOTIFICATION_TYPE - .equals( - notificationMessage.getType())) { + .equals(notificationMessage.getType())) { messageHeader = notificationMessage.getHeader(); messageBody = notificationMessage.getBody(); messageFooter1 = notificationMessage.getFooterLine1(); @@ -535,17 +536,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv EmailConfigurations emailConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). getDeviceManagementConfigRepository().getEmailConfigurations(); - emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix()+ emailConfig.getEnrollmentContextPath()); - + emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix() + + emailConfig.getEnrollmentContextPath()); messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); - messageBody = messageBody.trim() + System.getProperty("line.separator") + - System.getProperty("line.separator") + url.replaceAll("\\{" + messageBody = messageBody.trim() + System.getProperty("line.separator") + url.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); - messageBuilder.append(messageHeader).append(System.getProperty("line.separator")) .append(System.getProperty("line.separator")); messageBuilder.append(messageBody); @@ -553,7 +552,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv messageBuilder.append(messageFooter1.trim()) .append(System.getProperty("line.separator")).append(messageFooter2.trim()).append(System .getProperty("line.separator")).append(messageFooter3.trim()); - } catch (IOException e) { throw new DeviceManagementException("Error replacing tags in email template '" + emailMessageProperties.getSubject() + "'", e); @@ -576,8 +574,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv String subject = ""; for (NotificationMessages notificationMessage : notificationMessages) { - if (org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailNotifications.USER_REGISTRATION_NOTIFICATION_TYPE. - equals(notificationMessage.getType())) { + if (org.wso2.carbon.device.mgt.core.DeviceManagementConstants.EmailNotifications. + USER_REGISTRATION_NOTIFICATION_TYPE.equals(notificationMessage.getType())) { messageHeader = notificationMessage.getHeader(); messageBody = notificationMessage.getBody(); messageFooter1 = notificationMessage.getFooterLine1(); @@ -588,24 +586,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv break; } } -log.error("======================================================================"); - log.error(messageBody); -log.error("======================================================================"); StringBuilder messageBuilder = new StringBuilder(); - try { - // Reading the download url from the cdm-config.xml file EmailConfigurations emailConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). getDeviceManagementConfigRepository().getEmailConfigurations(); - emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix()+ emailConfig.getEnrollmentContextPath()); - - + emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix() + + emailConfig.getEnrollmentContextPath()); messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); - messageBody = messageBody.trim().replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants .USERNAME + "\\}", @@ -615,22 +606,18 @@ log.error("===================================================================== + "\\}", URLEncoder.encode(emailMessageProperties.getDomainName(), EmailConstants.EnrolmentEmailConstants .ENCODED_SCHEME)); - messageBody = messageBody.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.PASSWORD + "\\}", URLEncoder.encode(emailMessageProperties.getPassword(), EmailConstants.EnrolmentEmailConstants .ENCODED_SCHEME)); - messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}", URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); - messageBuilder.append(messageHeader).append(System.getProperty("line.separator")); messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append( messageFooter1.trim()); messageBuilder.append(System.getProperty("line.separator")).append(messageFooter2.trim()); messageBuilder.append(System.getProperty("line.separator")).append(messageFooter3.trim()); - log.info(messageBuilder.toString()); } catch (IOException e) { throw new DeviceManagementException("Error replacing tags in email template '" + @@ -718,7 +705,6 @@ log.error("===================================================================== deviceTypesInDatabase = deviceDAO.getDeviceTypes(); Map registeredTypes = pluginRepository.getAllDeviceManagementServices(); DeviceType deviceType; - if (registeredTypes != null && deviceTypesInDatabase != null) { for (int x = 0; x < deviceTypesInDatabase.size(); x++) { if (registeredTypes.get(deviceTypesInDatabase.get(x).getName()) != null) { @@ -783,11 +769,9 @@ log.error("===================================================================== EnrolmentInfo.Status status) throws DeviceManagementException { try { DeviceManagementDAOFactory.beginTransaction(); - int tenantId = this.getTenantId(); Device device = deviceDAO.getDevice(deviceId, tenantId); boolean success = enrollmentDAO.setStatus(device.getId(), currentOwner, status, tenantId); - DeviceManagementDAOFactory.commitTransaction(); return success; } catch (DeviceManagementDAOException e) { @@ -811,7 +795,8 @@ log.error("===================================================================== dms.notifyOperationToDevices(operation, deviceIds); } } catch (DeviceManagementException deviceMgtEx) { - String errorMsg = "Error in notify operations to plugins for app installation:" + deviceMgtEx.getErrorMessage(); + String errorMsg = "Error in notify operations to plugins for app installation:" + + deviceMgtEx.getErrorMessage(); log.error(errorMsg, deviceMgtEx); throw new DeviceManagementException(errorMsg, deviceMgtEx); } @@ -1038,12 +1023,10 @@ log.error("===================================================================== public void updateDeviceEnrolmentInfo(Device device, EnrolmentInfo.Status status) throws DeviceManagementException { try { DeviceManagementDAOFactory.beginTransaction(); - DeviceType deviceType = deviceTypeDAO.getDeviceType(device.getType()); device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime()); device.getEnrolmentInfo().setStatus(status); deviceDAO.updateDevice(deviceType.getId(), device, this.getTenantId()); - DeviceManagementDAOFactory.commitTransaction(); } catch (DeviceManagementDAOException e) { DeviceManagementDAOFactory.rollbackTransaction(); @@ -1090,7 +1073,6 @@ log.error("===================================================================== } finally { DeviceManagementDAOFactory.closeConnection(); } - for (Device device : allDevices) { Device dmsDevice = this.getDeviceManager(device.getType()). getDevice(new DeviceIdentifier(device.getDeviceIdentifier(), device.getType())); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml index 9ee0a480041..eabecf785b4 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/notification-messages.xml @@ -21,7 +21,7 @@
Dear {first-name},
You have been registered to WSO2 MDM with following credentials. -Domain: {domain} +Domain: {domain-name} Username: {user-name} Password: {password} Below is the link to enroll. From d95a198ad62b74ad60adc2a52df636785aff56c6 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 30 Nov 2015 19:56:47 +0530 Subject: [PATCH 3/4] Fixed EMM-1001 --- .../carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 2 +- .../device/mgt/core/operation/mgt/OperationManagerImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index aedc981f487..c5b7a4e13e7 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -609,7 +609,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { stmt.setString(index++, status.toString()); stmt.setInt(index, tenantId); rs = stmt.executeQuery(); - if (rs.next()) { + while (rs.next()) { enrolments.add(DeviceManagementDAOUtil.loadEnrolment(rs)); } return enrolments; 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 58cb057153c..7ef4b8f5da4 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 @@ -97,7 +97,7 @@ public class OperationManagerImpl implements OperationManager { List enrolments; try { DeviceManagementDAOFactory.openConnection(); - enrolments = deviceDAO.getEnrolmentsByStatus(deviceIds, EnrolmentInfo.Status.ACTIVE, tenantId); + enrolments = deviceDAO.getEnrolmentsByStatus(authorizedDeviceList, EnrolmentInfo.Status.ACTIVE, tenantId); } catch (SQLException e) { throw new OperationManagementException("Error occurred while opening a connection the data " + "source", e); From 73906f7cdab1fa7bbaba2c34d620912527ed9367 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 30 Nov 2015 22:20:33 +0530 Subject: [PATCH 4/4] Fixed EMM-1003 --- .../mgt/core/dao/impl/AbstractDeviceDAOImpl.java | 15 +++++++-------- .../framework/WebappAuthenticationValve.java | 4 +++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java index c5b7a4e13e7..14e1109cf57 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/AbstractDeviceDAOImpl.java @@ -300,16 +300,15 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO { List devices = new ArrayList<>(); try { conn = this.getConnection(); - String sql = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " + - "d1.DEVICE_IDENTIFICATION, e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, " + - "e.DATE_OF_ENROLMENT, e.ID AS ENROLMENT_ID FROM DM_ENROLMENT e, (SELECT t.NAME AS DEVICE_TYPE, " + - "d.ID, d.DESCRIPTION, d.NAME, d.DEVICE_IDENTIFICATION FROM DM_DEVICE d, DM_DEVICE_TYPE t " + - "WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 " + - "WHERE DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ? AND e.OWNER = ?"; + String sql = "SELECT e1.OWNER, e1.OWNERSHIP, e1.ENROLMENT_ID, e1.DEVICE_ID, e1.STATUS, e1.DATE_OF_LAST_UPDATE," + + " e1.DATE_OF_ENROLMENT, d.DESCRIPTION, d.NAME AS DEVICE_NAME, d.DEVICE_IDENTIFICATION, t.NAME " + + "AS DEVICE_TYPE FROM DM_DEVICE d, (SELECT e.OWNER, e.OWNERSHIP, e.ID AS ENROLMENT_ID, " + + "e.DEVICE_ID, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e WHERE " + + "e.TENANT_ID = ? AND e.OWNER = ?) e1, DM_DEVICE_TYPE t WHERE d.ID = e1.DEVICE_ID " + + "AND t.ID = d.DEVICE_TYPE_ID"; stmt = conn.prepareStatement(sql); stmt.setInt(1, tenantId); - stmt.setInt(2, tenantId); - stmt.setString(3, username); + stmt.setString(2, username); ResultSet rs = stmt.executeQuery(); while (rs.next()) { diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java index da8b4cfabc9..b701b9bf966 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java @@ -139,7 +139,9 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { msg = authenticationInfo.getMessage(); response.setHeader("WWW-Authenticate", msg); } - log.error(msg + " , API : " + request.getRequestURI()); + if (log.isDebugEnabled()) { + log.debug(msg + " , API : " + request.getRequestURI()); + } AuthenticationFrameworkUtil .handleResponse(request, response, HttpServletResponse.SC_UNAUTHORIZED, msg);