From cb99e4c285b4ee6a0ff1ff56ec516789e243a24c Mon Sep 17 00:00:00 2001 From: inoshperera Date: Tue, 20 Jun 2023 23:37:12 +0530 Subject: [PATCH 1/5] iOS user enrollment support Fixes https://roadmap.entgra.net/issues/10149 --- .../mgt/common/general/QREnrollmentDetails.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java index 38153881a2..fd270dc56d 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/general/QREnrollmentDetails.java @@ -18,10 +18,21 @@ package io.entgra.device.mgt.core.device.mgt.common.general; +import java.util.Map; + public class QREnrollmentDetails { String ownershipType; String username; String enrollmentMode; + Map customValues; + + public Map getCustomValues() { + return customValues; + } + + public void setCustomValues(Map customValues) { + this.customValues = customValues; + } public String getOwnershipType() { return ownershipType; } From 00bd74734a639517930f904e98c2208b9737d0c3 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Wed, 21 Jun 2023 23:32:48 +0530 Subject: [PATCH 2/5] Remove apim_reserved_user when fetching users --- .../jaxrs/service/impl/UserManagementServiceImpl.java | 9 +++++++++ .../mgt/core/device/mgt/api/jaxrs/util/Constants.java | 1 + 2 files changed, 10 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java index d8db5e3776..29a64a9238 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImpl.java @@ -455,6 +455,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(users.size()); BasicUserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = getBasicUserInfo(username); userList.add(user); } @@ -515,6 +518,9 @@ public class UserManagementServiceImpl implements UserManagementService { if (StringUtils.isNotEmpty(username)) { commonUsers = getUserList(null, username); } + if (commonUsers != null) { + commonUsers.remove(Constants.APIM_RESERVED_USER); + } if (!skipSearch(commonUsers) && StringUtils.isNotEmpty(firstName)) { tempList = getUserList(Constants.USER_CLAIM_FIRST_NAME, firstName); @@ -689,6 +695,9 @@ public class UserManagementServiceImpl implements UserManagementService { userList = new ArrayList<>(); UserInfo user; for (String username : users) { + if (Constants.APIM_RESERVED_USER.equals(username)) { + continue; + } user = new UserInfo(); user.setUsername(username); user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS)); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java index 300e47b147..c9ad2e182e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/Constants.java @@ -30,6 +30,7 @@ public class Constants { public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified"; public static final String USER_CLAIM_DEVICES = "http://wso2.org/claims/devices"; public static final String PRIMARY_USER_STORE = "PRIMARY"; + public static final String APIM_RESERVED_USER = "apim_reserved_user"; public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String SCOPE = "scope"; public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager"; From d862ab814393edd127439849e319b1ad2d9de2b9 Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Thu, 22 Jun 2023 19:45:11 +0530 Subject: [PATCH 3/5] Fix incorrect clear app scope --- .../src/main/resources/conf/mdm-ui-config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml index 46114821a2..809c856038 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/conf/mdm-ui-config.xml @@ -224,7 +224,7 @@ perm:admin:tenant:view perm:admin:metadata:view perm:admin:usage:view - perm:android:clear-applicatio + perm:android:clear-application perm:android:suspend-package perm:android:alternate-install From 6109f58c49d420b868bf827ca809f67e6da86328 Mon Sep 17 00:00:00 2001 From: Oshani Silva Date: Sun, 25 Jun 2023 19:14:59 +0000 Subject: [PATCH 4/5] Remove unwanted check in billing logic Co-authored-by: Oshani Silva Co-committed-by: Oshani Silva --- .../DeviceManagementProviderServiceImpl.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 8dcaf1ebca..0d2a3fb42c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -156,6 +156,7 @@ import java.lang.reflect.Type; import java.sql.SQLException; import java.sql.Timestamp; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; @@ -1069,7 +1070,15 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv dateDiff = endDate.getTime() - device.getEnrolmentInfo().getDateOfEnrolment(); } } - long dateInDays = TimeUnit.DAYS.convert(dateDiff, TimeUnit.MILLISECONDS); + + // Convert dateDiff to days as a decimal value + double dateDiffInDays = (double) dateDiff / (24 * 60 * 60 * 1000); + + if (dateDiffInDays % 1 >= 0.9) { + dateDiffInDays = Math.ceil(dateDiffInDays); + } + + long dateInDays = (long) dateDiffInDays; double cost = (tenantCost.getCost() / 365) * dateInDays; totalCost += cost; device.setCost(Math.round(cost * 100.0) / 100.0); @@ -1136,9 +1145,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv long difference_In_Days = (difference_In_Time / (1000 * 60 * 60 * 24)) % 365; + if (difference_In_Time % (1000 * 60 * 60 * 24) >= 0.9 * (1000 * 60 * 60 * 24)) { + difference_In_Days++; + } + for (int i = 1; i <= difference_In_Years; i++) { List allDevicesPerYear = new ArrayList<>(); - LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + LocalDateTime oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; Timestamp newStartDate; Timestamp newEndDate; @@ -1147,14 +1160,12 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv remainingDaysConsidered = true; oneYearAfterStart = startDate.toLocalDateTime(); newEndDate = endDate; - } else if (Timestamp.valueOf(oneYearAfterStart).getTime() >= endDate.getTime()) { - newEndDate = Timestamp.valueOf(oneYearAfterStart); } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; newEndDate = Timestamp.valueOf(oneYearAfterStart); } } else { - oneYearAfterStart = startDate.toLocalDateTime().plusYears(1); + oneYearAfterStart = startDate.toLocalDateTime().plusYears(1).with(LocalTime.of(23, 59, 59));; newEndDate = Timestamp.valueOf(oneYearAfterStart); } @@ -1177,7 +1188,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv allDevices.addAll(billingResponse.getDevice()); totalCost = totalCost + billingResponse.getTotalCostPerYear(); deviceCount = deviceCount + billingResponse.getDeviceCount(); - LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1); + LocalDateTime nextStartDate = oneYearAfterStart.plusDays(1).with(LocalTime.of(00, 00, 00)); startDate = Timestamp.valueOf(nextStartDate); } From 7073deb4619c601b52b4487df5d5560c780e818c Mon Sep 17 00:00:00 2001 From: navodzoysa Date: Mon, 26 Jun 2023 14:15:29 +0530 Subject: [PATCH 5/5] Fix skip app release error --- .../application/mgt/core/impl/ApplicationManagerImpl.java | 6 +++--- .../device/mgt/core/application/mgt/core/util/APIUtil.java | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java index b7fd8f23b5..51dc57868d 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/impl/ApplicationManagerImpl.java @@ -1283,13 +1283,13 @@ public class ApplicationManagerImpl implements ApplicationManager { this.changeLifecycleState(applicationReleaseDTO, lifecycleChanger); } } + if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { + persistAppIconInfo(applicationReleaseDTO); + } applicationReleaseEntities.add(applicationReleaseDTO); } applicationDTO.setId(appId); applicationDTO.setApplicationReleaseDTOs(applicationReleaseEntities); - if (applicationDTO.getType().equals("ENTERPRISE") || applicationDTO.getType().equals("PUBLIC") ) { - persistAppIconInfo(applicationReleaseDTO); - } return APIUtil.appDtoToAppResponse(applicationDTO); } } catch (LifeCycleManagementDAOException e) { diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java index 407b4ebcac..b33fce5bf2 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/APIUtil.java @@ -521,7 +521,6 @@ public class APIUtil { public static String createAppIconPath(ApplicationReleaseDTO applicationReleaseDTO, int tenantId) throws ApplicationManagementException { String basePath = getArtifactDownloadBaseURL() + tenantId + Constants.FORWARD_SLASH + applicationReleaseDTO .getAppHashValue() + Constants.FORWARD_SLASH; - String iconPath = basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); - return iconPath; + return basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName(); } }