summaryrefslogtreecommitdiffstats
path: root/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java
diff options
context:
space:
mode:
authorUdo Walter2020-10-27 18:56:19 +0100
committerUdo Walter2020-10-27 18:56:19 +0100
commit60c53021df660563d0be52b307f8dbbcbbbca22c (patch)
tree045b9c5063adf5d0275e9d47797c4987eef27c8d /src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java
parentFix logo in firefox (diff)
downloadbwlp-guacamole-ext-60c53021df660563d0be52b307f8dbbcbbbca22c.tar.gz
bwlp-guacamole-ext-60c53021df660563d0be52b307f8dbbcbbbca22c.tar.xz
bwlp-guacamole-ext-60c53021df660563d0be52b307f8dbbcbbbca22c.zip
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
Diffstat (limited to 'src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java')
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java44
1 files changed, 35 insertions, 9 deletions
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.<Field>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.<Field>singletonList(new GroupField())
));
}