mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
Removed trailing whitespace.
This commit is contained in:
@@ -53,14 +53,14 @@ public interface GuacamoleReader {
|
|||||||
* this does not guarantee an entire instruction is available. If a full
|
* this does not guarantee an entire instruction is available. If a full
|
||||||
* instruction is not available, this function can return true, and a call
|
* instruction is not available, this function can return true, and a call
|
||||||
* to read() will still block.
|
* to read() will still block.
|
||||||
*
|
*
|
||||||
* @return true if instruction data is available for reading, false
|
* @return true if instruction data is available for reading, false
|
||||||
* otherwise.
|
* otherwise.
|
||||||
* @throws GuacamoleException If an error occurs while checking for
|
* @throws GuacamoleException If an error occurs while checking for
|
||||||
* available data.
|
* available data.
|
||||||
*/
|
*/
|
||||||
public boolean available() throws GuacamoleException;
|
public boolean available() throws GuacamoleException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads at least one complete Guacamole instruction, returning a buffer
|
* Reads at least one complete Guacamole instruction, returning a buffer
|
||||||
* containing one or more complete Guacamole instructions and no
|
* containing one or more complete Guacamole instructions and no
|
||||||
|
@@ -93,7 +93,7 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
|
|||||||
|
|
||||||
// Length of element
|
// Length of element
|
||||||
int elementLength = 0;
|
int elementLength = 0;
|
||||||
|
|
||||||
// Resume where we left off
|
// Resume where we left off
|
||||||
int i = parseStart;
|
int i = parseStart;
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
|
|||||||
|
|
||||||
// Get terminator
|
// Get terminator
|
||||||
char terminator = buffer[i + elementLength];
|
char terminator = buffer[i + elementLength];
|
||||||
|
|
||||||
// Move to character after terminator
|
// Move to character after terminator
|
||||||
i += elementLength + 1;
|
i += elementLength + 1;
|
||||||
|
|
||||||
@@ -139,19 +139,19 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
|
|||||||
System.arraycopy(buffer, i, buffer, 0, usedLength);
|
System.arraycopy(buffer, i, buffer, 0, usedLength);
|
||||||
|
|
||||||
return instruction;
|
return instruction;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle invalid terminator characters
|
// Handle invalid terminator characters
|
||||||
else if (terminator != ',')
|
else if (terminator != ',')
|
||||||
throw new GuacamoleServerException("Element terminator of instruction was not ';' nor ','");
|
throw new GuacamoleServerException("Element terminator of instruction was not ';' nor ','");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, read more data
|
// Otherwise, read more data
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, parse error
|
// Otherwise, parse error
|
||||||
@@ -189,14 +189,14 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
|
|||||||
|
|
||||||
// Get instruction
|
// Get instruction
|
||||||
char[] instructionBuffer = read();
|
char[] instructionBuffer = read();
|
||||||
|
|
||||||
// If EOF, return EOF
|
// If EOF, return EOF
|
||||||
if (instructionBuffer == null)
|
if (instructionBuffer == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Start of element
|
// Start of element
|
||||||
int elementStart = 0;
|
int elementStart = 0;
|
||||||
|
|
||||||
// Build list of elements
|
// Build list of elements
|
||||||
LinkedList<String> elements = new LinkedList<String>();
|
LinkedList<String> elements = new LinkedList<String>();
|
||||||
while (elementStart < instructionBuffer.length) {
|
while (elementStart < instructionBuffer.length) {
|
||||||
@@ -232,14 +232,14 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
|
|||||||
|
|
||||||
// Append element to list of elements
|
// Append element to list of elements
|
||||||
elements.addLast(element);
|
elements.addLast(element);
|
||||||
|
|
||||||
// Read terminator after element
|
// Read terminator after element
|
||||||
elementStart += length;
|
elementStart += length;
|
||||||
char terminator = instructionBuffer[elementStart];
|
char terminator = instructionBuffer[elementStart];
|
||||||
|
|
||||||
// Continue reading instructions after terminator
|
// Continue reading instructions after terminator
|
||||||
elementStart++;
|
elementStart++;
|
||||||
|
|
||||||
// If we've reached the end of the instruction
|
// If we've reached the end of the instruction
|
||||||
if (terminator == ';')
|
if (terminator == ';')
|
||||||
break;
|
break;
|
||||||
@@ -248,7 +248,7 @@ public class ReaderGuacamoleReader implements GuacamoleReader {
|
|||||||
|
|
||||||
// Pull opcode off elements list
|
// Pull opcode off elements list
|
||||||
String opcode = elements.removeFirst();
|
String opcode = elements.removeFirst();
|
||||||
|
|
||||||
// Create instruction
|
// Create instruction
|
||||||
GuacamoleInstruction instruction = new GuacamoleInstruction(
|
GuacamoleInstruction instruction = new GuacamoleInstruction(
|
||||||
Operation.fromOpcode(opcode),
|
Operation.fromOpcode(opcode),
|
||||||
|
@@ -79,7 +79,7 @@ public interface GuacamoleSocket {
|
|||||||
/**
|
/**
|
||||||
* Returns whether this GuacamoleSocket is open and can be used for reading
|
* Returns whether this GuacamoleSocket is open and can be used for reading
|
||||||
* and writing.
|
* and writing.
|
||||||
*
|
*
|
||||||
* @return true if this GuacamoleSocket is open, false otherwise.
|
* @return true if this GuacamoleSocket is open, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean isOpen();
|
public boolean isOpen();
|
||||||
|
@@ -149,7 +149,7 @@ public class GuacamoleTunnel {
|
|||||||
/**
|
/**
|
||||||
* Returns the GuacamoleSocket used by this GuacamoleTunnel for reading
|
* Returns the GuacamoleSocket used by this GuacamoleTunnel for reading
|
||||||
* and writing.
|
* and writing.
|
||||||
*
|
*
|
||||||
* @return The GuacamoleSocket used by this GuacamoleTunnel.
|
* @return The GuacamoleSocket used by this GuacamoleTunnel.
|
||||||
*/
|
*/
|
||||||
public GuacamoleSocket getSocket() {
|
public GuacamoleSocket getSocket() {
|
||||||
@@ -158,7 +158,7 @@ public class GuacamoleTunnel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Release all resources allocated to this GuacamoleTunnel.
|
* Release all resources allocated to this GuacamoleTunnel.
|
||||||
*
|
*
|
||||||
* @throws GuacamoleException if an error occurs while releasing
|
* @throws GuacamoleException if an error occurs while releasing
|
||||||
* resources.
|
* resources.
|
||||||
*/
|
*/
|
||||||
@@ -168,11 +168,11 @@ public class GuacamoleTunnel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this GuacamoleTunnel is open, or has been closed.
|
* Returns whether this GuacamoleTunnel is open, or has been closed.
|
||||||
*
|
*
|
||||||
* @return true if this GuacamoleTunnel is open, false if it is closed.
|
* @return true if this GuacamoleTunnel is open, false if it is closed.
|
||||||
*/
|
*/
|
||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return socket.isOpen();
|
return socket.isOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -64,7 +64,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class InetGuacamoleSocket implements GuacamoleSocket {
|
public class InetGuacamoleSocket implements GuacamoleSocket {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(InetGuacamoleSocket.class);
|
private Logger logger = LoggerFactory.getLogger(InetGuacamoleSocket.class);
|
||||||
|
|
||||||
private GuacamoleReader reader;
|
private GuacamoleReader reader;
|
||||||
private GuacamoleWriter writer;
|
private GuacamoleWriter writer;
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ public class InetGuacamoleSocket implements GuacamoleSocket {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
logger.debug("Connecting to guacd at {}:{}.", hostname, port);
|
logger.debug("Connecting to guacd at {}:{}.", hostname, port);
|
||||||
|
|
||||||
// Get address
|
// Get address
|
||||||
SocketAddress address = new InetSocketAddress(
|
SocketAddress address = new InetSocketAddress(
|
||||||
InetAddress.getByName(hostname),
|
InetAddress.getByName(hostname),
|
||||||
@@ -136,6 +136,6 @@ public class InetGuacamoleSocket implements GuacamoleSocket {
|
|||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return !sock.isClosed();
|
return !sock.isClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ public abstract class FileGuacamoleProperty implements GuacamoleProperty<File> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File parseValue(String value) throws GuacamoleException {
|
public File parseValue(String value) throws GuacamoleException {
|
||||||
|
|
||||||
// If no property provided, return null.
|
// If no property provided, return null.
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return null;
|
return null;
|
||||||
|
@@ -141,6 +141,6 @@ public class GuacamoleProperties {
|
|||||||
throw new GuacamoleServerException("Property " + property.getName() + " is required.");
|
throw new GuacamoleServerException("Property " + property.getName() + " is required.");
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,7 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket {
|
|||||||
args[i] = value;
|
args[i] = value;
|
||||||
else
|
else
|
||||||
args[i] = "";
|
args[i] = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send args
|
// Send args
|
||||||
@@ -111,7 +111,7 @@ public class ConfiguredGuacamoleSocket implements GuacamoleSocket {
|
|||||||
/**
|
/**
|
||||||
* Returns the GuacamoleConfiguration used to configure this
|
* Returns the GuacamoleConfiguration used to configure this
|
||||||
* ConfiguredGuacamoleSocket.
|
* ConfiguredGuacamoleSocket.
|
||||||
*
|
*
|
||||||
* @return The GuacamoleConfiguration used to configure this
|
* @return The GuacamoleConfiguration used to configure this
|
||||||
* ConfiguredGuacamoleSocket.
|
* ConfiguredGuacamoleSocket.
|
||||||
*/
|
*/
|
||||||
|
@@ -49,7 +49,7 @@ import java.util.HashMap;
|
|||||||
public class GuacamoleConfiguration implements Serializable {
|
public class GuacamoleConfiguration implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String protocol;
|
private String protocol;
|
||||||
private HashMap<String, String> parameters = new HashMap<String, String>();
|
private HashMap<String, String> parameters = new HashMap<String, String>();
|
||||||
|
|
||||||
|
@@ -58,7 +58,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(GuacamoleHTTPTunnelServlet.class);
|
private Logger logger = LoggerFactory.getLogger(GuacamoleHTTPTunnelServlet.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
||||||
handleTunnelRequest(request, response);
|
handleTunnelRequest(request, response);
|
||||||
@@ -72,7 +72,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
/**
|
/**
|
||||||
* Sends an error on the given HTTP response with the given integer error
|
* Sends an error on the given HTTP response with the given integer error
|
||||||
* code.
|
* code.
|
||||||
*
|
*
|
||||||
* @param response The HTTP response to use to send the error.
|
* @param response The HTTP response to use to send the error.
|
||||||
* @param code The HTTP status code of the error.
|
* @param code The HTTP status code of the error.
|
||||||
* @throws ServletException If an error prevents sending of the error
|
* @throws ServletException If an error prevents sending of the error
|
||||||
@@ -98,7 +98,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dispatches every HTTP GET and POST request to the appropriate handler
|
* Dispatches every HTTP GET and POST request to the appropriate handler
|
||||||
* function based on the query string.
|
* function based on the query string.
|
||||||
@@ -132,7 +132,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
session.attachTunnel(tunnel);
|
session.attachTunnel(tunnel);
|
||||||
|
|
||||||
logger.info("Connection from {} succeeded.", request.getRemoteAddr());
|
logger.info("Connection from {} succeeded.", request.getRemoteAddr());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Send UUID to client
|
// Send UUID to client
|
||||||
response.getWriter().print(tunnel.getUUID().toString());
|
response.getWriter().print(tunnel.getUUID().toString());
|
||||||
@@ -140,7 +140,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new GuacamoleServerException(e);
|
throw new GuacamoleServerException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failed to connect
|
// Failed to connect
|
||||||
@@ -233,7 +233,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
// Ensure tunnel is open
|
// Ensure tunnel is open
|
||||||
if (!tunnel.isOpen())
|
if (!tunnel.isOpen())
|
||||||
throw new GuacamoleResourceNotFoundException("Tunnel is closed.");
|
throw new GuacamoleResourceNotFoundException("Tunnel is closed.");
|
||||||
|
|
||||||
// Obtain exclusive read access
|
// Obtain exclusive read access
|
||||||
GuacamoleReader reader = tunnel.acquireReader();
|
GuacamoleReader reader = tunnel.acquireReader();
|
||||||
|
|
||||||
@@ -273,7 +273,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
// Close tunnel immediately upon EOF
|
// Close tunnel immediately upon EOF
|
||||||
if (message == null)
|
if (message == null)
|
||||||
tunnel.close();
|
tunnel.close();
|
||||||
|
|
||||||
// End-of-instructions marker
|
// End-of-instructions marker
|
||||||
out.write("0.;");
|
out.write("0.;");
|
||||||
out.flush();
|
out.flush();
|
||||||
@@ -292,11 +292,11 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
|
|
||||||
// Log typically frequent I/O error if desired
|
// Log typically frequent I/O error if desired
|
||||||
logger.debug("Error writing to servlet output stream", e);
|
logger.debug("Error writing to servlet output stream", e);
|
||||||
|
|
||||||
// Detach and close
|
// Detach and close
|
||||||
session.detachTunnel(tunnel);
|
session.detachTunnel(tunnel);
|
||||||
tunnel.close();
|
tunnel.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
tunnel.releaseReader();
|
tunnel.releaseReader();
|
||||||
@@ -345,7 +345,7 @@ public abstract class GuacamoleHTTPTunnelServlet extends HttpServlet {
|
|||||||
char[] buffer = new char[8192];
|
char[] buffer = new char[8192];
|
||||||
|
|
||||||
int length;
|
int length;
|
||||||
while (tunnel.isOpen() &&
|
while (tunnel.isOpen() &&
|
||||||
(length = input.read(buffer, 0, buffer.length)) != -1)
|
(length = input.read(buffer, 0, buffer.length)) != -1)
|
||||||
writer.write(buffer, 0, length);
|
writer.write(buffer, 0, length);
|
||||||
|
|
||||||
|
@@ -54,7 +54,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
public class GuacamoleSession {
|
public class GuacamoleSession {
|
||||||
|
|
||||||
private Logger logger = LoggerFactory.getLogger(GuacamoleSession.class);
|
private Logger logger = LoggerFactory.getLogger(GuacamoleSession.class);
|
||||||
|
|
||||||
private ConcurrentMap<String, GuacamoleTunnel> tunnels;
|
private ConcurrentMap<String, GuacamoleTunnel> tunnels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user