2 package net.sourceforge.guacamole.net.authentication.basic;
4 import javax.servlet.http.HttpSession;
5 import net.sourceforge.guacamole.GuacamoleException;
6 import net.sourceforge.guacamole.net.GuacamoleSession;
7 import net.sourceforge.guacamole.net.authentication.GuacamoleSessionProvider;
10 * Guacamole - Clientless Remote Desktop
11 * Copyright (C) 2010 Michael Jumper
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU Affero General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 public class BasicGuacamoleSessionProvider implements GuacamoleSessionProvider {
29 public GuacamoleSession createSession(HttpSession session) throws GuacamoleException {
31 // Retrieve authorized config data from session
32 BasicLogin.AuthorizedConfiguration config = (BasicLogin.AuthorizedConfiguration)
33 session.getAttribute("BASIC-LOGIN-AUTH");
35 // If no data, not authorized
37 throw new GuacamoleException("Unauthorized");
39 // Configure session from authorized config info
40 GuacamoleSession guacSession = new GuacamoleSession(session);
41 guacSession.setConnection(config.getProtocol(), config.getHostname(), config.getPort());
42 if (config.getPassword() != null)
43 guacSession.setPassword(config.getPassword());
45 // Return authorized session