From 62b83a7a18e1878cf8192d80f02c10dffc0478d7 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Sat, 9 May 2020 01:41:41 +0200 Subject: Fix connecting to a new client after exiting a client. Add logo, favicon and logout button. --- .gitignore | 1 + .../de/bwlehrpool/bwlp_guac/AvailableClient.java | 4 +- .../bwlp_guac/BwlpAuthenticationProvider.java | 30 +--------- .../de/bwlehrpool/bwlp_guac/BwlpUserContext.java | 2 +- src/main/resources/bwlpModule.js | 2 +- .../controllers/locationFieldController.js | 15 ++++- src/main/resources/disclaimer.html | 1 - src/main/resources/guac-manifest.json | 3 + src/main/resources/images/Logo_bwLehrpool.svg | 66 +++++++++++++++++++++ .../resources/images/Logo_bwLehrpool_symbol.png | Bin 0 -> 47241 bytes src/main/resources/styles/locationField.css | 5 ++ src/main/resources/styles/login.css | 11 ++++ src/main/resources/templates/locationField.html | 1 + src/main/resources/translations/en.json | 3 + 14 files changed, 108 insertions(+), 36 deletions(-) create mode 100644 src/main/resources/images/Logo_bwLehrpool.svg create mode 100644 src/main/resources/images/Logo_bwLehrpool_symbol.png create mode 100644 src/main/resources/styles/login.css diff --git a/.gitignore b/.gitignore index 1898b99..d2b8409 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /.project /.settings /target +/src/main/resources/generated \ No newline at end of file diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java index e9144f8..6126e77 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java @@ -143,7 +143,7 @@ public class AvailableClient implements Cloneable { if (now < this.lastConnectionCheck) { this.lastConnectionCheck = 0; } - if (now - this.lastConnectionCheck < 5000) + if (now - this.lastConnectionCheck < 1000) return this.connectionOk; for (;;) { try (VncConnection vnc = new VncConnection(this.clientip, 5900)) { @@ -172,7 +172,7 @@ public class AvailableClient implements Cloneable { return this.connectionOk = false; } } - + @Override public AvailableClient clone() { AvailableClient c = new AvailableClient(this.clientip); diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java index b902621..0fc7bc8 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java @@ -1,21 +1,15 @@ package de.bwlehrpool.bwlp_guac; -import java.io.IOException; import java.util.*; import org.apache.guacamole.GuacamoleException; -import org.apache.guacamole.form.TextField; import org.apache.guacamole.net.auth.*; import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException; -import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException; -import org.codehaus.jackson.JsonGenerationException; import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.JsonMappingException; import org.codehaus.jackson.map.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; -import javax.xml.soap.Text; import org.apache.guacamole.form.Field; import org.apache.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException; @@ -34,11 +28,6 @@ public class BwlpAuthenticationProvider implements AuthenticationProvider { } public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException { - // XXX We can somehow request additional fields to be shown during login by throwing an exception - // that declares additional ones; but when I tried, it removed the existing username and password - // field, so do we need to state them too? Seems wrong since we don't need them, we'd just want - // an additional field to pick the room/location we want to end up in and let the actual - // authentication plugin define the username/password fields. return null; } @@ -60,21 +49,7 @@ public class BwlpAuthenticationProvider implements AuthenticationProvider { public UserContext decorate(UserContext context, AuthenticatedUser authenticatedUser, Credentials credentials) throws GuacamoleException { - String username = authenticatedUser.getCredentials().getUsername(); - - LOGGER.warn("decorate called for " + username); - BwlpUserContext user = oldMappings.get(username); - - if (user != null) - return user; - - int locationid = requestLocation(credentials); - - LOGGER.warn("Doing the decoration"); - user = new BwlpUserContext(authenticatedUser, context, locationid); - oldMappings.put(username, user); - - return user; + return context; } private Map oldMappings = Collections @@ -130,8 +105,7 @@ public class BwlpAuthenticationProvider implements AuthenticationProvider { correctPassword = ConnectionManager.getLocationPool().get(selectedId).password; } } catch (Exception e) { - LOGGER.info("Error reading location"); - LOGGER.info(e.toString()); + LOGGER.info("Error reading location", e); tryAgain = true; } diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java index 05fa78f..ca020f6 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpUserContext.java @@ -9,7 +9,6 @@ import org.apache.guacamole.net.auth.Directory; import org.apache.guacamole.net.auth.User; import org.apache.guacamole.net.auth.UserContext; import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException; -import org.apache.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException; import org.apache.guacamole.net.auth.permission.ObjectPermissionSet; import org.apache.guacamole.net.auth.simple.SimpleConnection; import org.apache.guacamole.net.auth.simple.SimpleDirectory; @@ -105,6 +104,7 @@ public class BwlpUserContext extends AbstractUserContext { } catch (Exception e) { LOGGER.warn("hasValidConnection", e); } + if (!ok) connectionDirectory = new SimpleDirectory(); return ok; } diff --git a/src/main/resources/bwlpModule.js b/src/main/resources/bwlpModule.js index c74580a..67fb487 100644 --- a/src/main/resources/bwlpModule.js +++ b/src/main/resources/bwlpModule.js @@ -2,4 +2,4 @@ angular.module('location', [ 'form' ]); -angular.module('index').requires.push('location'); \ No newline at end of file +angular.module('index').requires.push('location'); diff --git a/src/main/resources/controllers/locationFieldController.js b/src/main/resources/controllers/locationFieldController.js index 8117ed7..af2b6fe 100644 --- a/src/main/resources/controllers/locationFieldController.js +++ b/src/main/resources/controllers/locationFieldController.js @@ -1,9 +1,12 @@ -angular.module('location').controller('locationFieldController', ['$scope', '$window', - function locationFieldController($scope, $window) { +angular.module('location').controller('locationFieldController', ['$scope', function locationFieldController($scope) { - $scope.data = { id: 0, password: '' } + $scope.data = { id: 0, password: '' }; $scope.$watch('data', function(newValue) { + if (window.location.hash !== '#/') { + window.location.hash = '#/'; + window.location.reload(); + } $scope.model = JSON.stringify(newValue); }, true); @@ -20,4 +23,10 @@ angular.module('location').controller('locationFieldController', ['$scope', '$wi angular.element($event.currentTarget).addClass('selected-location'); }; + $scope.logout = function logout() { + window.localStorage.removeItem('GUAC_AUTH'); + window.location.hash = '#/'; + window.location.reload(); + } + }]); \ No newline at end of file diff --git a/src/main/resources/disclaimer.html b/src/main/resources/disclaimer.html index be4cca3..b6c6190 100644 --- a/src/main/resources/disclaimer.html +++ b/src/main/resources/disclaimer.html @@ -3,4 +3,3 @@

bwLehrpool

- diff --git a/src/main/resources/guac-manifest.json b/src/main/resources/guac-manifest.json index e507183..def8a3f 100644 --- a/src/main/resources/guac-manifest.json +++ b/src/main/resources/guac-manifest.json @@ -2,6 +2,8 @@ "guacamoleVersion" : "*", "name" : "bwLehrpool virtual pool", "namespace" : "de.bwlehrpool", + "smallIcon" : "images/Logo_bwLehrpool_symbol.png", + "largeIcon" : "images/Logo_bwLehrpool_symbol.png", "authProviders": ["de.bwlehrpool.bwlp_guac.BwlpAuthenticationProvider"], "html" : [ "disclaimer.html" ], "translations" : [ @@ -14,6 +16,7 @@ "bwlp.min.css" ], "resources" : { + "images/Logo_bwLehrpool.svg" : "image/svg+xml", "templates/locationField.html" : "text/html" } } diff --git a/src/main/resources/images/Logo_bwLehrpool.svg b/src/main/resources/images/Logo_bwLehrpool.svg new file mode 100644 index 0000000..8b6a230 --- /dev/null +++ b/src/main/resources/images/Logo_bwLehrpool.svg @@ -0,0 +1,66 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/src/main/resources/images/Logo_bwLehrpool_symbol.png b/src/main/resources/images/Logo_bwLehrpool_symbol.png new file mode 100644 index 0000000..e26795f Binary files /dev/null and b/src/main/resources/images/Logo_bwLehrpool_symbol.png differ diff --git a/src/main/resources/styles/locationField.css b/src/main/resources/styles/locationField.css index cec1466..1764af9 100644 --- a/src/main/resources/styles/locationField.css +++ b/src/main/resources/styles/locationField.css @@ -44,4 +44,9 @@ margin: 0 !important; padding: 5px 8px !important; background-color: white !important; +} + +.logout-button { + float: left; + margin: 20px 0 0 0; } \ No newline at end of file diff --git a/src/main/resources/styles/login.css b/src/main/resources/styles/login.css new file mode 100644 index 0000000..ab3b04d --- /dev/null +++ b/src/main/resources/styles/login.css @@ -0,0 +1,11 @@ +.login-ui .login-dialog .logo { + width: 215px; + height: 50px; + background-image: url('app/ext/de.bwlehrpool/images/Logo_bwLehrpool.svg'); + background-size: cover; + background-position: center; +} + +.login-ui .login-dialog .app-name { + display: none; +} diff --git a/src/main/resources/templates/locationField.html b/src/main/resources/templates/locationField.html index f76259e..9feb83c 100644 --- a/src/main/resources/templates/locationField.html +++ b/src/main/resources/templates/locationField.html @@ -16,3 +16,4 @@ + diff --git a/src/main/resources/translations/en.json b/src/main/resources/translations/en.json index 9ad430b..85a8b6e 100644 --- a/src/main/resources/translations/en.json +++ b/src/main/resources/translations/en.json @@ -1,4 +1,7 @@ { + "APP" : { + "NAME" : "bwLehrpool" + }, "LOGIN" : { "FIELD_HEADER_LOCATION" : "" } -- cgit v1.2.3-55-g7522