Remove trailing whitespace.

This commit is contained in:
Michael Jumper
2012-08-09 11:08:20 -07:00
parent 917d532431
commit bdd0ab250f
12 changed files with 104 additions and 104 deletions

View File

@@ -27,32 +27,32 @@ import org.slf4j.LoggerFactory;
* Abstract servlet which provides an authenticatedService() function that * Abstract servlet which provides an authenticatedService() function that
* is only called if the HTTP request is authenticated, or the current * is only called if the HTTP request is authenticated, or the current
* HTTP session has already been authenticated. * HTTP session has already been authenticated.
* *
* Authorized configurations are retrieved using the authentication provider * Authorized configurations are retrieved using the authentication provider
* defined in guacamole.properties. The authentication provider has access * defined in guacamole.properties. The authentication provider has access
* to the request and session, in addition to any submitted username and * to the request and session, in addition to any submitted username and
* password, in order to authenticate the user. * password, in order to authenticate the user.
* *
* All authorized configurations will be stored in the current HttpSession. * All authorized configurations will be stored in the current HttpSession.
* *
* Success and failure are logged. * Success and failure are logged.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public abstract class AuthenticatingHttpServlet extends HttpServlet { public abstract class AuthenticatingHttpServlet extends HttpServlet {
private Logger logger = LoggerFactory.getLogger(AuthenticatingHttpServlet.class); private Logger logger = LoggerFactory.getLogger(AuthenticatingHttpServlet.class);
/** /**
* The session attribute holding the map of configurations. * The session attribute holding the map of configurations.
*/ */
private static final String CONFIGURATIONS_ATTRIBUTE = "GUAC_CONFIGS"; private static final String CONFIGURATIONS_ATTRIBUTE = "GUAC_CONFIGS";
/** /**
* The session attribute holding the credentials authorizing this session. * The session attribute holding the credentials authorizing this session.
*/ */
private static final String CREDENTIALS_ATTRIBUTE = "GUAC_CREDS"; private static final String CREDENTIALS_ATTRIBUTE = "GUAC_CREDS";
/** /**
* The AuthenticationProvider to use to authenticate all requests. * The AuthenticationProvider to use to authenticate all requests.
*/ */
@@ -75,16 +75,16 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
/** /**
* Notifies all listeners in the given collection that authentication has * Notifies all listeners in the given collection that authentication has
* failed. * failed.
* *
* @param listeners A collection of all listeners that should be notified. * @param listeners A collection of all listeners that should be notified.
* @param credentials The credentials associated with the authentication * @param credentials The credentials associated with the authentication
* request that failed. * request that failed.
*/ */
private void notifyFailed(Collection listeners, Credentials credentials) { private void notifyFailed(Collection listeners, Credentials credentials) {
// Build event for auth failure // Build event for auth failure
AuthenticationFailureEvent event = new AuthenticationFailureEvent(credentials); AuthenticationFailureEvent event = new AuthenticationFailureEvent(credentials);
// Notify all listeners // Notify all listeners
for (Object listener : listeners) { for (Object listener : listeners) {
try { try {
@@ -95,13 +95,13 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
logger.error("Error notifying AuthenticationFailureListener.", e); logger.error("Error notifying AuthenticationFailureListener.", e);
} }
} }
} }
/** /**
* Notifies all listeners in the given collection that authentication was * Notifies all listeners in the given collection that authentication was
* successful. * successful.
* *
* @param listeners A collection of all listeners that should be notified. * @param listeners A collection of all listeners that should be notified.
* @param credentials The credentials associated with the authentication * @param credentials The credentials associated with the authentication
* request that succeeded. * request that succeeded.
@@ -116,10 +116,10 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
*/ */
private boolean notifySuccess(Collection listeners, Credentials credentials) private boolean notifySuccess(Collection listeners, Credentials credentials)
throws GuacamoleException { throws GuacamoleException {
// Build event for auth success // Build event for auth success
AuthenticationSuccessEvent event = new AuthenticationSuccessEvent(credentials); AuthenticationSuccessEvent event = new AuthenticationSuccessEvent(credentials);
// Notify all listeners // Notify all listeners
for (Object listener : listeners) { for (Object listener : listeners) {
if (listener instanceof AuthenticationSuccessListener) { if (listener instanceof AuthenticationSuccessListener) {
@@ -127,28 +127,28 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
// Cancel immediately if hook returns false // Cancel immediately if hook returns false
if (!((AuthenticationSuccessListener) listener).authenticationSucceeded(event)) if (!((AuthenticationSuccessListener) listener).authenticationSucceeded(event))
return false; return false;
} }
} }
return true; return true;
} }
/** /**
* Sends a predefined, generic error message to the user, along with a * Sends a predefined, generic error message to the user, along with a
* "403 - Forbidden" HTTP status code in the response. * "403 - Forbidden" HTTP status code in the response.
* *
* @param response The response to send the error within. * @param response The response to send the error within.
* @throws IOException If an error occurs while sending the error. * @throws IOException If an error occurs while sending the error.
*/ */
private void failAuthentication(HttpServletResponse response) throws IOException { private void failAuthentication(HttpServletResponse response) throws IOException {
response.sendError(HttpServletResponse.SC_FORBIDDEN); response.sendError(HttpServletResponse.SC_FORBIDDEN);
} }
/** /**
* Returns the credentials associated with the given session. * Returns the credentials associated with the given session.
* *
* @param session The session to retrieve credentials from. * @param session The session to retrieve credentials from.
* @return The credentials associated with the given session. * @return The credentials associated with the given session.
*/ */
@@ -158,14 +158,14 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
/** /**
* Returns the configurations associated with the given session. * Returns the configurations associated with the given session.
* *
* @param session The session to retrieve configurations from. * @param session The session to retrieve configurations from.
* @return The configurations associated with the given session. * @return The configurations associated with the given session.
*/ */
protected Map<String, GuacamoleConfiguration> getConfigurations(HttpSession session) { protected Map<String, GuacamoleConfiguration> getConfigurations(HttpSession session) {
return (Map<String, GuacamoleConfiguration>) session.getAttribute(CONFIGURATIONS_ATTRIBUTE); return (Map<String, GuacamoleConfiguration>) session.getAttribute(CONFIGURATIONS_ATTRIBUTE);
} }
@Override @Override
protected void service(HttpServletRequest request, HttpServletResponse response) protected void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
@@ -188,7 +188,7 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
failAuthentication(response); failAuthentication(response);
return; return;
} }
// Retrieve username and password from parms // Retrieve username and password from parms
String username = request.getParameter("username"); String username = request.getParameter("username");
String password = request.getParameter("password"); String password = request.getParameter("password");
@@ -207,7 +207,7 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
/******** HANDLE FAILED AUTHENTICATION ********/ /******** HANDLE FAILED AUTHENTICATION ********/
// If error retrieving configs, fail authentication, notify listeners // If error retrieving configs, fail authentication, notify listeners
catch (GuacamoleException e) { catch (GuacamoleException e) {
logger.error("Error retrieving configuration(s) for user \"{}\".", logger.error("Error retrieving configuration(s) for user \"{}\".",
@@ -217,12 +217,12 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
failAuthentication(response); failAuthentication(response);
return; return;
} }
// If no configs, fail authentication, notify listeners // If no configs, fail authentication, notify listeners
if (configs == null) { if (configs == null) {
logger.warn("Authentication attempt from {} for user \"{}\" failed.", logger.warn("Authentication attempt from {} for user \"{}\" failed.",
request.getRemoteAddr(), credentials.getUsername()); request.getRemoteAddr(), credentials.getUsername());
notifyFailed(listeners, credentials); notifyFailed(listeners, credentials);
failAuthentication(response); failAuthentication(response);
return; return;
@@ -230,7 +230,7 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
/******** HANDLE SUCCESSFUL AUTHENTICATION ********/ /******** HANDLE SUCCESSFUL AUTHENTICATION ********/
try { try {
// Otherwise, authentication has been succesful // Otherwise, authentication has been succesful
@@ -243,15 +243,15 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
failAuthentication(response); failAuthentication(response);
return; return;
} }
} }
catch (GuacamoleException e) { catch (GuacamoleException e) {
// Cancel authentication success if hook throws exception // Cancel authentication success if hook throws exception
logger.error("Successful authentication canceled by error in hook.", e); logger.error("Successful authentication canceled by error in hook.", e);
failAuthentication(response); failAuthentication(response);
return; return;
} }
// Associate configs and credentials with session // Associate configs and credentials with session

View File

@@ -48,13 +48,13 @@ 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.
* Each username/password may be associated with multiple configurations. * Each username/password may be associated with multiple configurations.
* This list is stored in an XML file which is reread if modified. * This list is stored in an XML file which is reread if modified.
* *
* @author Michael Jumper, Michal Kotas * @author Michael Jumper, Michal Kotas
*/ */
public class BasicFileAuthenticationProvider implements AuthenticationProvider { public class BasicFileAuthenticationProvider implements AuthenticationProvider {
private Logger logger = LoggerFactory.getLogger(BasicFileAuthenticationProvider.class); private Logger logger = LoggerFactory.getLogger(BasicFileAuthenticationProvider.class);
private long mappingTime; private long mappingTime;
private Map<String, AuthInfo> mapping; private Map<String, AuthInfo> mapping;
@@ -83,7 +83,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
throw new GuacamoleException("Missing \"basic-user-mapping\" parameter required for basic login."); throw new GuacamoleException("Missing \"basic-user-mapping\" parameter required for basic login.");
logger.info("Reading user mapping file: {}", mapFile); logger.info("Reading user mapping file: {}", mapFile);
// Parse document // Parse document
try { try {
@@ -132,7 +132,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
// If no mapping available, report as such // If no mapping available, report as such
if (mapping == null) if (mapping == null)
throw new GuacamoleException("User mapping could not be read."); throw new GuacamoleException("User mapping could not be read.");
// Validate and return info for given user and pass // Validate and return info for given user and pass
AuthInfo info = mapping.get(credentials.getUsername()); AuthInfo info = mapping.get(credentials.getUsername());
if (info != null && info.validate(credentials.getUsername(), credentials.getPassword())) if (info != null && info.validate(credentials.getUsername(), credentials.getPassword()))
@@ -297,7 +297,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
} }
break; break;
case CONNECTION: case CONNECTION:
if (localName.equals("connection")) { if (localName.equals("connection")) {
@@ -305,7 +305,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
return; return;
} }
break; break;
case PROTOCOL: case PROTOCOL:
@@ -400,7 +400,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
currentConnection = attributes.getValue("name"); currentConnection = attributes.getValue("name");
if (currentConnection == null) if (currentConnection == null)
throw new SAXException("Attribute \"name\" required for connection tag."); throw new SAXException("Attribute \"name\" required for connection tag.");
// Next state // Next state
state = State.CONNECTION; state = State.CONNECTION;
return; return;
@@ -410,7 +410,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
// Associate protocol with default connection // Associate protocol with default connection
currentConnection = "DEFAULT"; currentConnection = "DEFAULT";
// Next state // Next state
state = State.DEFAULT_CONNECTION_PROTOCOL; state = State.DEFAULT_CONNECTION_PROTOCOL;
return; return;
@@ -420,7 +420,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
// Associate parameter with default connection // Associate parameter with default connection
currentConnection = "DEFAULT"; currentConnection = "DEFAULT";
currentParameter = attributes.getValue("name"); currentParameter = attributes.getValue("name");
if (currentParameter == null) if (currentParameter == null)
throw new SAXException("Attribute \"name\" required for param tag."); throw new SAXException("Attribute \"name\" required for param tag.");
@@ -431,7 +431,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
} }
break; break;
case CONNECTION: case CONNECTION:
if (localName.equals("protocol")) { if (localName.equals("protocol")) {
@@ -451,7 +451,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
return; return;
} }
break; break;
} }
@@ -463,7 +463,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
public void characters(char[] ch, int start, int length) throws SAXException { public void characters(char[] ch, int start, int length) throws SAXException {
String str = new String(ch, start, length); String str = new String(ch, start, length);
switch (state) { switch (state) {
case PROTOCOL: case PROTOCOL:
@@ -479,7 +479,7 @@ public class BasicFileAuthenticationProvider implements AuthenticationProvider {
current.getConfiguration(currentConnection) current.getConfiguration(currentConnection)
.setParameter(currentParameter, str); .setParameter(currentParameter, str);
return; return;
} }
if (str.trim().length() != 0) if (str.trim().length() != 0)

View File

@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
/** /**
* Connects users to a tunnel associated with the authorized configuration * Connects users to a tunnel associated with the authorized configuration
* having the given ID. * having the given ID.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet { public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
@@ -58,16 +58,16 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
Map<String, GuacamoleConfiguration> configs, Map<String, GuacamoleConfiguration> configs,
HttpServletRequest request, HttpServletResponse response) HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
// If authenticated, respond as tunnel // If authenticated, respond as tunnel
tunnelServlet.service(request, response); tunnelServlet.service(request, response);
} }
/** /**
* Notifies all listeners in the given collection that a tunnel has been * Notifies all listeners in the given collection that a tunnel has been
* connected. * connected.
* *
* @param listeners A collection of all listeners that should be notified. * @param listeners A collection of all listeners that should be notified.
* @param credentials The credentials associated with the authentication * @param credentials The credentials associated with the authentication
* request that connected the tunnel. * request that connected the tunnel.
@@ -83,10 +83,10 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
private boolean notifyConnect(Collection listeners, private boolean notifyConnect(Collection listeners,
Credentials credentials, GuacamoleTunnel tunnel) Credentials credentials, GuacamoleTunnel tunnel)
throws GuacamoleException { throws GuacamoleException {
// Build event for auth success // Build event for auth success
TunnelConnectEvent event = new TunnelConnectEvent(credentials, tunnel); TunnelConnectEvent event = new TunnelConnectEvent(credentials, tunnel);
// Notify all listeners // Notify all listeners
for (Object listener : listeners) { for (Object listener : listeners) {
if (listener instanceof TunnelConnectListener) { if (listener instanceof TunnelConnectListener) {
@@ -94,18 +94,18 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
// Cancel immediately if hook returns false // Cancel immediately if hook returns false
if (!((TunnelConnectListener) listener).tunnelConnected(event)) if (!((TunnelConnectListener) listener).tunnelConnected(event))
return false; return false;
} }
} }
return true; return true;
} }
/** /**
* Notifies all listeners in the given collection that a tunnel has been * Notifies all listeners in the given collection that a tunnel has been
* closed. * closed.
* *
* @param listeners A collection of all listeners that should be notified. * @param listeners A collection of all listeners that should be notified.
* @param credentials The credentials associated with the authentication * @param credentials The credentials associated with the authentication
* request that closed the tunnel. * request that closed the tunnel.
@@ -121,10 +121,10 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
private boolean notifyClose(Collection listeners, private boolean notifyClose(Collection listeners,
Credentials credentials, GuacamoleTunnel tunnel) Credentials credentials, GuacamoleTunnel tunnel)
throws GuacamoleException { throws GuacamoleException {
// Build event for auth success // Build event for auth success
TunnelCloseEvent event = new TunnelCloseEvent(credentials, tunnel); TunnelCloseEvent event = new TunnelCloseEvent(credentials, tunnel);
// Notify all listeners // Notify all listeners
for (Object listener : listeners) { for (Object listener : listeners) {
if (listener instanceof TunnelCloseListener) { if (listener instanceof TunnelCloseListener) {
@@ -132,12 +132,12 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
// Cancel immediately if hook returns false // Cancel immediately if hook returns false
if (!((TunnelCloseListener) listener).tunnelClosed(event)) if (!((TunnelCloseListener) listener).tunnelClosed(event))
return false; return false;
} }
} }
return true; return true;
} }
/** /**
@@ -150,7 +150,7 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException { protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {
HttpSession httpSession = request.getSession(true); HttpSession httpSession = request.getSession(true);
// Get listeners // Get listeners
final SessionListenerCollection listeners; final SessionListenerCollection listeners;
try { try {
@@ -163,10 +163,10 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
// Get ID of connection // Get ID of connection
String id = request.getParameter("id"); String id = request.getParameter("id");
// Get credentials // Get credentials
final Credentials credentials = getCredentials(httpSession); final Credentials credentials = getCredentials(httpSession);
// Get authorized configs // Get authorized configs
Map<String, GuacamoleConfiguration> configs = getConfigurations(httpSession); Map<String, GuacamoleConfiguration> configs = getConfigurations(httpSession);
@@ -180,7 +180,7 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
logger.warn("Configuration id={} not found.", id); logger.warn("Configuration id={} not found.", id);
throw new GuacamoleSecurityException("Requested configuration is not authorized."); throw new GuacamoleSecurityException("Requested configuration is not authorized.");
} }
logger.info("Successful connection from {} to \"{}\".", request.getRemoteAddr(), id); logger.info("Successful connection from {} to \"{}\".", request.getRemoteAddr(), id);
// Configure and connect socket // Configure and connect socket
@@ -201,12 +201,12 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
// Only close if not canceled // Only close if not canceled
if (!notifyClose(listeners, credentials, this)) if (!notifyClose(listeners, credentials, this))
throw new GuacamoleException("Tunnel close canceled by listener."); throw new GuacamoleException("Tunnel close canceled by listener.");
// Close if no exception due to listener // Close if no exception due to listener
super.close(); super.close();
} }
}; };
// Notify listeners about connection // Notify listeners about connection
@@ -214,7 +214,7 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet {
logger.info("Connection canceled by listener."); logger.info("Connection canceled by listener.");
return null; return null;
} }
return tunnel; return tunnel;
} }

View File

@@ -29,13 +29,13 @@ import org.slf4j.LoggerFactory;
/** /**
* Simple dummy AuthenticatingHttpServlet which provides an endpoint for arbitrary * Simple dummy AuthenticatingHttpServlet which provides an endpoint for arbitrary
* authentication requests that do not expect a response. * authentication requests that do not expect a response.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class BasicLogin extends AuthenticatingHttpServlet { public class BasicLogin extends AuthenticatingHttpServlet {
private Logger logger = LoggerFactory.getLogger(BasicLogin.class); private Logger logger = LoggerFactory.getLogger(BasicLogin.class);
@Override @Override
protected void authenticatedService( protected void authenticatedService(
Map<String, GuacamoleConfiguration> configs, Map<String, GuacamoleConfiguration> configs,

View File

@@ -27,7 +27,7 @@ import javax.servlet.http.HttpSession;
/** /**
* Logs out the current user by invalidating the associated HttpSession and * Logs out the current user by invalidating the associated HttpSession and
* redirecting the user to the login page. * redirecting the user to the login page.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class BasicLogout extends HttpServlet { public class BasicLogout extends HttpServlet {

View File

@@ -31,7 +31,7 @@ import net.sourceforge.guacamole.protocol.GuacamoleConfiguration;
/** /**
* Simple HttpServlet which outputs XML containing a list of all authorized * Simple HttpServlet which outputs XML containing a list of all authorized
* configurations for the current user. * configurations for the current user.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class ConfigurationList extends AuthenticatingHttpServlet { public class ConfigurationList extends AuthenticatingHttpServlet {
@@ -44,12 +44,12 @@ public class ConfigurationList extends AuthenticatingHttpServlet {
// Do not cache // Do not cache
response.setHeader("Cache-Control", "no-cache"); response.setHeader("Cache-Control", "no-cache");
// Write XML // Write XML
response.setHeader("Content-Type", "text/xml"); response.setHeader("Content-Type", "text/xml");
PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter();
out.println("<configs>"); out.println("<configs>");
for (Entry<String, GuacamoleConfiguration> entry : configs.entrySet()) { for (Entry<String, GuacamoleConfiguration> entry : configs.entrySet()) {
GuacamoleConfiguration config = entry.getValue(); GuacamoleConfiguration config = entry.getValue();

View File

@@ -54,18 +54,18 @@ import net.sourceforge.guacamole.properties.GuacamoleProperties;
/** /**
* A ClassLoader implementation which finds classes within a configurable * A ClassLoader implementation which finds classes within a configurable
* directory. This directory is set within guacamole.properties. * directory. This directory is set within guacamole.properties.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class GuacamoleClassLoader extends ClassLoader { public class GuacamoleClassLoader extends ClassLoader {
private URLClassLoader classLoader = null; private URLClassLoader classLoader = null;
private static GuacamoleException exception = null; private static GuacamoleException exception = null;
private static GuacamoleClassLoader instance = null; private static GuacamoleClassLoader instance = null;
static { static {
try { try {
// Attempt to create singleton classloader which loads classes from // Attempt to create singleton classloader which loads classes from
// all .jar's in the lib directory defined in guacamole.properties // all .jar's in the lib directory defined in guacamole.properties
@@ -80,12 +80,12 @@ public class GuacamoleClassLoader extends ClassLoader {
}); });
} }
catch (PrivilegedActionException e) { catch (PrivilegedActionException e) {
// On error, record exception // On error, record exception
exception = (GuacamoleException) e.getException(); exception = (GuacamoleException) e.getException();
} }
} }
private GuacamoleClassLoader(File libDirectory) throws GuacamoleException { private GuacamoleClassLoader(File libDirectory) throws GuacamoleException {
@@ -93,37 +93,37 @@ public class GuacamoleClassLoader extends ClassLoader {
// If no directory provided, just direct requests to parent classloader // If no directory provided, just direct requests to parent classloader
if (libDirectory == null) if (libDirectory == null)
return; return;
// Validate directory is indeed a directory // Validate directory is indeed a directory
if (!libDirectory.isDirectory()) if (!libDirectory.isDirectory())
throw new GuacamoleException(libDirectory + " is not a directory."); throw new GuacamoleException(libDirectory + " is not a directory.");
// Get list of URLs for all .jar's in the lib directory // Get list of URLs for all .jar's in the lib directory
Collection<URL> jarURLs = new ArrayList<URL>(); Collection<URL> jarURLs = new ArrayList<URL>();
for (File file : libDirectory.listFiles(new FilenameFilter() { for (File file : libDirectory.listFiles(new FilenameFilter() {
@Override @Override
public boolean accept(File dir, String name) { public boolean accept(File dir, String name) {
// If it ends with .jar, accept the file // If it ends with .jar, accept the file
return name.endsWith(".jar"); return name.endsWith(".jar");
} }
})) { })) {
try { try {
// Add URL for the .jar to the jar URL list // Add URL for the .jar to the jar URL list
jarURLs.add(file.toURI().toURL()); jarURLs.add(file.toURI().toURL());
} }
catch (MalformedURLException e) { catch (MalformedURLException e) {
throw new GuacamoleException(e); throw new GuacamoleException(e);
} }
} }
// Set delegate classloader to new URLClassLoader which loads from the // Set delegate classloader to new URLClassLoader which loads from the
// .jars found above. // .jars found above.
@@ -132,22 +132,22 @@ public class GuacamoleClassLoader extends ClassLoader {
jarURLs.toArray(urls), jarURLs.toArray(urls),
getClass().getClassLoader() getClass().getClassLoader()
); );
} }
/** /**
* Returns an instance of a GuacamoleClassLoader which finds classes * Returns an instance of a GuacamoleClassLoader which finds classes
* within the directory configured in guacamole.properties. * within the directory configured in guacamole.properties.
* *
* @return An instance of a GuacamoleClassLoader. * @return An instance of a GuacamoleClassLoader.
* @throws GuacamoleException If no instance could be returned due to an * @throws GuacamoleException If no instance could be returned due to an
* error. * error.
*/ */
public static GuacamoleClassLoader getInstance() throws GuacamoleException { public static GuacamoleClassLoader getInstance() throws GuacamoleException {
// If instance could not be created, rethrow original exception // If instance could not be created, rethrow original exception
if (exception != null) throw exception; if (exception != null) throw exception;
return instance; return instance;
} }
@@ -158,7 +158,7 @@ public class GuacamoleClassLoader extends ClassLoader {
// If no classloader, use default loader // If no classloader, use default loader
if (classLoader == null) if (classLoader == null)
return Class.forName(name); return Class.forName(name);
// Otherwise, delegate // Otherwise, delegate
return classLoader.loadClass(name); return classLoader.loadClass(name);

View File

@@ -32,11 +32,11 @@ import org.slf4j.LoggerFactory;
* Simple ServletContextListener which loads a WebSocket tunnel implementation * Simple ServletContextListener which loads a WebSocket tunnel implementation
* if available, using the Servlet 3.0 API to dynamically load and install * if available, using the Servlet 3.0 API to dynamically load and install
* the tunnel servlet. * the tunnel servlet.
* *
* Note that because Guacamole depends on the Servlet 2.5 API, and 3.0 may * Note that because Guacamole depends on the Servlet 2.5 API, and 3.0 may
* not be available or needed if WebSocket is not desired, the 3.0 API is * not be available or needed if WebSocket is not desired, the 3.0 API is
* detected and invoked dynamically via reflection. * detected and invoked dynamically via reflection.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class WebSocketSupportLoader implements ServletContextListener { public class WebSocketSupportLoader implements ServletContextListener {
@@ -55,7 +55,7 @@ public class WebSocketSupportLoader implements ServletContextListener {
// Attempt to find WebSocket servlet // Attempt to find WebSocket servlet
Class<Servlet> servlet = (Class<Servlet>) GuacamoleClassLoader.getInstance().findClass( Class<Servlet> servlet = (Class<Servlet>) GuacamoleClassLoader.getInstance().findClass(
"net.sourceforge.guacamole.net.basic.BasicGuacamoleWebSocketTunnelServlet" "net.sourceforge.guacamole.net.basic.BasicGuacamoleWebSocketTunnelServlet"
); );
// Dynamically add servlet IF SERVLET 3.0 API AVAILABLE! // Dynamically add servlet IF SERVLET 3.0 API AVAILABLE!
try { try {

View File

@@ -17,7 +17,7 @@ import net.sourceforge.guacamole.properties.GuacamoleProperties;
* collection is stored within the HttpSession, and will be reused if available. * collection is stored within the HttpSession, and will be reused if available.
* Each listener is instantiated once per session. Listeners are singleton * Each listener is instantiated once per session. Listeners are singleton
* classes within the session, but not globally. * classes within the session, but not globally.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class SessionListenerCollection extends AbstractCollection { public class SessionListenerCollection extends AbstractCollection {
@@ -33,19 +33,19 @@ public class SessionListenerCollection extends AbstractCollection {
* session. * session.
*/ */
private Collection listeners; private Collection listeners;
/** /**
* Creates a new SessionListenerCollection which stores all listeners * Creates a new SessionListenerCollection which stores all listeners
* defined in guacamole.properties in the provided session. If listeners * defined in guacamole.properties in the provided session. If listeners
* are already stored in the provided session, those listeners are used * are already stored in the provided session, those listeners are used
* instead. * instead.
* *
* @param session The HttpSession to store listeners within. * @param session The HttpSession to store listeners within.
* @throws GuacamoleException If an error occurs while instantiating new * @throws GuacamoleException If an error occurs while instantiating new
* listeners. * listeners.
*/ */
public SessionListenerCollection(HttpSession session) throws GuacamoleException { public SessionListenerCollection(HttpSession session) throws GuacamoleException {
// Pull cached listeners from session // Pull cached listeners from session
listeners = (Collection) session.getAttribute(SESSION_ATTRIBUTE); listeners = (Collection) session.getAttribute(SESSION_ATTRIBUTE);
@@ -96,11 +96,11 @@ public class SessionListenerCollection extends AbstractCollection {
// Store listeners for next time // Store listeners for next time
session.setAttribute(SESSION_ATTRIBUTE, listeners); session.setAttribute(SESSION_ATTRIBUTE, listeners);
} }
} }
@Override @Override
public Iterator iterator() { public Iterator iterator() {
return listeners.iterator(); return listeners.iterator();
@@ -110,5 +110,5 @@ public class SessionListenerCollection extends AbstractCollection {
public int size() { public int size() {
return listeners.size(); return listeners.size();
} }
} }

View File

@@ -27,7 +27,7 @@ import net.sourceforge.guacamole.properties.GuacamoleProperty;
/** /**
* A GuacamoleProperty whose value is the name of a class to use to * A GuacamoleProperty whose value is the name of a class to use to
* authenticate users. This class must implement AuthenticationProvider. * authenticate users. This class must implement AuthenticationProvider.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public abstract class AuthenticationProviderProperty implements GuacamoleProperty<AuthenticationProvider> { public abstract class AuthenticationProviderProperty implements GuacamoleProperty<AuthenticationProvider> {

View File

@@ -23,7 +23,7 @@ import net.sourceforge.guacamole.properties.FileGuacamoleProperty;
/** /**
* Properties used by the default Guacamole web application. * Properties used by the default Guacamole web application.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public class BasicGuacamoleProperties { public class BasicGuacamoleProperties {

View File

@@ -27,7 +27,7 @@ import net.sourceforge.guacamole.properties.GuacamoleProperty;
/** /**
* A GuacamoleProperty whose value is a comma-separated list of class names, * A GuacamoleProperty whose value is a comma-separated list of class names,
* where each class will be used as a listener for events. * where each class will be used as a listener for events.
* *
* @author Michael Jumper * @author Michael Jumper
*/ */
public abstract class EventListenersProperty implements GuacamoleProperty<Collection<Class>> { public abstract class EventListenersProperty implements GuacamoleProperty<Collection<Class>> {
@@ -41,7 +41,7 @@ public abstract class EventListenersProperty implements GuacamoleProperty<Collec
// Parse list // Parse list
String[] classNames = classNameList.split(",[\\s]*"); String[] classNames = classNameList.split(",[\\s]*");
// Fill list of classes // Fill list of classes
Collection<Class> listeners = new ArrayList<Class>(); Collection<Class> listeners = new ArrayList<Class>();
try { try {