mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-497: Merge remove usage of function/classes deprecated within Java 9.
This commit is contained in:
@@ -76,7 +76,7 @@ public class NumericField extends Field {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Parse as integer
|
// Parse as integer
|
||||||
return new Integer(str);
|
return Integer.valueOf(str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,8 +35,7 @@ public abstract class IntegerGuacamoleProperty implements GuacamoleProperty<Inte
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Integer integer = new Integer(value);
|
return Integer.valueOf(value);
|
||||||
return integer;
|
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
throw new GuacamoleServerException("Property \"" + getName() + "\" must be an integer.", e);
|
throw new GuacamoleServerException("Property \"" + getName() + "\" must be an integer.", e);
|
||||||
|
@@ -35,8 +35,7 @@ public abstract class LongGuacamoleProperty implements GuacamoleProperty<Long> {
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Long longValue = new Long(value);
|
return Long.valueOf(value);
|
||||||
return longValue;
|
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
throw new GuacamoleServerException("Property \"" + getName() + "\" must be an long.", e);
|
throw new GuacamoleServerException("Property \"" + getName() + "\" must be an long.", e);
|
||||||
|
@@ -84,6 +84,10 @@ public class DocumentHandler extends DefaultHandler {
|
|||||||
public void startElement(String uri, String localName, String qName,
|
public void startElement(String uri, String localName, String qName,
|
||||||
Attributes attributes) throws SAXException {
|
Attributes attributes) throws SAXException {
|
||||||
|
|
||||||
|
// If the SAX implementation does not provide the local name, the
|
||||||
|
// qualified name should be used instead
|
||||||
|
String name = localName.isEmpty() ? qName : localName;
|
||||||
|
|
||||||
// Get current state
|
// Get current state
|
||||||
DocumentHandlerState current = getCurrentState();
|
DocumentHandlerState current = getCurrentState();
|
||||||
|
|
||||||
@@ -94,7 +98,7 @@ public class DocumentHandler extends DefaultHandler {
|
|||||||
if (current == null) {
|
if (current == null) {
|
||||||
|
|
||||||
// Validate element name
|
// Validate element name
|
||||||
if (!localName.equals(rootElementName))
|
if (!name.equals(rootElementName))
|
||||||
throw new SAXException("Root element must be '" + rootElementName + "'");
|
throw new SAXException("Root element must be '" + rootElementName + "'");
|
||||||
|
|
||||||
handler = root;
|
handler = root;
|
||||||
@@ -103,12 +107,12 @@ public class DocumentHandler extends DefaultHandler {
|
|||||||
// Otherwise, get handler from parent
|
// Otherwise, get handler from parent
|
||||||
else {
|
else {
|
||||||
TagHandler parent_handler = current.getTagHandler();
|
TagHandler parent_handler = current.getTagHandler();
|
||||||
handler = parent_handler.childElement(localName);
|
handler = parent_handler.childElement(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no handler returned, the element was not expected
|
// If no handler returned, the element was not expected
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
throw new SAXException("Unexpected element: '" + localName + "'");
|
throw new SAXException("Unexpected element: '" + name + "'");
|
||||||
|
|
||||||
// Initialize handler
|
// Initialize handler
|
||||||
handler.init(attributes);
|
handler.init(attributes);
|
||||||
|
@@ -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;
|
||||||
@@ -34,10 +34,7 @@ import org.apache.guacamole.xml.DocumentHandler;
|
|||||||
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.
|
||||||
@@ -115,6 +112,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 {
|
||||||
|
|
||||||
@@ -126,14 +139,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