2 package net.sourceforge.guacamole.net;
5 * Guacamole - Clientless Remote Desktop
6 * Copyright (C) 2010 Michael Jumper
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 import net.sourceforge.guacamole.net.authentication.GuacamoleSessionProvider;
23 import java.lang.reflect.InvocationTargetException;
24 import javax.servlet.http.HttpSession;
25 import net.sourceforge.guacamole.GuacamoleException;
27 public class GuacamoleConfiguration extends Configuration {
29 private String guacd_hostname;
30 private int guacd_port;
31 private GuacamoleSessionProvider sessionProvider;
33 public GuacamoleConfiguration() throws GuacamoleException {
35 guacd_hostname = readParameter("guacd-hostname");
36 guacd_port = readIntParameter("guacd-port", null);
38 // Get session provider instance
40 String sessionProviderClassName = readParameter("session-provider");
41 Object obj = Class.forName(sessionProviderClassName).getConstructor().newInstance();
42 if (!(obj instanceof GuacamoleSessionProvider))
43 throw new GuacamoleException("Specified session provider class is not a GuacamoleSessionProvider");
45 sessionProvider = (GuacamoleSessionProvider) obj;
47 catch (ClassNotFoundException e) {
48 throw new GuacamoleException("Session provider class not found", e);
50 catch (NoSuchMethodException e) {
51 throw new GuacamoleException("Default constructor for session provider not present", e);
53 catch (SecurityException e) {
54 throw new GuacamoleException("Creation of session provider disallowed; check your security settings", e);
56 catch (InstantiationException e) {
57 throw new GuacamoleException("Unable to instantiate session provider", e);
59 catch (IllegalAccessException e) {
60 throw new GuacamoleException("Unable to access default constructor of session provider", e);
62 catch (InvocationTargetException e) {
63 throw new GuacamoleException("Internal error in constructor of session provider", e.getTargetException());
68 public int getProxyPort() {
72 public String getProxyHostname() {
73 return guacd_hostname;
76 public GuacamoleSession createSession(HttpSession session) throws GuacamoleException {
77 return sessionProvider.createSession(session);