mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Find protocols in GUACAMOLE_HOME/protocols, and read those with priority.
This commit is contained in:
@@ -19,6 +19,9 @@ package net.sourceforge.guacamole.net.basic.crud.protocols;
|
||||
*/
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
@@ -37,6 +40,9 @@ import net.sourceforge.guacamole.net.basic.ProtocolParameter;
|
||||
import net.sourceforge.guacamole.net.basic.ProtocolParameterOption;
|
||||
import net.sourceforge.guacamole.net.basic.xml.DocumentHandler;
|
||||
import net.sourceforge.guacamole.net.basic.xml.protocol.ProtocolTagHandler;
|
||||
import net.sourceforge.guacamole.properties.GuacamoleHome;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
@@ -50,6 +56,11 @@ import org.xml.sax.helpers.XMLReaderFactory;
|
||||
*/
|
||||
public class List extends AuthenticatingHttpServlet {
|
||||
|
||||
/**
|
||||
* Logger for this class.
|
||||
*/
|
||||
private Logger logger = LoggerFactory.getLogger(List.class);
|
||||
|
||||
/**
|
||||
* Array of all known protocol names.
|
||||
*/
|
||||
@@ -191,9 +202,46 @@ public class List extends AuthenticatingHttpServlet {
|
||||
// Map of all available protocols
|
||||
Map<String, ProtocolInfo> protocols = new HashMap<String, ProtocolInfo>();
|
||||
|
||||
// Read protocols
|
||||
// Get protcols directory
|
||||
File protocol_directory = new File(GuacamoleHome.getDirectory(),
|
||||
"protocols");
|
||||
|
||||
/* STUB */
|
||||
// Read protocols from directory if it exists
|
||||
if (protocol_directory.isDirectory()) {
|
||||
|
||||
// Get all XML files
|
||||
File[] files = protocol_directory.listFiles(
|
||||
new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File file, String string) {
|
||||
return string.endsWith(".xml");
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// Load each protocol from each file
|
||||
for (File file : files) {
|
||||
|
||||
try {
|
||||
|
||||
// Parse protocol
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
ProtocolInfo protocol = getProtocol(stream);
|
||||
stream.close();
|
||||
|
||||
// Store protocol
|
||||
protocols.put(protocol.getName(), protocol);
|
||||
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.error("Unable to read protocol XML.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If known protocols are not already defined, read from classpath
|
||||
for (String protocol : KNOWN_PROTOCOLS) {
|
||||
|
Reference in New Issue
Block a user