mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-30 00:23:21 +00:00 
			
		
		
		
	List all protocols defined in classpath, add RDP.
This commit is contained in:
		| @@ -21,6 +21,8 @@ package net.sourceforge.guacamole.net.basic.crud.protocols; | |||||||
| import java.io.BufferedInputStream; | import java.io.BufferedInputStream; | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| import java.io.InputStream; | import java.io.InputStream; | ||||||
|  | import java.util.HashMap; | ||||||
|  | import java.util.Map; | ||||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||||
| import javax.xml.stream.XMLOutputFactory; | import javax.xml.stream.XMLOutputFactory; | ||||||
| @@ -48,6 +50,12 @@ import org.xml.sax.helpers.XMLReaderFactory; | |||||||
|  */ |  */ | ||||||
| public class List extends AuthenticatingHttpServlet { | public class List extends AuthenticatingHttpServlet { | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Array of all known protocol names. | ||||||
|  |      */ | ||||||
|  |     private static final String[] KNOWN_PROTOCOLS = new String[]{ | ||||||
|  |         "vnc", "rdp", "ssh"}; | ||||||
|  |      | ||||||
|     /** |     /** | ||||||
|      * Parses the given XML file, returning the parsed ProtocolInfo. |      * Parses the given XML file, returning the parsed ProtocolInfo. | ||||||
|      *  |      *  | ||||||
| @@ -180,9 +188,33 @@ public class List extends AuthenticatingHttpServlet { | |||||||
|         // Do not cache |         // Do not cache | ||||||
|         response.setHeader("Cache-Control", "no-cache"); |         response.setHeader("Cache-Control", "no-cache"); | ||||||
|  |  | ||||||
|  |         // Map of all available protocols | ||||||
|  |         Map<String, ProtocolInfo> protocols = new HashMap<String, ProtocolInfo>(); | ||||||
|  |  | ||||||
|  |         // Read protocols | ||||||
|  |          | ||||||
|  |         /* STUB */ | ||||||
|  |          | ||||||
|  |         // If known protocols are not already defined, read from classpath | ||||||
|  |         for (String protocol : KNOWN_PROTOCOLS) { | ||||||
|  |  | ||||||
|  |             // If protocol not defined yet, attempt to load from classpath | ||||||
|  |             if (!protocols.containsKey(protocol)) { | ||||||
|  |  | ||||||
|  |                 InputStream stream = List.class.getResourceAsStream( | ||||||
|  |                         "/net/sourceforge/guacamole/net/protocols/" | ||||||
|  |                         + protocol + ".xml"); | ||||||
|  |  | ||||||
|  |                 // Parse XML if available | ||||||
|  |                 if (stream != null) | ||||||
|  |                     protocols.put(protocol, getProtocol(stream)); | ||||||
|  |  | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |         | ||||||
|         // Write actual XML |         // Write actual XML | ||||||
|         try { |         try { | ||||||
|  |  | ||||||
|             // Write XML content type |             // Write XML content type | ||||||
|             response.setHeader("Content-Type", "text/xml"); |             response.setHeader("Content-Type", "text/xml"); | ||||||
|  |  | ||||||
| @@ -193,14 +225,8 @@ public class List extends AuthenticatingHttpServlet { | |||||||
|             xml.writeStartDocument(); |             xml.writeStartDocument(); | ||||||
|             xml.writeStartElement("protocols"); |             xml.writeStartElement("protocols"); | ||||||
|  |  | ||||||
|             // Read from classpath |             // Write all protocols | ||||||
|             InputStream stream = List.class.getResourceAsStream( |             for (ProtocolInfo protocol : protocols.values()) | ||||||
|                     "/net/sourceforge/guacamole/net/protocols/vnc.xml"); |  | ||||||
|             if (stream == null) |  | ||||||
|                 throw new IOException("Could not read VNC XML."); |  | ||||||
|  |  | ||||||
|             // Parse and write protocol |  | ||||||
|             ProtocolInfo protocol = getProtocol(stream); |  | ||||||
|                 writeProtocol(xml, protocol); |                 writeProtocol(xml, protocol); | ||||||
|             |             | ||||||
|             // End document |             // End document | ||||||
|   | |||||||
| @@ -0,0 +1,24 @@ | |||||||
|  | <protocol name="rdp" title="RDP"> | ||||||
|  |  | ||||||
|  |     <param name="hostname"        type="text"     title="Hostname"/> | ||||||
|  |     <param name="port"            type="numeric"  title="Port"/> | ||||||
|  |  | ||||||
|  |     <param name="username"        type="text"     title="Username"/> | ||||||
|  |     <param name="password"        type="password" title="Password"/> | ||||||
|  |     <param name="domain"          type="text"     title="Domain"/> | ||||||
|  |     <param name="initial-program" type="text"     title="Initial program"/> | ||||||
|  |  | ||||||
|  |     <param name="width"           type="numeric"  title="Display width"/> | ||||||
|  |     <param name="height"          type="numeric"  title="Display height"/> | ||||||
|  |     <param name="color-depth" type="text" title="Color depth"> | ||||||
|  |         <option value="8">256 color</option> | ||||||
|  |         <option value="16">Low color (16-bit)</option> | ||||||
|  |         <option value="24">True color (24-bit)</option> | ||||||
|  |         <option value="32">True color (32-bit)</option> | ||||||
|  |     </param> | ||||||
|  |  | ||||||
|  |     <param name="console"       type="boolean" title="Administrator console"/> | ||||||
|  |     <param name="console-audio" type="boolean" title="Support audio in console"/> | ||||||
|  |     <param name="disable-audio" type="boolean" title="Disable audio"/> | ||||||
|  |  | ||||||
|  | </protocol> | ||||||
| @@ -2,7 +2,11 @@ | |||||||
|  |  | ||||||
|     <param name="hostname"    type="text"     title="Hostname"/> |     <param name="hostname"    type="text"     title="Hostname"/> | ||||||
|     <param name="port"        type="numeric"  title="Port"/> |     <param name="port"        type="numeric"  title="Port"/> | ||||||
|  |     <param name="password"    type="password" title="Password"/> | ||||||
|  |  | ||||||
|     <param name="read-only"     type="boolean" title="Read-only"/> |     <param name="read-only"     type="boolean" title="Read-only"/> | ||||||
|  |     <param name="swap-red-blue" type="boolean" title="Swap red/blue components"/> | ||||||
|  |  | ||||||
|     <param name="color-depth" type="text" title="Color depth"> |     <param name="color-depth" type="text" title="Color depth"> | ||||||
|         <option value="8">256 color</option> |         <option value="8">256 color</option> | ||||||
|         <option value="16">Low color (16-bit)</option> |         <option value="16">Low color (16-bit)</option> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user