1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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() {
}
}
|