import net.sourceforge.guacamole.GuacamoleException;
-public interface AuthenticationProvider {
+public interface AuthenticationProvider<CredentialType> {
- public UserConfiguration getUserConfiguration(String username, String password) throws GuacamoleException;
+ public UserConfiguration getUserConfiguration(CredentialType credentials) throws GuacamoleException;
}
--- /dev/null
+package net.sourceforge.guacamole.net.auth;
+
+public class UsernamePassword {
+
+ private String username;
+ private String password;
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+}
import java.util.Map;
import net.sourceforge.guacamole.GuacamoleException;
import net.sourceforge.guacamole.net.auth.UserConfiguration;
+import net.sourceforge.guacamole.net.auth.UsernamePassword;
import net.sourceforge.guacamole.net.basic.properties.BasicGuacamoleProperties;
import net.sourceforge.guacamole.properties.GuacamoleProperties;
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;
-public class BasicFileAuthenticationProvider implements AuthenticationProvider {
+public class BasicFileAuthenticationProvider implements AuthenticationProvider<UsernamePassword> {
private Logger logger = LoggerFactory.getLogger(BasicFileAuthenticationProvider.class);
}
@Override
- public UserConfiguration getUserConfiguration(String username, String password) throws GuacamoleException {
+ public UserConfiguration getUserConfiguration(UsernamePassword credentials) throws GuacamoleException {
// Check mapping file mod time
File userMappingFile = getUserMappingFile();
throw new GuacamoleException("User mapping could not be read.");
// Validate and return info for given user and pass
- AuthInfo info = mapping.get(username);
- if (info != null && info.validate(username, password))
+ AuthInfo info = mapping.get(credentials.getUsername());
+ if (info != null && info.validate(credentials.getUsername(), credentials.getPassword()))
return info.getUserConfiguration();
return null;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import net.sourceforge.guacamole.GuacamoleException;
+import net.sourceforge.guacamole.net.auth.UsernamePassword;
import net.sourceforge.guacamole.properties.GuacamoleProperties;
import net.sourceforge.guacamole.net.basic.properties.BasicGuacamoleProperties;
import org.slf4j.Logger;
String username = request.getParameter("username");
String password = request.getParameter("password");
+ UsernamePassword credentials = new UsernamePassword();
+ credentials.setUsername(username);
+ credentials.setPassword(password);
+
// Get authorized configs
UserConfiguration config;
try {
- config = authProvider.getUserConfiguration(username, password);
+ config = authProvider.getUserConfiguration(credentials);
}
catch (GuacamoleException e) {
logger.error("Error retrieving configuration for user {}.", username);
}
+ // If only one connection, redirect to that.
+ if (configs.length == 1) {
+ window.location.href = "client.xhtml?" + encodeURIComponent(configs[0].id);
+ return;
+ }
+
// Remove all rows from connections list
var tbody = document.getElementById("connections-tbody");
tbody.innerHTML = "";