From 60c53021df660563d0be52b307f8dbbcbbbca22c Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Tue, 27 Oct 2020 18:56:19 +0100 Subject: fix language tags for Guacamole 1.2.0, workaround for greyed out continue button, add build logging Build revision and timestamp are logged on start and sent as http request headers on connection to the sat server. (Bwlp-Plugin-Build-Revision and Bwlp-Plugin-Build-Timestamp) This build now requires guacamole >=1.2.0 --- .../bwlp_guac/BwlpAuthenticationProvider.java | 44 +++++++++++++++++----- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java') diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java index f73de84..3043339 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java @@ -1,23 +1,45 @@ package de.bwlehrpool.bwlp_guac; +import java.net.URL; +import java.net.URLClassLoader; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.*; - import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.net.auth.*; -import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException; +import org.apache.guacamole.language.TranslatableGuacamoleCredentialsException; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; - import org.apache.guacamole.form.Field; -import org.apache.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException; +import org.apache.guacamole.language.TranslatableGuacamoleInsufficientCredentialsException; import org.apache.guacamole.net.auth.credentials.CredentialsInfo; public class BwlpAuthenticationProvider implements AuthenticationProvider { - Logger LOGGER = LoggerFactory.getLogger(BwlpAuthenticationProvider.class); + static Logger LOGGER = LoggerFactory.getLogger(BwlpAuthenticationProvider.class); + + static Properties MANIFEST = new Properties(); + + static { + URLClassLoader cl = (URLClassLoader) BwlpAuthenticationProvider.class.getClassLoader(); + URL url = cl.findResource("META-INF/MANIFEST.MF"); + try { + MANIFEST.load(url.openStream()); + LOGGER.info("Plugin build revision: " + MANIFEST.getProperty("Build-Revision")); + + String timestamp = MANIFEST.getProperty("Build-Revision-Timestamp"); + DateFormat formatter = new SimpleDateFormat("yyyy.MM.dd HH:mm"); + long milliSeconds= Long.parseLong(timestamp); + Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis(milliSeconds); + LOGGER.info("Plugin build timestamp: " + formatter.format(calendar.getTime())); + } catch (Exception e) { + System.out.println("unable to read manifest " + e.getMessage()); + } + } public String getIdentifier() { return "de.bwlehrpool.bwgpul"; @@ -58,6 +80,8 @@ public class BwlpAuthenticationProvider implements AuthenticationProvider { public UserContext redecorate(UserContext decorated, UserContext context, AuthenticatedUser authenticatedUser, Credentials credentials) throws GuacamoleException { + LOGGER.info(MANIFEST.getProperty("Build-Revision")); + String username = Util.getUsername(authenticatedUser); if (username == null) { LOGGER.warn("redecorate: Ignoring user without name"); @@ -97,8 +121,9 @@ public class BwlpAuthenticationProvider implements AuthenticationProvider { String groupJson = request.getParameter("group"); if (groupJson == null) { - throw new GuacamoleInsufficientCredentialsException( - "GROUP_SELECTION.TITLE", new CredentialsInfo( + LOGGER.warn("test 1"); + throw new TranslatableGuacamoleInsufficientCredentialsException( + "GROUP_SELECTION.TITLE", "GROUP_SELECTION.TITLE", new CredentialsInfo( Collections.singletonList(new GroupField()) )); } @@ -130,8 +155,9 @@ public class BwlpAuthenticationProvider implements AuthenticationProvider { } if (tryAgain) { - throw new GuacamoleCredentialsException( - message, new CredentialsInfo( + LOGGER.warn("test 2"); + throw new TranslatableGuacamoleCredentialsException( + message, message, new CredentialsInfo( Collections.singletonList(new GroupField()) )); } -- cgit v1.2.3-55-g7522