mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-497: Remove usage of now-deprecated XMLReaderFactory.
This commit is contained in:
@@ -19,12 +19,12 @@
|
|||||||
|
|
||||||
package org.apache.guacamole.auth.file;
|
package org.apache.guacamole.auth.file;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.parsers.SAXParser;
|
||||||
|
import javax.xml.parsers.SAXParserFactory;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
import org.apache.guacamole.environment.LocalEnvironment;
|
import org.apache.guacamole.environment.LocalEnvironment;
|
||||||
@@ -35,10 +35,7 @@ import org.apache.guacamole.properties.FileGuacamoleProperty;
|
|||||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.InputSource;
|
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import org.xml.sax.XMLReader;
|
|
||||||
import org.xml.sax.helpers.XMLReaderFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticates users against a static list of username/password pairs.
|
* Authenticates users against a static list of username/password pairs.
|
||||||
@@ -151,6 +148,22 @@ public class FileAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
|
|
||||||
logger.debug("Reading user mapping file: \"{}\"", userMappingFile);
|
logger.debug("Reading user mapping file: \"{}\"", userMappingFile);
|
||||||
|
|
||||||
|
// Set up XML parser
|
||||||
|
SAXParser parser;
|
||||||
|
try {
|
||||||
|
parser = SAXParserFactory.newInstance().newSAXParser();
|
||||||
|
}
|
||||||
|
catch (ParserConfigurationException e) {
|
||||||
|
logger.error("Unable to create XML parser for reading \"{}\": {}", USER_MAPPING_FILENAME, e.getMessage());
|
||||||
|
logger.debug("An instance of SAXParser could not be created.", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (SAXException e) {
|
||||||
|
logger.error("Unable to create XML parser for reading \"{}\": {}", USER_MAPPING_FILENAME, e.getMessage());
|
||||||
|
logger.debug("An instance of SAXParser could not be created.", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Parse document
|
// Parse document
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -162,14 +175,8 @@ public class FileAuthenticationProvider extends SimpleAuthenticationProvider {
|
|||||||
DocumentHandler contentHandler = new DocumentHandler(
|
DocumentHandler contentHandler = new DocumentHandler(
|
||||||
"user-mapping", userMappingHandler);
|
"user-mapping", userMappingHandler);
|
||||||
|
|
||||||
// Set up XML parser
|
|
||||||
XMLReader parser = XMLReaderFactory.createXMLReader();
|
|
||||||
parser.setContentHandler(contentHandler);
|
|
||||||
|
|
||||||
// Read and parse file
|
// Read and parse file
|
||||||
InputStream input = new BufferedInputStream(new FileInputStream(userMappingFile));
|
parser.parse(userMappingFile, contentHandler);
|
||||||
parser.parse(new InputSource(input));
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
// Store mod time and user mapping
|
// Store mod time and user mapping
|
||||||
lastModified = userMappingFile.lastModified();
|
lastModified = userMappingFile.lastModified();
|
||||||
|
Reference in New Issue
Block a user