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.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java
new file mode 100644
index 0000000..4ec4f48
--- /dev/null
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/BwlpAuthenticationProvider.java
@@ -0,0 +1,84 @@
+package de.bwlehrpool.bwlp_guac;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.apache.guacamole.GuacamoleException;
+import org.apache.guacamole.net.auth.AuthenticatedUser;
+import org.apache.guacamole.net.auth.AuthenticationProvider;
+import org.apache.guacamole.net.auth.Credentials;
+import org.apache.guacamole.net.auth.UserContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BwlpAuthenticationProvider implements AuthenticationProvider {
+
+ Logger LOGGER = LoggerFactory.getLogger(BwlpAuthenticationProvider.class);
+
+ public String getIdentifier() {
+ return "de.bwlehrpool.bwgpul";
+ }
+
+ public Object getResource() throws GuacamoleException {
+ return null;
+ }
+
+ 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;
+ }
+
+ public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser, Credentials credentials)
+ throws GuacamoleException {
+ return null;
+ }
+
+ public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException {
+ LOGGER.warn("Ignoring getUserContext for " + authenticatedUser.toString());
+ return null;
+ }
+
+ public UserContext updateUserContext(UserContext context, AuthenticatedUser authenticatedUser,
+ Credentials credentials) throws GuacamoleException {
+ LOGGER.warn("Ignoring updateUserContext called with " + context.toString());
+ return null;
+ }
+
+ 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;
+ LOGGER.warn("Doing the decoration");
+ user = new BwlpUserContext(authenticatedUser, context);
+ oldMappings.put(username, user);
+ return user;
+ }
+
+ private Map<String, BwlpUserContext> oldMappings = Collections
+ .synchronizedMap(new WeakHashMap<String, BwlpUserContext>());
+
+ public UserContext redecorate(UserContext decorated, UserContext context, AuthenticatedUser authenticatedUser,
+ Credentials credentials) throws GuacamoleException {
+ String username = authenticatedUser.getCredentials().getUsername();
+ LOGGER.warn("REdecorate called for " + username);
+ BwlpUserContext user = oldMappings.get(username);
+ if (user != null && user.hasValidConnection())
+ return user;
+ LOGGER.warn("Doing the REdecoration");
+ user = new BwlpUserContext(authenticatedUser, context);
+ oldMappings.put(username, user);
+ return user;
+ }
+
+ public void shutdown() {
+ }
+
+}