1 package net.sourceforge.guacamole.net.basic;
4 * Guacamole - Clientless Remote Desktop
5 * Copyright (C) 2010 Michael Jumper
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 import java.io.IOException;
22 import java.io.PrintWriter;
24 import java.util.Map.Entry;
25 import javax.servlet.http.HttpServlet;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28 import javax.servlet.http.HttpSession;
29 import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
32 * Simple HttpServlet which outputs XML containing a list of all authorized
33 * configurations for the current user.
35 * @author Michael Jumper
37 public class ConfigurationList extends HttpServlet {
40 protected void service(HttpServletRequest request, HttpServletResponse response)
43 HttpSession httpSession = request.getSession(true);
45 // Get user configuration
46 // Get authorized configs
47 Map<String, GuacamoleConfiguration> configs = (Map<String, GuacamoleConfiguration>)
48 httpSession.getAttribute("GUAC_CONFIGS");
50 // If no configs in session, not authorized
51 if (configs == null) {
52 response.sendError(HttpServletResponse.SC_FORBIDDEN);
57 response.setHeader("Cache-Control", "no-cache");
60 response.setHeader("Content-Type", "text/xml");
61 PrintWriter out = response.getWriter();
62 out.println("<configs>");
64 for (Entry<String, GuacamoleConfiguration> entry : configs.entrySet()) {
66 GuacamoleConfiguration config = entry.getValue();
69 out.print("<config id=\"");
70 out.print(entry.getKey());
71 out.print("\" protocol=\"");
72 out.print(config.getProtocol());
78 out.println("</configs>");