summaryrefslogtreecommitdiffstats
path: root/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java
diff options
context:
space:
mode:
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())
));
}