package net.sourceforge.guacamole.net.basic;
import net.sourceforge.guacamole.GuacamoleException;
-import net.sourceforge.guacamole.net.Configuration;
+import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
public interface AuthenticationProvider {
- public Configuration getAuthorizedConfiguration(String username, String password) throws GuacamoleException;
+ public GuacamoleConfiguration getAuthorizedConfiguration(String username, String password) throws GuacamoleException;
}
import java.util.HashMap;
import java.util.Map;
import net.sourceforge.guacamole.GuacamoleException;
-import net.sourceforge.guacamole.net.Configuration;
-import net.sourceforge.guacamole.net.GuacamoleProperties;
+import net.sourceforge.guacamole.net.basic.properties.BasicGuacamoleProperties;
+import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
+import net.sourceforge.guacamole.properties.GuacamoleProperties;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
private File getUserMappingFile() throws GuacamoleException {
- // Get user mapping filename
- String filename = GuacamoleProperties.getProperty("basic-user-mapping");
- if (filename == null)
- return null;
-
- return new File(filename);
+ // Get user mapping file
+ return GuacamoleProperties.getProperty(BasicGuacamoleProperties.BASIC_USER_MAPPING);
}
}
@Override
- public Configuration getAuthorizedConfiguration(String username, String password) throws GuacamoleException {
+ public GuacamoleConfiguration getAuthorizedConfiguration(String username, String password) throws GuacamoleException {
// Check mapping file mod time
File userMappingFile = getUserMappingFile();
private String auth_password;
private Encoding auth_encoding;
- private Configuration config;
+ private GuacamoleConfiguration config;
public AuthInfo(String auth_username, String auth_password, Encoding auth_encoding) {
this.auth_username = auth_username;
this.auth_password = auth_password;
this.auth_encoding = auth_encoding;
- config = new Configuration();
+ config = new GuacamoleConfiguration();
}
private static final char HEX_CHARS[] = {
}
- public Configuration getConfiguration() {
+ public GuacamoleConfiguration getConfiguration() {
return config;
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-import java.lang.reflect.InvocationTargetException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import net.sourceforge.guacamole.GuacamoleException;
-import net.sourceforge.guacamole.GuacamoleTCPClient;
-import net.sourceforge.guacamole.net.Configuration;
-import net.sourceforge.guacamole.net.GuacamoleProperties;
-import net.sourceforge.guacamole.net.GuacamoleSession;
-import net.sourceforge.guacamole.net.tunnel.GuacamoleTunnel;
-import net.sourceforge.guacamole.net.tunnel.GuacamoleTunnelServlet;
+import net.sourceforge.guacamole.net.InetGuacamoleSocket;
+import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
+import net.sourceforge.guacamole.properties.GuacamoleProperties;
+import net.sourceforge.guacamole.net.GuacamoleSocket;
+import net.sourceforge.guacamole.servlet.GuacamoleSession;
+import net.sourceforge.guacamole.net.GuacamoleTunnel;
+import net.sourceforge.guacamole.net.basic.properties.BasicGuacamoleProperties;
+import net.sourceforge.guacamole.protocol.ConfiguredGuacamoleSocket;
+import net.sourceforge.guacamole.servlet.GuacamoleTunnelServlet;
public class BasicGuacamoleTunnelServlet extends GuacamoleTunnelServlet {
// Get auth provider instance
try {
- String authProviderClassName = GuacamoleProperties.getProperty("auth-provider");
- Object obj = Class.forName(authProviderClassName).getConstructor().newInstance();
- if (!(obj instanceof AuthenticationProvider))
- throw new ServletException("Specified authentication provider class is not a AuthenticationProvider.");
-
- authProvider = (AuthenticationProvider) obj;
+ authProvider = GuacamoleProperties.getProperty(BasicGuacamoleProperties.AUTH_PROVIDER);
}
catch (GuacamoleException e) {
throw new ServletException(e);
}
- catch (ClassNotFoundException e) {
- throw new ServletException("Authentication provider class not found", e);
- }
- catch (NoSuchMethodException e) {
- throw new ServletException("Default constructor for authentication provider not present", e);
- }
- catch (SecurityException e) {
- throw new ServletException("Creation of authentication provider disallowed; check your security settings", e);
- }
- catch (InstantiationException e) {
- throw new ServletException("Unable to instantiate authentication provider", e);
- }
- catch (IllegalAccessException e) {
- throw new ServletException("Unable to access default constructor of authentication provider", e);
- }
- catch (InvocationTargetException e) {
- throw new ServletException("Internal error in constructor of authentication provider", e.getTargetException());
- }
}
String password = request.getParameter("password");
// Get authorized config
- Configuration config = authProvider.getAuthorizedConfiguration(username, password);
+ GuacamoleConfiguration config = authProvider.getAuthorizedConfiguration(username, password);
if (config == null)
throw new GuacamoleException("Invalid login");
- // Configure and connect client
- String hostname = GuacamoleProperties.getProperty("guacd-hostname");
- int port = GuacamoleProperties.getIntProperty("guacd-port", null);
+ // Configure and connect socket
+ String hostname = GuacamoleProperties.getProperty(GuacamoleProperties.GUACD_HOSTNAME);
+ int port = GuacamoleProperties.getProperty(GuacamoleProperties.GUACD_PORT);
- GuacamoleTCPClient client = new GuacamoleTCPClient(hostname, port);
- client.connect(config);
+ GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
+ new InetGuacamoleSocket(hostname, port),
+ config
+ );
- // Associate client with tunnel
- GuacamoleTunnel tunnel = new GuacamoleTunnel(client);
+ // Associate socket with tunnel
+ GuacamoleTunnel tunnel = new GuacamoleTunnel(socket);
// Attach tunnel to session
GuacamoleSession session = new GuacamoleSession(httpSession);
--- /dev/null
+package net.sourceforge.guacamole.net.basic.properties;
+
+/*
+ * Guacamole - Clientless Remote Desktop
+ * Copyright (C) 2010 Michael Jumper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import net.sourceforge.guacamole.GuacamoleException;
+import net.sourceforge.guacamole.net.basic.AuthenticationProvider;
+import net.sourceforge.guacamole.properties.GuacamoleProperty;
+
+public abstract class AuthenticationProviderProperty implements GuacamoleProperty<AuthenticationProvider> {
+
+ @Override
+ public AuthenticationProvider parseValue(String authProviderClassName) throws GuacamoleException {
+
+ // Get auth provider instance
+ try {
+
+ Object obj = Class.forName(authProviderClassName).getConstructor().newInstance();
+ if (!(obj instanceof AuthenticationProvider))
+ throw new GuacamoleException("Specified authentication provider class is not a AuthenticationProvider.");
+
+ return (AuthenticationProvider) obj;
+
+ }
+ catch (ClassNotFoundException e) {
+ throw new GuacamoleException("Authentication provider class not found", e);
+ }
+ catch (NoSuchMethodException e) {
+ throw new GuacamoleException("Default constructor for authentication provider not present", e);
+ }
+ catch (SecurityException e) {
+ throw new GuacamoleException("Creation of authentication provider disallowed; check your security settings", e);
+ }
+ catch (InstantiationException e) {
+ throw new GuacamoleException("Unable to instantiate authentication provider", e);
+ }
+ catch (IllegalAccessException e) {
+ throw new GuacamoleException("Unable to access default constructor of authentication provider", e);
+ }
+ catch (InvocationTargetException e) {
+ throw new GuacamoleException("Internal error in constructor of authentication provider", e.getTargetException());
+ }
+
+ }
+
+}
+
--- /dev/null
+
+package net.sourceforge.guacamole.net.basic.properties;
+
+import net.sourceforge.guacamole.properties.FileGuacamoleProperty;
+
+/*
+ * Guacamole - Clientless Remote Desktop
+ * Copyright (C) 2010 Michael Jumper
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+public class BasicGuacamoleProperties {
+
+ private BasicGuacamoleProperties() {}
+
+ public static final FileGuacamoleProperty BASIC_USER_MAPPING = new FileGuacamoleProperty() {
+
+ @Override
+ public String getName() { return "basic-user-mapping"; }
+
+ };
+
+ public static final AuthenticationProviderProperty AUTH_PROVIDER = new AuthenticationProviderProperty() {
+
+ @Override
+ public String getName() { return "auth-provider"; }
+
+ };
+
+}