summaryrefslogtreecommitdiffstats
path: root/src/main/java/de/bwlehrpool/bwlp_guac/Util.java
blob: 2b07640f59eca06d57d12700b16f34e4a80cef00 (plain) (blame)
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
package de.bwlehrpool.bwlp_guac;

import org.apache.guacamole.net.auth.AuthenticatedUser;
import org.apache.guacamole.net.event.TunnelCloseEvent;
import org.apache.guacamole.net.event.TunnelConnectEvent;

public class Util {

	public static String getUsername(TunnelConnectEvent event) {
		return getUsername(event.getAuthenticatedUser());
	}
	
	public static String getUsername(TunnelCloseEvent event) {
		return getUsername(event.getAuthenticatedUser());
	}
	
	public static String getUsername(AuthenticatedUser user) {
		if (user == null)
			return null;
		String username = null;
		if (user.getCredentials() != null) {
			username = user.getCredentials().getUsername();
		}
		if (username == null) {
			username = user.getIdentifier();
		}
		return username;
	}
	
}