From efb18aed692861034a817d732f28a338ba8e1d29 Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:29:00 -0500 Subject: [PATCH 1/7] Comprobantes --- .../controller/configurations.controller.js | 49 +++++++++++++++++++ .../components/main/view/configuration.html | 4 +- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/server/src/main/webapp/app/components/main/controller/configurations.controller.js b/server/src/main/webapp/app/components/main/controller/configurations.controller.js index 42048056..634d386f 100644 --- a/server/src/main/webapp/app/components/main/controller/configurations.controller.js +++ b/server/src/main/webapp/app/components/main/controller/configurations.controller.js @@ -311,7 +311,51 @@ angular.module('headwind-kiosk') function ($scope, configurationService, settingsService, $stateParams, $state, $rootScope, $window, $timeout, $transitions, localization, confirmModal, alertService, $modal, appVersionComparisonService, settingsService) { + $scope.successMessage = null; + + $scope.configuration = { + kioskMode: false, + kioskHome: false, + kioskRecents: false, + kioskNotifications: false, + kioskSystemInfo: false, + kioskKeyguard: false, + kioskLockButtons: false, + kioskExit: false + }; + + + $scope.onKioskModeChange = function() { + if ($scope.configuration.kioskMode) { + console.log("Kiosk Mode activado"); + } else { + console.log("Kiosk Mode desactivado"); + } + }; + + $scope.logKioskMode = function () { + console.log("Kiosk Mode:", $scope.configuration.kioskMode); + console.log("Kiosk Home:", $scope.configuration.kioskHome); + console.log("Kiosk Recents:", $scope.configuration.kioskRecents); + console.log("Kiosk Notifications:", $scope.configuration.kioskNotifications); + console.log("Kiosk System Info:", $scope.configuration.kioskSystemInfo); + console.log("Kiosk Keyguard:", $scope.configuration.kioskKeyguard); + console.log("Kiosk Lock Buttons:", $scope.configuration.kioskLockButtons); + console.log("Kiosk Exit:", $scope.configuration.kioskExit); + }; + + $scope.printKioskModeConfig = function() { + console.log("Kiosk Mode Configuration:"); + console.log("kioskMode:", $scope.configuration.kioskMode); + console.log("kioskHome:", $scope.configuration.kioskHome); + console.log("kioskRecents:", $scope.configuration.kioskRecents); + console.log("kioskNotifications:", $scope.configuration.kioskNotifications); + console.log("kioskSystemInfo:", $scope.configuration.kioskSystemInfo); + console.log("kioskKeyguard:", $scope.configuration.kioskKeyguard); + console.log("kioskLockButtons:", $scope.configuration.kioskLockButtons); + console.log("kioskExit:", $scope.configuration.kioskExit); + }; let sortItem = $window.localStorage.getItem('HMDM_configAppsSortBy'); $scope.sort = { @@ -658,6 +702,7 @@ angular.module('headwind-kiosk') } }); }; + $scope.save = function (doClose) { $scope.errorMessage = ''; @@ -672,6 +717,10 @@ angular.module('headwind-kiosk') } else if ($scope.configuration.kioskMode && (!contentAppSelected)) { $scope.errorMessage = localization.localize('error.empty.configuration.contentApp'); } else { + + $scope.logKioskMode(); + $scope.printKioskModeConfig(); + var request = {}; for (var prop in $scope.configuration) { diff --git a/server/src/main/webapp/app/components/main/view/configuration.html b/server/src/main/webapp/app/components/main/view/configuration.html index 66bee1e6..be319816 100644 --- a/server/src/main/webapp/app/components/main/view/configuration.html +++ b/server/src/main/webapp/app/components/main/view/configuration.html @@ -703,9 +703,9 @@

form.configuration.title.typical &q
- +
-
+
From 567526cbf4ff8aff70abe1b18632f5f25484cf6e Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:11:25 -0500 Subject: [PATCH 2/7] =?UTF-8?q?Bot=C3=B3n=20de=20alerta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/configurations.controller.js | 22 +++++++++++-------- .../components/main/view/configuration.html | 2 +- server/webtarget/package-lock.json | 5 +++++ server/webtarget/package.json | 1 + 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/server/src/main/webapp/app/components/main/controller/configurations.controller.js b/server/src/main/webapp/app/components/main/controller/configurations.controller.js index 634d386f..4d697b1c 100644 --- a/server/src/main/webapp/app/components/main/controller/configurations.controller.js +++ b/server/src/main/webapp/app/components/main/controller/configurations.controller.js @@ -346,16 +346,20 @@ angular.module('headwind-kiosk') }; $scope.printKioskModeConfig = function() { - console.log("Kiosk Mode Configuration:"); - console.log("kioskMode:", $scope.configuration.kioskMode); - console.log("kioskHome:", $scope.configuration.kioskHome); - console.log("kioskRecents:", $scope.configuration.kioskRecents); - console.log("kioskNotifications:", $scope.configuration.kioskNotifications); - console.log("kioskSystemInfo:", $scope.configuration.kioskSystemInfo); - console.log("kioskKeyguard:", $scope.configuration.kioskKeyguard); - console.log("kioskLockButtons:", $scope.configuration.kioskLockButtons); - console.log("kioskExit:", $scope.configuration.kioskExit); + var message = "Configuración del Kiosk Mode:\n"; + message += "Kiosk Mode: " + $scope.configuration.kioskMode + "\n"; + message += "Kiosk Home: " + $scope.configuration.kioskHome + "\n"; + message += "Kiosk Recents: " + $scope.configuration.kioskRecents + "\n"; + message += "Kiosk Notifications: " + $scope.configuration.kioskNotifications + "\n"; + message += "Kiosk System Info: " + $scope.configuration.kioskSystemInfo + "\n"; + message += "Kiosk Keyguard: " + $scope.configuration.kioskKeyguard + "\n"; + message += "Kiosk Lock Buttons: " + $scope.configuration.kioskLockButtons + "\n"; + message += "Kiosk Exit: " + $scope.configuration.kioskExit; + + // Mostrar un mensaje de advertencia en la pantalla + $window.alert(message); }; + let sortItem = $window.localStorage.getItem('HMDM_configAppsSortBy'); $scope.sort = { diff --git a/server/src/main/webapp/app/components/main/view/configuration.html b/server/src/main/webapp/app/components/main/view/configuration.html index be319816..8fa86408 100644 --- a/server/src/main/webapp/app/components/main/view/configuration.html +++ b/server/src/main/webapp/app/components/main/view/configuration.html @@ -909,7 +909,7 @@

form.configuration.title.typical &q
 
- +
diff --git a/server/webtarget/package-lock.json b/server/webtarget/package-lock.json index 369d1aec..44d6843d 100644 --- a/server/webtarget/package-lock.json +++ b/server/webtarget/package-lock.json @@ -8,6 +8,7 @@ "name": "controlled-launcher-webclient", "version": "0.1.0", "dependencies": { + "controlled-launcher-webclient": "file:", "leaflet.gridlayer.googlemutant": "~0.8.0" }, "devDependencies": { @@ -441,6 +442,10 @@ "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, + "node_modules/controlled-launcher-webclient": { + "resolved": "", + "link": true + }, "node_modules/copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", diff --git a/server/webtarget/package.json b/server/webtarget/package.json index 7a5f4e4c..d46d395d 100644 --- a/server/webtarget/package.json +++ b/server/webtarget/package.json @@ -10,6 +10,7 @@ "grunt-contrib-copy": "~1.0.0" }, "dependencies": { + "controlled-launcher-webclient": "file:", "leaflet.gridlayer.googlemutant": "~0.8.0" }, "resolutions": { From 9e1aacb7332248753b4fb4770a45c201a143a152 Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:32:50 -0500 Subject: [PATCH 3/7] Arreglo mensajes por consola --- hmdm_install.sh | 2 +- .../controller/configurations.controller.js | 26 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/hmdm_install.sh b/hmdm_install.sh index ffa0f30f..6b2e870f 100755 --- a/hmdm_install.sh +++ b/hmdm_install.sh @@ -473,7 +473,7 @@ if [[ "$REPLY" =~ ^[Yy]$ ]]; then cd $LOCATION/files for FILE in $FILES; do echo "Downloading $FILE..." - wget $FILE + wget https://h-mdm.com/files/hmdm-5.19-os.apk done chown $TOMCAT_USER:$TOMCAT_USER * echo "UPDATE applicationversions SET url=REPLACE(url, 'https://h-mdm.com', '$PROTOCOL://$BASE_HOST$BASE_PATH') WHERE url IS NOT NULL" | psql $PSQL_CONNSTRING >/dev/null 2>&1 diff --git a/server/src/main/webapp/app/components/main/controller/configurations.controller.js b/server/src/main/webapp/app/components/main/controller/configurations.controller.js index 4d697b1c..e372ddf8 100644 --- a/server/src/main/webapp/app/components/main/controller/configurations.controller.js +++ b/server/src/main/webapp/app/components/main/controller/configurations.controller.js @@ -345,21 +345,6 @@ angular.module('headwind-kiosk') console.log("Kiosk Exit:", $scope.configuration.kioskExit); }; - $scope.printKioskModeConfig = function() { - var message = "Configuración del Kiosk Mode:\n"; - message += "Kiosk Mode: " + $scope.configuration.kioskMode + "\n"; - message += "Kiosk Home: " + $scope.configuration.kioskHome + "\n"; - message += "Kiosk Recents: " + $scope.configuration.kioskRecents + "\n"; - message += "Kiosk Notifications: " + $scope.configuration.kioskNotifications + "\n"; - message += "Kiosk System Info: " + $scope.configuration.kioskSystemInfo + "\n"; - message += "Kiosk Keyguard: " + $scope.configuration.kioskKeyguard + "\n"; - message += "Kiosk Lock Buttons: " + $scope.configuration.kioskLockButtons + "\n"; - message += "Kiosk Exit: " + $scope.configuration.kioskExit; - - // Mostrar un mensaje de advertencia en la pantalla - $window.alert(message); - }; - let sortItem = $window.localStorage.getItem('HMDM_configAppsSortBy'); $scope.sort = { @@ -707,6 +692,17 @@ angular.module('headwind-kiosk') }); }; + $scope.printKioskModeConfig = function() { + console.log("Configuración de Kiosk Mode:"); + console.log("kioskMode:", $scope.configuration.kioskMode); + console.log("kioskHome:", $scope.configuration.kioskHome); + console.log("kioskRecents:", $scope.configuration.kioskRecents); + console.log("kioskNotifications:", $scope.configuration.kioskNotifications); + console.log("kioskSystemInfo:", $scope.configuration.kioskSystemInfo); + console.log("kioskKeyguard:", $scope.configuration.kioskKeyguard); + console.log("kioskLockButtons:", $scope.configuration.kioskLockButtons); + console.log("kioskExit:", $scope.configuration.kioskExit); + }; $scope.save = function (doClose) { $scope.errorMessage = ''; From d37f3855a9ee8147f255d4f3a926e54d79d9f8f3 Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Tue, 24 Sep 2024 09:58:56 -0500 Subject: [PATCH 4/7] =?UTF-8?q?Verificaci=C3=B3n=20de=20devices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/controller/devices.controller.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server/src/main/webapp/app/components/main/controller/devices.controller.js b/server/src/main/webapp/app/components/main/controller/devices.controller.js index f33043d6..251411f0 100644 --- a/server/src/main/webapp/app/components/main/controller/devices.controller.js +++ b/server/src/main/webapp/app/components/main/controller/devices.controller.js @@ -1005,7 +1005,25 @@ angular.module('headwind-kiosk') configurationService.getAllConfigurations(function (response) { $scope.device.configurationId = response.data[0].id; $scope.configurations = response.data; + + // Agregamos aquí el código para mostrar las configuraciones del modo kiosko + var config = response.data[0]; // Recupera la primera configuración, puedes ajustar si necesitas otra + + // Crear el mensaje con las configuraciones recuperadas + var message = + "Kiosk Mode: " + config.kioskMode + "\n" + + "Kiosk Home: " + config.kioskHome + "\n" + + "Kiosk Recents: " + config.kioskRecents + "\n" + + "Kiosk Notifications: " + config.kioskNotifications + "\n" + + "Kiosk System Info: " + config.kioskSystemInfo + "\n" + + "Kiosk Keyguard: " + config.kioskKeyguard + "\n" + + "Kiosk Lock Buttons: " + config.kioskLockButtons + "\n" + + "Kiosk Exit: " + config.kioskExit; + + // Mostrar el mensaje en una ventana emergente + alert(message); }); + $scope.save = function () { var ids = []; From a8075ffec75b114d1983181f4a8cb3540ccb763a Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:47:46 -0500 Subject: [PATCH 5/7] Funciones del modo kiosko --- .../com/hmdm/rest/resource/SyncResource.java | 200 ++++++++++-------- 1 file changed, 111 insertions(+), 89 deletions(-) diff --git a/server/src/main/java/com/hmdm/rest/resource/SyncResource.java b/server/src/main/java/com/hmdm/rest/resource/SyncResource.java index e5cc874d..bc13f528 100644 --- a/server/src/main/java/com/hmdm/rest/resource/SyncResource.java +++ b/server/src/main/java/com/hmdm/rest/resource/SyncResource.java @@ -72,18 +72,21 @@ import org.slf4j.LoggerFactory; /** - *

A resource used for synchronizing the data with devices.

+ *

+ * A resource used for synchronizing the data with devices. + *

*/ @Singleton @Path("/public/sync") -@Api(tags = {"Device data synchronization"}) +@Api(tags = { "Device data synchronization" }) public class SyncResource { - private static final Logger logger = LoggerFactory.getLogger(SyncResource.class); /** - *

DAO objects

+ *

+ * DAO objects + *

*/ private UnsecureDAO unsecureDAO; @@ -92,12 +95,17 @@ public class SyncResource { private CustomerDAO customerDAO; /** - *

A service used for sending notifications on battery level update for device

+ *

+ * A service used for sending notifications on battery level update for device + *

*/ private EventService eventService; /** - *

A list of hooks to be executed against the response to device confoguration synchronization request.

+ *

+ * A list of hooks to be executed against the response to device confoguration + * synchronization request. + *

*/ private Set syncResponseHooks; @@ -117,27 +125,32 @@ public class SyncResource { private String vendor; /** - *

A constructor required by Swagger.

+ *

+ * A constructor required by Swagger. + *

*/ public SyncResource() { } /** - *

Constructs new SyncResource instance. This implementation does nothing.

+ *

+ * Constructs new SyncResource instance. This implementation does + * nothing. + *

*/ @Inject public SyncResource(UnsecureDAO unsecureDAO, - EventService eventService, - Injector injector, - CustomerDAO customerDAO, - DeviceDAO deviceDAO, - @Named("base.url") String baseUrl, - @Named("secure.enrollment") boolean secureEnrollment, - @Named("hash.secret") String hashSecret, - @Named("rebranding.mobile.name") String mobileAppName, - @Named("rebranding.vendor.name") String vendor, - @Named("proxy.addresses") String proxyIps, - @Named("proxy.ip.header") String ipHeader) { + EventService eventService, + Injector injector, + CustomerDAO customerDAO, + DeviceDAO deviceDAO, + @Named("base.url") String baseUrl, + @Named("secure.enrollment") boolean secureEnrollment, + @Named("hash.secret") String hashSecret, + @Named("rebranding.mobile.name") String mobileAppName, + @Named("rebranding.vendor.name") String vendor, + @Named("proxy.addresses") String proxyIps, + @Named("proxy.ip.header") String ipHeader) { this.unsecureDAO = unsecureDAO; this.eventService = eventService; this.customerDAO = customerDAO; @@ -160,25 +173,20 @@ public SyncResource(UnsecureDAO unsecureDAO, } // ================================================================================================================= - @ApiOperation( - value = "Get device settings", - notes = "Gets the device info and settings from the MDM server.", - response = SyncResponse.class - ) + @ApiOperation(value = "Get device settings", notes = "Gets the device info and settings from the MDM server.", response = SyncResponse.class) @POST @Path("/configuration/{deviceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response getDeviceSettingExtended(DeviceCreateOptions createOptions, - @PathParam("deviceId") - @ApiParam("An identifier of device within MDM server") - String number, - @Context HttpServletRequest request, - @Context HttpServletResponse response) { + @PathParam("deviceId") @ApiParam("An identifier of device within MDM server") String number, + @Context HttpServletRequest request, + @Context HttpServletResponse response) { logger.debug("/public/sync/configuration/{}", number); if (secureEnrollment) { - if (!CryptoUtil.checkRequestSignature(request.getHeader(HEADER_ENROLLMENT_SIGNATURE), hashSecret + number)) { + if (!CryptoUtil.checkRequestSignature(request.getHeader(HEADER_ENROLLMENT_SIGNATURE), + hashSecret + number)) { logger.warn("Failed to setup device {}: signature mismatch", number); return Response.PERMISSION_DENIED(); } @@ -219,23 +227,19 @@ public Response getDeviceSettingExtended(DeviceCreateOptions createOptions, } // ================================================================================================================= - @ApiOperation( - value = "Get device settings", - notes = "Gets the device info and settings from the MDM server.", - response = SyncResponse.class - ) + @ApiOperation(value = "Get device settings", notes = "Gets the device info and settings from the MDM server.", response = SyncResponse.class) @GET @Path("/configuration/{deviceId}") @Produces(MediaType.APPLICATION_JSON) - public Response getDeviceSetting(@PathParam("deviceId") - @ApiParam("An identifier of device within MDM server") - String number, - @Context HttpServletRequest request, - @Context HttpServletResponse response) { + public Response getDeviceSetting( + @PathParam("deviceId") @ApiParam("An identifier of device within MDM server") String number, + @Context HttpServletRequest request, + @Context HttpServletResponse response) { logger.debug("/public/sync/configuration/{}", number); if (secureEnrollment) { - if (!CryptoUtil.checkRequestSignature(request.getHeader(HEADER_ENROLLMENT_SIGNATURE), hashSecret + number)) { + if (!CryptoUtil.checkRequestSignature(request.getHeader(HEADER_ENROLLMENT_SIGNATURE), + hashSecret + number)) { logger.warn("Failed to setup device {}: signature mismatch", number); return Response.PERMISSION_DENIED(); } @@ -279,11 +283,12 @@ public Response getDeviceSetting(@PathParam("deviceId") } private Response getDeviceSettingInternal(Device dbDevice, boolean migration, boolean foundByImeiOrSerial, - HttpServletRequest request, - HttpServletResponse response) throws UnsupportedEncodingException { + HttpServletRequest request, + HttpServletResponse response) throws UnsupportedEncodingException { if (!migration && dbDevice.getOldNumber() != null) { - // If a device requested the configuration by new device ID, the migration is completed + // If a device requested the configuration by new device ID, the migration is + // completed unsecureDAO.completeDeviceMigration(dbDevice.getId()); dbDevice.setOldNumber(null); } @@ -304,10 +309,9 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo Settings settings = this.unsecureDAO.getSettings(dbDevice.getCustomerId()); final List applications = this.unsecureDAO.getPlainConfigurationApplications( - dbDevice.getCustomerId(), dbDevice.getConfigurationId() - ); + dbDevice.getCustomerId(), dbDevice.getConfigurationId()); - for (Application app: applications) { + for (Application app : applications) { final String icon = app.getIcon(); if (icon != null) { if (!icon.trim().isEmpty()) { @@ -326,7 +330,8 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo } } - Configuration configuration = this.unsecureDAO.getConfigurationByIdWithAppSettings(dbDevice.getConfigurationId()); + Configuration configuration = this.unsecureDAO + .getConfigurationByIdWithAppSettings(dbDevice.getConfigurationId()); SyncResponse data; if (configuration.isUseDefaultDesignSettings()) { @@ -352,7 +357,8 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo // Set only if autoBrightness == false data.setBrightness(configuration.getBrightness()); } - data.setManageTimeout(configuration.getManageTimeout() == null || !configuration.getManageTimeout() ? null : true); + data.setManageTimeout( + configuration.getManageTimeout() == null || !configuration.getManageTimeout() ? null : true); if (data.getManageTimeout() != null && data.getManageTimeout()) { data.setTimeout(configuration.getTimeout()); } @@ -386,22 +392,40 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo data.setKioskMode(configuration.isKioskMode()); if (data.isKioskMode()) { + data.setLockStatusBar(true); // Esta línea bloquea la barra de estado + + // Bloquear capturas de pantalla + data.setDisableScreenshots(true); // Bloquea las capturas de pantalla + + // Bloquear el volumen y ajustar el brillo + data.setLockVolume(true); // Bloquea el control del volumen + data.setAutoBrightness(false); // Desactiva el ajuste automático del brillo + data.setBrightness(50); // Fija el nivel de brillo al 50% + Integer contentAppId = configuration.getContentAppId(); if (contentAppId != null) { ApplicationVersion applicationVersion = this.unsecureDAO.findApplicationVersionById(contentAppId); if (applicationVersion != null) { - Application application = this.unsecureDAO.findApplicationById(applicationVersion.getApplicationId()); + Application application = this.unsecureDAO + .findApplicationById(applicationVersion.getApplicationId()); data.setMainApp(application.getPkg()); } } } + + data.setWifi(false); // Bloquea el acceso a la configuración de Wi-Fi + data.setBluetooth(false); // Bloquea el acceso a la configuración de Bluetooth data.setKioskHome(configuration.getKioskHome() != null && configuration.getKioskHome() ? true : null); data.setKioskRecents(configuration.getKioskRecents() != null && configuration.getKioskRecents() ? true : null); - data.setKioskNotifications(configuration.getKioskNotifications() != null && configuration.getKioskNotifications() ? true : null); - data.setKioskSystemInfo(configuration.getKioskSystemInfo() != null && configuration.getKioskSystemInfo() ? true : null); - data.setKioskKeyguard(configuration.getKioskKeyguard() != null && configuration.getKioskKeyguard() ? true : null); - data.setKioskLockButtons(configuration.getKioskLockButtons() != null && configuration.getKioskLockButtons() ? true : null); + data.setKioskNotifications( + configuration.getKioskNotifications() != null && configuration.getKioskNotifications() ? true : null); + data.setKioskSystemInfo( + configuration.getKioskSystemInfo() != null && configuration.getKioskSystemInfo() ? true : null); + data.setKioskKeyguard( + configuration.getKioskKeyguard() != null && configuration.getKioskKeyguard() ? true : null); + data.setKioskLockButtons( + configuration.getKioskLockButtons() != null && configuration.getKioskLockButtons() ? true : null); data.setRestrictions(configuration.getRestrictions()); if (settings != null) { @@ -425,8 +449,8 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo // Evaluate the application settings final List deviceAppSettings = this.unsecureDAO.getDeviceAppSettings(dbDevice.getId()); final List configApplicationSettings = configuration.getApplicationSettings(); - final List applicationSettings - = combineDeviceLogRules(configApplicationSettings, deviceAppSettings); + final List applicationSettings = combineDeviceLogRules(configApplicationSettings, + deviceAppSettings); final Device dbDevice1 = dbDevice; data.setApplicationSettings(applicationSettings.stream().map(s -> { @@ -447,11 +471,11 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo if (file.getExternalUrl() != null) { file.setUrl(file.getExternalUrl()); } else if (file.getFilePath() != null) { - final String url = FileUtil.createFileUrl(this.baseUrl, customer.getFilesDir(), file.getFilePath()); + final String url = FileUtil.createFileUrl(this.baseUrl, customer.getFilesDir(), + file.getFilePath()); file.setUrl(url); } - } - ); + }); data.setFiles(configurationFiles.stream().map(SyncConfigurationFile::new).collect(Collectors.toList())); @@ -483,28 +507,24 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo response.setHeader(HEADER_IP_ADDRESS, remoteAddrResolver.getRemoteAddr(request)); // Always add signature to enable "soft" security implementation -// if (secureEnrollment) { - // Add a signature to avoid MITM attack - response.setHeader(HEADER_RESPONSE_SIGNATURE, CryptoUtil.getDataSignature(hashSecret, syncResponse)); -// } + // if (secureEnrollment) { + // Add a signature to avoid MITM attack + response.setHeader(HEADER_RESPONSE_SIGNATURE, CryptoUtil.getDataSignature(hashSecret, syncResponse)); + // } return Response.OK(syncResponse); } // ================================================================================================================= - @ApiOperation( - value = "Update device info", - notes = "Updates the device info on the MDM server.", - response = Response.class - ) + @ApiOperation(value = "Update device info", notes = "Updates the device info on the MDM server.", response = Response.class) @POST @Path("/info") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response updateDeviceInfo(DeviceInfo deviceInfo, - @Context HttpServletRequest request, - @Context HttpServletResponse response) { + @Context HttpServletRequest request, + @Context HttpServletResponse response) { logger.debug("/public/sync/info --> {}", deviceInfo); try { @@ -565,7 +585,8 @@ public Response updateDeviceInfo(DeviceInfo deviceInfo, } if (deviceInfo.getBatteryLevel() != null) { - this.eventService.fireEvent(new DeviceBatteryLevelUpdatedEvent(dbDevice.getId(), deviceInfo.getBatteryLevel())); + this.eventService.fireEvent( + new DeviceBatteryLevelUpdatedEvent(dbDevice.getId(), deviceInfo.getBatteryLevel())); } final DeviceLocation location = deviceInfo.getLocation(); @@ -573,8 +594,7 @@ public Response updateDeviceInfo(DeviceInfo deviceInfo, List locations = new LinkedList<>(); locations.add(deviceInfo.getLocation()); this.eventService.fireEvent( - new DeviceLocationUpdatedEvent(dbDevice.getId(), locations, false) - ); + new DeviceLocationUpdatedEvent(dbDevice.getId(), locations, false)); } this.eventService.fireEvent(new DeviceInfoUpdatedEvent(dbDevice.getId())); @@ -592,19 +612,14 @@ public Response updateDeviceInfo(DeviceInfo deviceInfo, } // ================================================================================================================= - @ApiOperation( - value = "Save application settings", - notes = "Saves the application settings for the device on the MDM server.", - response = Response.class - ) + @ApiOperation(value = "Save application settings", notes = "Saves the application settings for the device on the MDM server.", response = Response.class) @POST @Path("/applicationSettings/{deviceId}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Response saveApplicationSettings(@PathParam("deviceId") - @ApiParam("An identifier of device within MDM server") - String deviceNumber, - List applicationSettings) { + public Response saveApplicationSettings( + @PathParam("deviceId") @ApiParam("An identifier of device within MDM server") String deviceNumber, + List applicationSettings) { logger.debug("/public/sync/applicationSettings/{} --> {}", deviceNumber, applicationSettings); try { @@ -614,7 +629,8 @@ public Response saveApplicationSettings(@PathParam("deviceId") ApplicationSetting applicationSetting = new ApplicationSetting(); applicationSetting.setApplicationPkg(s.getPackageId()); applicationSetting.setName(s.getName()); - applicationSetting.setType(ApplicationSettingType.byId(s.getType()).orElse(ApplicationSettingType.STRING)); + applicationSetting + .setType(ApplicationSettingType.byId(s.getType()).orElse(ApplicationSettingType.STRING)); applicationSetting.setReadonly(s.isReadonly()); applicationSetting.setValue(s.getValue()); applicationSetting.setLastUpdate(s.getLastUpdate()); @@ -634,18 +650,25 @@ public Response saveApplicationSettings(@PathParam("deviceId") } /** - *

A function producing the key for referencing the specified application setting.

+ *

+ * A function producing the key for referencing the specified application + * setting. + *

*/ - private static final Function appSettingMapKeyGenerator = (s) -> s.getApplicationId() + "," + s.getName(); + private static final Function appSettingMapKeyGenerator = (s) -> s.getApplicationId() + + "," + s.getName(); /** - *

Combines the specified list of application settings into a single list.

+ *

+ * Combines the specified list of application settings into a single list. + *

* * @param lessPreferred a list of less preferred settings. * @param morePreferred a list of more preferred settings. * @return a resulting list of application settings. */ - private static List combineDeviceLogRules(List lessPreferred, List morePreferred) { + private static List combineDeviceLogRules(List lessPreferred, + List morePreferred) { lessPreferred = lessPreferred.stream() .filter(s -> s.getValue() != null && !s.getValue().trim().isEmpty()) @@ -654,8 +677,7 @@ private static List combineDeviceLogRules(List s.getValue() != null && !s.getValue().trim().isEmpty()) .collect(Collectors.toList()); - final Map moreMapping - = morePreferred.stream() + final Map moreMapping = morePreferred.stream() .collect(Collectors.toMap(appSettingMapKeyGenerator, r -> r)); List result = new ArrayList<>(); From 7c93698720fc9f5eca15dde7791699261223d55b Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:13:35 -0500 Subject: [PATCH 6/7] =?UTF-8?q?Verificaci=C3=B3n=20QR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/hmdm/rest/resource/QRCodeResource.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/hmdm/rest/resource/QRCodeResource.java b/server/src/main/java/com/hmdm/rest/resource/QRCodeResource.java index 2324f173..3d690aa5 100644 --- a/server/src/main/java/com/hmdm/rest/resource/QRCodeResource.java +++ b/server/src/main/java/com/hmdm/rest/resource/QRCodeResource.java @@ -168,14 +168,18 @@ public javax.ws.rs.core.Response generateQRCode(@PathParam("id") @ApiParam("Conf @QueryParam("useId") @ApiParam("Which parameter to use as a device ID") String useId, @QueryParam("group") @ApiParam("Groups to assign when creating a device") List groups, @Context HttpServletRequest req) { - logger.info("Generating QR-code image for configuration key: {}", id); + //logger.info("Generating QR-code image for configuration key: {}", id); + logger.info("Iniciando la generación del código QR para la configuración: {}", id); try { Configuration configuration = this.unsecureDAO.getConfigurationByQRCodeKey(id); if (configuration != null) { Integer mainAppId = configuration.getMainAppId(); + logger.info("Configuración encontrada para la clave QR: {}", id); if (mainAppId != null) { ApplicationVersion appVersion = this.unsecureDAO.findApplicationVersionById(mainAppId); + logger.info("Main App encontrada para la clave QR: {}", id); if (appVersion != null && appVersion.getUrl() != null && !appVersion.getUrl().trim().isEmpty()) { + logger.info("Versión de la app encontrada para la clave QR: {}", id); final String apkUrl = appVersion.getUrl().replace(" ", "%20"); final String sha256; if (appVersion.getApkHash() == null) { @@ -231,7 +235,7 @@ public javax.ws.rs.core.Response generateQRCode(@PathParam("id") @ApiParam("Conf "}\n"; logger.info("The base for QR code generation:\n{}", s); - + return javax.ws.rs.core.Response.ok( (StreamingOutput) output -> { int imageSize = 250; if (size != null) { From ce14d20fd1c69e01f6cb157daa6d683fa89c883c Mon Sep 17 00:00:00 2001 From: CarlosChasi13 <120142318+CarlosChasi13@users.noreply.github.com> Date: Wed, 16 Oct 2024 07:59:24 -0500 Subject: [PATCH 7/7] Activar wifi --- server/src/main/java/com/hmdm/rest/resource/SyncResource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/hmdm/rest/resource/SyncResource.java b/server/src/main/java/com/hmdm/rest/resource/SyncResource.java index bc13f528..25e28feb 100644 --- a/server/src/main/java/com/hmdm/rest/resource/SyncResource.java +++ b/server/src/main/java/com/hmdm/rest/resource/SyncResource.java @@ -413,8 +413,8 @@ private Response getDeviceSettingInternal(Device dbDevice, boolean migration, bo } } - data.setWifi(false); // Bloquea el acceso a la configuración de Wi-Fi - data.setBluetooth(false); // Bloquea el acceso a la configuración de Bluetooth + //data.setWifi(false); // Bloquea el acceso a la configuración de Wi-Fi + //data.setBluetooth(false); // Bloquea el acceso a la configuración de Bluetooth data.setKioskHome(configuration.getKioskHome() != null && configuration.getKioskHome() ? true : null); data.setKioskRecents(configuration.getKioskRecents() != null && configuration.getKioskRecents() ? true : null);