diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/AuthenticatingHttpServlet.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/AuthenticatingHttpServlet.java index 6e95ae9e0..3b31eee54 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/AuthenticatingHttpServlet.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/AuthenticatingHttpServlet.java @@ -290,12 +290,12 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet { * Function called after the credentials given in the request (if any) * are authenticated. If the current session is not associated with * valid credentials, this function will not be called. - * + * * @param context The current UserContext. * @param request The HttpServletRequest being serviced. * @param response An HttpServletResponse which controls the HTTP response * of this servlet. - * + * * @throws ServletException If an error occurs that interferes with the * normal operation of this servlet. * @throws IOException If an error occurs that prevents this servlet from diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java index b1037826b..6606faf09 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java @@ -81,7 +81,7 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide * the XML file specified by the "basic-user-mapping" property in * guacamole.properties. If the XML file has been modified or has not yet * been read, this function may reread the file. - * + * * @return A UserMapping containing all authorization data within the * user mapping XML file. * @throws GuacamoleException If the user mapping property is missing or @@ -106,7 +106,7 @@ public class BasicFileAuthenticationProvider extends SimpleAuthenticationProvide // Get handler for root element UserMappingTagHandler userMappingHandler = new UserMappingTagHandler(); - + // Set up document handler DocumentHandler contentHandler = new DocumentHandler( "user-mapping", userMappingHandler); diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicGuacamoleTunnelServlet.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicGuacamoleTunnelServlet.java index b22917297..47d0c5352 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicGuacamoleTunnelServlet.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicGuacamoleTunnelServlet.java @@ -177,12 +177,12 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet { // Get connection directory Directory directory = context.getConnectionDirectory(); - + // If no credentials in session, not authorized if (credentials == null) throw new GuacamoleSecurityException("Cannot connect - user not logged in."); - // Get authorized connection + // Get authorized connection Connection connection = directory.get(id); if (connection == null) { logger.warn("Connection id={} not found.", id); @@ -193,7 +193,7 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet { // Get client information GuacamoleClientInformation info = new GuacamoleClientInformation(); - + // Set width if provided String width = request.getParameter("width"); if (width != null) @@ -203,12 +203,12 @@ public class BasicGuacamoleTunnelServlet extends AuthenticatingHttpServlet { String height = request.getParameter("height"); if (height != null) info.setOptimalScreenHeight(Integer.parseInt(height)); - + // Add audio mimetypes String[] audio_mimetypes = request.getParameterValues("audio"); if (audio_mimetypes != null) info.getAudioMimetypes().addAll(Arrays.asList(audio_mimetypes)); - + // Add video mimetypes String[] video_mimetypes = request.getParameterValues("video"); if (video_mimetypes != null) diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/GuacamoleClassLoader.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/GuacamoleClassLoader.java index 24ee22d93..6be2950e5 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/GuacamoleClassLoader.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/GuacamoleClassLoader.java @@ -84,7 +84,7 @@ public class GuacamoleClassLoader extends ClassLoader { /** * Creates a new GuacamoleClassLoader which reads classes from the given * directory. - * + * * @param libDirectory The directory to load classes from. * @throws GuacamoleException If the file given is not a director, or if * an error occurs while constructing the URL diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/Authorization.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/Authorization.java index cdb403ab6..91147a513 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/Authorization.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/Authorization.java @@ -29,7 +29,7 @@ import net.sourceforge.guacamole.protocol.GuacamoleConfiguration; * Mapping of username/password pair to configuration set. In addition to basic * storage of the username, password, and configurations, this class also * provides password validation functions. - * + * * @author Mike Jumper */ public class Authorization { @@ -83,7 +83,7 @@ public class Authorization { /** * Produces a String containing the bytes provided in hexadecimal notation. - * + * * @param bytes The bytes to convert into hex. * @return A String containing the hex representation of the given bytes. */ @@ -110,7 +110,7 @@ public class Authorization { /** * Returns the username associated with this authorization. - * + * * @return The username associated with this authorization. */ public String getUsername() { @@ -119,7 +119,7 @@ public class Authorization { /** * Sets the username associated with this authorization. - * + * * @param username The username to associate with this authorization. */ public void setUsername(String username) { @@ -129,7 +129,7 @@ public class Authorization { /** * Returns the password associated with this authorization, which may be * encoded or hashed. - * + * * @return The password associated with this authorization. */ public String getPassword() { @@ -140,7 +140,7 @@ public class Authorization { * Sets the password associated with this authorization, which must be * encoded using the encoding specified with setEncoding(). By default, * passwords are plain text. - * + * * @param password Sets the password associated with this authorization. */ public void setPassword(String password) { @@ -149,7 +149,7 @@ public class Authorization { /** * Returns the encoding used to hash the password, if any. - * + * * @return The encoding used to hash the password. */ public Encoding getEncoding() { @@ -159,7 +159,7 @@ public class Authorization { /** * Sets the encoding which will be used to hash the password or when * comparing a given password for validation. - * + * * @param encoding The encoding to use for password hashing. */ public void setEncoding(Encoding encoding) { @@ -170,7 +170,7 @@ public class Authorization { * Returns whether a given username/password pair is authorized based on * the stored username and password. The password given must be plain text. * It will be hashed as necessary to perform the validation. - * + * * @param username The username to validate. * @param password The password to validate. * @return true if the username/password pair given is authorized, false @@ -217,7 +217,7 @@ public class Authorization { /** * Returns the GuacamoleConfiguration having the given name and associated * with the username/password pair stored within this authorization. - * + * * @param name The name of the GuacamoleConfiguration to return. * @return The GuacamoleConfiguration having the given name, or null if no * such GuacamoleConfiguration exists. @@ -229,19 +229,19 @@ public class Authorization { /** * Adds the given GuacamoleConfiguration to the set of stored configurations * under the given name. - * + * * @param name The name to associate this GuacamoleConfiguration with. * @param config The GuacamoleConfiguration to store. */ public void addConfiguration(String name, GuacamoleConfiguration config) { configs.put(name, config); } - + /** * Returns a Map of all stored GuacamoleConfigurations associated with the * username/password pair stored within this authorization, indexed by * configuration name. - * + * * @return A Map of all stored GuacamoleConfigurations. */ public Map getConfigurations() { diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/UserMapping.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/UserMapping.java index fca8e2e8c..e21cdc9a4 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/UserMapping.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/auth/UserMapping.java @@ -24,7 +24,7 @@ import java.util.Map; /** * Mapping of all usernames to corresponding authorizations. - * + * * @author Mike Jumper */ public class UserMapping { @@ -34,10 +34,10 @@ public class UserMapping { */ private Map authorizations = new HashMap(); - + /** * Adds the given authorization to the user mapping. - * + * * @param authorization The authorization to add to the user mapping. */ public void addAuthorization(Authorization authorization) { @@ -47,7 +47,7 @@ public class UserMapping { /** * Returns the authorization corresponding to the user having the given * username, if any. - * + * * @param username The username to find the authorization for. * @return The authorization corresponding to the user having the given * username, or null if no such authorization exists. @@ -55,5 +55,5 @@ public class UserMapping { public Authorization getAuthorization(String username) { return authorizations.get(username); } - + } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Create.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Create.java index 1fb1b4892..e1603adb0 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Create.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Create.java @@ -42,7 +42,7 @@ public class Create extends AuthenticatingHttpServlet { * specific parameter meant for the configuration. */ public static final String PARAMETER_PREFIX = "_"; - + @Override protected void authenticatedService( UserContext context, @@ -52,7 +52,7 @@ public class Create extends AuthenticatingHttpServlet { // Get ID and protocol String identifier = request.getParameter("id"); String protocol = request.getParameter("protocol"); - + try { // Attempt to get connection directory @@ -74,22 +74,22 @@ public class Create extends AuthenticatingHttpServlet { config.setParameter( param.substring(PARAMETER_PREFIX.length()), request.getParameter(param)); - + } - + // Create connection skeleton Connection connection = new DummyConnection(); connection.setIdentifier(identifier); connection.setConfiguration(config); - + // Add connection directory.add(connection); - + } catch (GuacamoleException e) { throw new ServletException("Unable to create connection.", e); } - + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Delete.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Delete.java index 597e1d858..c526f27d8 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Delete.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Delete.java @@ -43,21 +43,21 @@ public class Delete extends AuthenticatingHttpServlet { // Get ID String identifier = request.getParameter("id"); - + try { // Attempt to get connection directory Directory directory = context.getConnectionDirectory(); - + // Remove connection directory.remove(identifier); - + } catch (GuacamoleException e) { throw new ServletException("Unable to remove connection.", e); } - + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/DummyConnection.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/DummyConnection.java index 809f86d93..7bd4492a8 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/DummyConnection.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/DummyConnection.java @@ -15,7 +15,7 @@ import net.sourceforge.guacamole.protocol.GuacamoleClientInformation; * semantics that would otherwise be present because of the authentication * provider. It is up to the authentication provider to create a new * Connection based on the information contained herein. - * + * * @author Michael Jumper */ public class DummyConnection extends AbstractConnection { diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java index 3f1388539..8f2c5adec 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/List.java @@ -52,11 +52,11 @@ public class List extends AuthenticatingHttpServlet { * Checks whether the given user has permission to perform the given * system operation. Security exceptions are handled appropriately - only * non-security exceptions pass through. - * + * * @param user The user whose permissions should be verified. * @param type The type of operation to check for permission for. * @return true if permission is granted, false otherwise. - * + * * @throws GuacamoleException If an error occurs while checking permissions. */ private boolean hasConfigPermission(User user, SystemPermission.Type type) @@ -81,13 +81,13 @@ public class List extends AuthenticatingHttpServlet { * Checks whether the given user has permission to perform the given * object operation. Security exceptions are handled appropriately - only * non-security exceptions pass through. - * + * * @param user The user whose permissions should be verified. * @param type The type of operation to check for permission for. * @param identifier The identifier of the connection the operation * would be performed upon. * @return true if permission is granted, false otherwise. - * + * * @throws GuacamoleException If an error occurs while checking permissions. */ private boolean hasConfigPermission(User user, ObjectPermission.Type type, @@ -110,7 +110,7 @@ public class List extends AuthenticatingHttpServlet { } } - + @Override protected void authenticatedService( UserContext context, @@ -123,7 +123,7 @@ public class List extends AuthenticatingHttpServlet { // Write XML content type response.setHeader("Content-Type", "text/xml"); - // Attempt to get connections + // Attempt to get connections Directory directory; try { @@ -134,28 +134,28 @@ public class List extends AuthenticatingHttpServlet { catch (GuacamoleException e) { throw new ServletException("Unable to retrieve connections.", e); } - + // Write actual XML try { - // Get self + // Get self User self = context.self(); - + XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xml = outputFactory.createXMLStreamWriter(response.getWriter()); // Begin document xml.writeStartDocument(); xml.writeStartElement("connections"); - + // Save connection create permission attribute if (hasConfigPermission(self, SystemPermission.Type.CREATE)) xml.writeAttribute("create", "yes"); - + // For each entry, write corresponding connection element for (String identifier : directory.getIdentifiers()) { - // Get connection + // Get connection Connection connection = directory.get(identifier); // Write connection @@ -168,12 +168,12 @@ public class List extends AuthenticatingHttpServlet { if (hasConfigPermission(self, ObjectPermission.Type.ADMINISTER, identifier)) xml.writeAttribute("admin", "yes"); - + // Save delete permission attribute if (hasConfigPermission(self, ObjectPermission.Type.DELETE, identifier)) xml.writeAttribute("delete", "yes"); - + // Save update permission attribute, include parameters if (hasConfigPermission(self, ObjectPermission.Type.UPDATE, identifier)) { @@ -209,7 +209,7 @@ public class List extends AuthenticatingHttpServlet { if (record.getEndDate() != null) xml.writeAttribute("end", Long.toString(record.getEndDate().getTime())); - + // User involved xml.writeCharacters(record.getUser().getUsername()); diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Update.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Update.java index cda5e5d75..9cd5727b4 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Update.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/connections/Update.java @@ -42,7 +42,7 @@ public class Update extends AuthenticatingHttpServlet { * specific parameter meant for the configuration. */ public static final String PARAMETER_PREFIX = "_"; - + @Override protected void authenticatedService( UserContext context, @@ -52,7 +52,7 @@ public class Update extends AuthenticatingHttpServlet { // Get ID and protocol String identifier = request.getParameter("id"); String protocol = request.getParameter("protocol"); - + try { // Attempt to get connection directory @@ -74,22 +74,22 @@ public class Update extends AuthenticatingHttpServlet { config.setParameter( param.substring(PARAMETER_PREFIX.length()), request.getParameter(param)); - + } - + // Create connection skeleton Connection connection = new DummyConnection(); connection.setIdentifier(identifier); connection.setConfiguration(config); - + // Update connection directory.update(connection); - + } catch (GuacamoleException e) { throw new ServletException("Unable to update connection.", e); } - + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/permissions/List.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/permissions/List.java index 41180fcc0..94ec140ff 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/permissions/List.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/permissions/List.java @@ -46,24 +46,24 @@ import net.sourceforge.guacamole.net.basic.AuthenticatingHttpServlet; * @author Michael Jumper */ public class List extends AuthenticatingHttpServlet { - + /** * Returns the XML attribute value representation of the given * SystemPermission.Type. - * + * * @param type The SystemPermission.Type to translate into a String. * @return The XML attribute value representation of the given * SystemPermission.Type. - * + * * @throws GuacamoleException If the type given is not implemented. */ - private String toString(SystemPermission.Type type) + private String toString(SystemPermission.Type type) throws GuacamoleException { switch (type) { case CREATE: return "create"; } - + throw new GuacamoleException("Unknown permission type: " + type); } @@ -71,14 +71,14 @@ public class List extends AuthenticatingHttpServlet { /** * Returns the XML attribute value representation of the given * ObjectPermission.Type. - * + * * @param type The ObjectPermission.Type to translate into a String. * @return The XML attribute value representation of the given * ObjectPermission.Type. - * + * * @throws GuacamoleException If the type given is not implemented. */ - private String toString(ObjectPermission.Type type) + private String toString(ObjectPermission.Type type) throws GuacamoleException { switch (type) { @@ -91,7 +91,7 @@ public class List extends AuthenticatingHttpServlet { throw new GuacamoleException("Unknown permission type: " + type); } - + @Override protected void authenticatedService( UserContext context, @@ -105,14 +105,14 @@ public class List extends AuthenticatingHttpServlet { try { User user; - + // Get username String username = request.getParameter("user"); if (username != null) { // Get user directory Directory users = context.getUserDirectory(); - + // Get specific user user = users.get(username); if (user == null) @@ -121,10 +121,10 @@ public class List extends AuthenticatingHttpServlet { } else user = context.self(); - + // Write XML content type response.setHeader("Content-Type", "text/xml"); - + XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter xml = outputFactory.createXMLStreamWriter(response.getWriter()); @@ -132,7 +132,7 @@ public class List extends AuthenticatingHttpServlet { xml.writeStartDocument(); xml.writeStartElement("permissions"); xml.writeAttribute("user", user.getUsername()); - + // For each entry, write corresponding user element for (Permission permission : user.getPermissions()) { @@ -142,8 +142,8 @@ public class List extends AuthenticatingHttpServlet { // Get permission ConnectionDirectoryPermission cdp = (ConnectionDirectoryPermission) permission; - - // Write permission + + // Write permission xml.writeEmptyElement("connections"); xml.writeAttribute("type", toString(cdp.getType())); @@ -155,8 +155,8 @@ public class List extends AuthenticatingHttpServlet { // Get permission ConnectionPermission cp = (ConnectionPermission) permission; - - // Write permission + + // Write permission xml.writeEmptyElement("connection"); xml.writeAttribute("type", toString(cp.getType())); xml.writeAttribute("name", cp.getObjectIdentifier()); @@ -169,8 +169,8 @@ public class List extends AuthenticatingHttpServlet { // Get permission UserDirectoryPermission udp = (UserDirectoryPermission) permission; - - // Write permission + + // Write permission xml.writeEmptyElement("users"); xml.writeAttribute("type", toString(udp.getType())); @@ -181,8 +181,8 @@ public class List extends AuthenticatingHttpServlet { // Get permission UserPermission up = (UserPermission) permission; - - // Write permission + + // Write permission xml.writeEmptyElement("user"); xml.writeAttribute("type", toString(up.getType())); xml.writeAttribute("name", up.getObjectIdentifier()); diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Create.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Create.java index 5480e1fcd..68a39199c 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Create.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Create.java @@ -44,7 +44,7 @@ public class Create extends AuthenticatingHttpServlet { // Create user as specified String username = request.getParameter("name"); - + try { // Attempt to get user directory @@ -55,16 +55,16 @@ public class Create extends AuthenticatingHttpServlet { User user = new DummyUser(); user.setUsername(username); user.setPassword(UUID.randomUUID().toString()); - + // Add user directory.add(user); - + } catch (GuacamoleException e) { throw new ServletException("Unable to create user.", e); } - - + + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Delete.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Delete.java index 62d3bc332..860b04598 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Delete.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Delete.java @@ -41,22 +41,22 @@ public class Delete extends AuthenticatingHttpServlet { HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - // Get username + // Get username String username = request.getParameter("name"); - + try { // Attempt to get user directory Directory directory = context.getUserDirectory(); - - // Remove user + + // Remove user directory.remove(username); - + } catch (GuacamoleException e) { throw new ServletException("Unable to remove user.", e); } - + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/DummyUser.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/DummyUser.java index 7ec67683e..ef5302816 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/DummyUser.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/DummyUser.java @@ -22,7 +22,7 @@ public class DummyUser extends AbstractUser { * Set of all available permissions. */ private Set permissions = new HashSet(); - + @Override public Set getPermissions() throws GuacamoleException { return permissions; diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/List.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/List.java index 1cc529a2b..a9f609947 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/List.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/List.java @@ -49,11 +49,11 @@ public class List extends AuthenticatingHttpServlet { * Checks whether the given user has permission to perform the given * system operation. Security exceptions are handled appropriately - only * non-security exceptions pass through. - * + * * @param user The user whose permissions should be verified. * @param type The type of operation to check for permission for. * @return true if permission is granted, false otherwise. - * + * * @throws GuacamoleException If an error occurs while checking permissions. */ private boolean hasUserPermission(User user, SystemPermission.Type type) @@ -77,13 +77,13 @@ public class List extends AuthenticatingHttpServlet { * Checks whether the given user has permission to perform the given * object operation. Security exceptions are handled appropriately - only * non-security exceptions pass through. - * + * * @param user The user whose permissions should be verified. * @param type The type of operation to check for permission for. * @param identifier The identifier of the user the operation would be * performed upon. * @return true if permission is granted, false otherwise. - * + * * @throws GuacamoleException If an error occurs while checking permissions. */ private boolean hasUserPermission(User user, ObjectPermission.Type type, @@ -103,7 +103,7 @@ public class List extends AuthenticatingHttpServlet { } } - + @Override protected void authenticatedService( UserContext context, @@ -121,7 +121,7 @@ public class List extends AuthenticatingHttpServlet { // Get user directory Directory directory = context.getUserDirectory(); - + // Get users Set users = directory.getIdentifiers(); @@ -134,18 +134,18 @@ public class List extends AuthenticatingHttpServlet { // Begin document xml.writeStartDocument(); xml.writeStartElement("users"); - + // Save user create permission attribute if (hasUserPermission(self, SystemPermission.Type.CREATE)) xml.writeAttribute("create", "yes"); - + // For each entry, write corresponding user element for (String username : users) { // Get user User user = directory.get(username); - - // Write user + + // Write user xml.writeEmptyElement("user"); xml.writeAttribute("name", user.getUsername()); @@ -153,17 +153,17 @@ public class List extends AuthenticatingHttpServlet { if (hasUserPermission(self, ObjectPermission.Type.UPDATE, user.getUsername())) xml.writeAttribute("update", "yes"); - + // Save admin permission attribute if (hasUserPermission(self, ObjectPermission.Type.ADMINISTER, user.getUsername())) xml.writeAttribute("admin", "yes"); - + // Save delete permission attribute if (hasUserPermission(self, ObjectPermission.Type.DELETE, user.getUsername())) xml.writeAttribute("delete", "yes"); - + } // End document diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Update.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Update.java index 87b602aa2..cc4b675fc 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Update.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/crud/users/Update.java @@ -46,22 +46,22 @@ public class Update extends AuthenticatingHttpServlet { * String given for directory creation permission. */ private static final String CREATE_PERMISSION = "create"; - + /** * Prefix given before an object identifier for read permission. */ private static final String READ_PREFIX = "read:"; - + /** * Prefix given before an object identifier for delete permission. */ private static final String DELETE_PREFIX = "delete:"; - + /** * Prefix given before an object identifier for update permission. */ private static final String UPDATE_PREFIX = "update:"; - + /** * Prefix given before an object identifier for administration permission. */ @@ -69,7 +69,7 @@ public class Update extends AuthenticatingHttpServlet { /** * Given a permission string, returns the corresponding user permission. - * + * * @param str The permission string to parse. * @return The parsed user permission. * @throws GuacamoleException If the given string could not be parsed. @@ -80,18 +80,18 @@ public class Update extends AuthenticatingHttpServlet { // Create permission if (str.equals(CREATE_PERMISSION)) return new UserDirectoryPermission(SystemPermission.Type.CREATE); - + // Read if (str.startsWith(READ_PREFIX)) return new UserPermission(ObjectPermission.Type.READ, str.substring(READ_PREFIX.length())); - - // Update + + // Update if (str.startsWith(UPDATE_PREFIX)) return new UserPermission(ObjectPermission.Type.UPDATE, str.substring(UPDATE_PREFIX.length())); - // Delete + // Delete if (str.startsWith(DELETE_PREFIX)) return new UserPermission(ObjectPermission.Type.DELETE, str.substring(DELETE_PREFIX.length())); @@ -100,15 +100,15 @@ public class Update extends AuthenticatingHttpServlet { if (str.startsWith(ADMIN_PREFIX)) return new UserPermission(ObjectPermission.Type.ADMINISTER, str.substring(ADMIN_PREFIX.length())); - + throw new GuacamoleException("Invalid permission string."); - + } /** * Given a permission string, returns the corresponding connection * permission. - * + * * @param str The permission string to parse. * @return The parsed connection permission. * @throws GuacamoleException If the given string could not be parsed. @@ -119,18 +119,18 @@ public class Update extends AuthenticatingHttpServlet { // Create permission if (str.equals(CREATE_PERMISSION)) return new ConnectionDirectoryPermission(SystemPermission.Type.CREATE); - + // Read if (str.startsWith(READ_PREFIX)) return new ConnectionPermission(ObjectPermission.Type.READ, str.substring(READ_PREFIX.length())); - - // Update + + // Update if (str.startsWith(UPDATE_PREFIX)) return new ConnectionPermission(ObjectPermission.Type.UPDATE, str.substring(UPDATE_PREFIX.length())); - // Delete + // Delete if (str.startsWith(DELETE_PREFIX)) return new ConnectionPermission(ObjectPermission.Type.DELETE, str.substring(DELETE_PREFIX.length())); @@ -139,11 +139,11 @@ public class Update extends AuthenticatingHttpServlet { if (str.startsWith(ADMIN_PREFIX)) return new ConnectionPermission(ObjectPermission.Type.ADMINISTER, str.substring(ADMIN_PREFIX.length())); - + throw new GuacamoleException("Invalid permission string."); - + } - + @Override protected void authenticatedService( UserContext context, @@ -153,7 +153,7 @@ public class Update extends AuthenticatingHttpServlet { // Create user as specified String username = request.getParameter("name"); String password = request.getParameter("password"); - + try { // Attempt to get user directory @@ -165,7 +165,7 @@ public class Update extends AuthenticatingHttpServlet { user.setUsername(username); if (password != null) user.setPassword(password); - + // Set user permissions String[] user_permission = request.getParameterValues("user"); if (user_permission != null) { @@ -179,15 +179,15 @@ public class Update extends AuthenticatingHttpServlet { for (String str : connection_permission) user.addPermission(parseConnectionPermission(str)); } - + // Update user directory.update(user); - + } catch (GuacamoleException e) { throw new ServletException("Unable to update user.", e); } - + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/DocumentHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/DocumentHandler.java index 6eb07a0cc..95b38275c 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/DocumentHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/DocumentHandler.java @@ -27,7 +27,7 @@ import org.xml.sax.helpers.DefaultHandler; * A simple ContentHandler implementation which digests SAX document events and * produces simpler tag-level events, maintaining its own stack for the * convenience of the tag handlers. - * + * * @author Mike Jumper */ public class DocumentHandler extends DefaultHandler { @@ -36,7 +36,7 @@ public class DocumentHandler extends DefaultHandler { * The name of the root element of the document. */ private String rootElementName; - + /** * The handler which will be used to handle element events for the root * element of the document. @@ -55,7 +55,7 @@ public class DocumentHandler extends DefaultHandler { /** * Creates a new DocumentHandler which will use the given TagHandler * to handle the root element. - * + * * @param rootElementName The name of the root element of the document * being handled. * @param root The TagHandler to use for the root element. @@ -64,11 +64,11 @@ public class DocumentHandler extends DefaultHandler { this.root = root; this.rootElementName = rootElementName; } - + /** * Returns the current element state. The current element state is the * state of the element the parser is currently within. - * + * * @return The current element state. */ private DocumentHandlerState getCurrentState() { @@ -79,14 +79,14 @@ public class DocumentHandler extends DefaultHandler { return stack.getLast(); } - + @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { // Get current state DocumentHandlerState current = getCurrentState(); - + // Handler for tag just read TagHandler handler; @@ -96,7 +96,7 @@ public class DocumentHandler extends DefaultHandler { // Validate element name if (!localName.equals(rootElementName)) throw new SAXException("Root element must be '" + rootElementName + "'"); - + handler = root; } @@ -109,10 +109,10 @@ public class DocumentHandler extends DefaultHandler { // If no handler returned, the element was not expected if (handler == null) throw new SAXException("Unexpected element: '" + localName + "'"); - + // Append new element state to stack stack.addLast(new DocumentHandlerState(handler)); - + } @Override @@ -152,12 +152,12 @@ public class DocumentHandler extends DefaultHandler { * element currently being parsed. */ private TagHandler tagHandler; - + /** * Creates a new DocumentHandlerState which will maintain the state * of parsing of the current element, as well as contain the TagHandler * which will receive events related to that element. - * + * * @param tagHandler The TagHandler which should receive any events * related to the element being parsed. */ @@ -168,7 +168,7 @@ public class DocumentHandler extends DefaultHandler { /** * Returns the mutable StringBuilder which contains the current text * content of the element being parsed. - * + * * @return The mutable StringBuilder which contains the current text * content of the element being parsed. */ @@ -179,14 +179,14 @@ public class DocumentHandler extends DefaultHandler { /** * Returns the TagHandler which must handle any events relating to the * element being parsed. - * + * * @return The TagHandler which must handle any events relating to the * element being parsed. */ public TagHandler getTagHandler() { return tagHandler; } - + } } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/TagHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/TagHandler.java index 0aefe9047..6383f4af8 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/TagHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/TagHandler.java @@ -24,14 +24,14 @@ import org.xml.sax.SAXException; /** * A simple element-level event handler for events triggered by the * SAX-driven DocumentHandler parser. - * - * @author Mike Jumper + * + * @author Mike Jumper */ public interface TagHandler { /** * Called when a child element of the current element is parsed. - * + * * @param localName The local name of the child element seen. * @param attributes The attributes of the child element seen. * @return The TagHandler which should handle all element-level events @@ -42,16 +42,16 @@ public interface TagHandler { */ public TagHandler childElement(String localName, Attributes attributes) throws SAXException; - + /** * Called when this element, and all child elements, have been fully parsed, * and the entire text content of this element (if any) is available. - * + * * @param textContent The full text content of this element, if any. * @throws SAXException If the text content received is not valid for any * reason, or the child elements parsed are not * correct. */ public void complete(String textContent) throws SAXException; - + } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java index b8f32aa1d..c8a7e4338 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java @@ -26,8 +26,8 @@ import org.xml.sax.SAXException; /** * TagHandler for the "authorize" element. - * - * @author Mike Jumper + * + * @author Mike Jumper */ public class AuthorizeTagHandler implements TagHandler { @@ -43,11 +43,11 @@ public class AuthorizeTagHandler implements TagHandler { * tags occur outside a "connection" tag. */ private GuacamoleConfiguration default_config = null; - + /** * Creates a new handler for an "authorize" tag having the given * attributes. - * + * * @param attributes The attributes of the "authorize" tag. * @throws SAXException If the attributes given are not valid. */ @@ -73,9 +73,9 @@ public class AuthorizeTagHandler implements TagHandler { else throw new SAXException( "Invalid encoding: '" + encoding + "'"); - + } - + } @Override @@ -90,7 +90,7 @@ public class AuthorizeTagHandler implements TagHandler { // Store configuration stub GuacamoleConfiguration config_stub = tagHandler.asGuacamoleConfiguration(); authorization.addConfiguration(tagHandler.getName(), config_stub); - + return tagHandler; } @@ -119,7 +119,7 @@ public class AuthorizeTagHandler implements TagHandler { } return null; - + } @Override @@ -132,12 +132,12 @@ public class AuthorizeTagHandler implements TagHandler { * handler. This Authorization is guaranteed to at least have the username, * password, and encoding available. Any associated configurations will be * added dynamically as the authorize tag is parsed. - * + * * @return An Authorization backed by the data of this authorize tag * handler. */ public Authorization asAuthorization() { return authorization; } - + } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java index d676ad072..69bd62b71 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java @@ -25,8 +25,8 @@ import org.xml.sax.SAXException; /** * TagHandler for the "connection" element. - * - * @author Mike Jumper + * + * @author Mike Jumper */ public class ConnectionTagHandler implements TagHandler { @@ -34,16 +34,16 @@ public class ConnectionTagHandler implements TagHandler { * The GuacamoleConfiguration backing this tag handler. */ private GuacamoleConfiguration config = new GuacamoleConfiguration(); - + /** * The name associated with the connection being parsed. */ private String name; - + /** * Creates a new handler for an "connection" tag having the given * attributes. - * + * * @param attributes The attributes of the "connection" tag. * @throws SAXException If the attributes given are not valid. */ @@ -61,20 +61,20 @@ public class ConnectionTagHandler implements TagHandler { return new ProtocolTagHandler(config); return null; - + } @Override public void complete(String textContent) throws SAXException { // Do nothing } - + /** * Returns a GuacamoleConfiguration whose contents are populated from data * within this connection element and child elements. This * GuacamoleConfiguration will continue to be modified as the user mapping * is parsed. - * + * * @return A GuacamoleConfiguration whose contents are populated from data * within this connection element. */ @@ -84,11 +84,11 @@ public class ConnectionTagHandler implements TagHandler { /** * Returns the name associated with this connection. - * + * * @return The name associated with this connection. */ public String getName() { return name; } - + } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java index 3a595ac3d..d66206905 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java @@ -25,8 +25,8 @@ import org.xml.sax.SAXException; /** * TagHandler for the "param" element. - * - * @author Mike Jumper + * + * @author Mike Jumper */ public class ParamTagHandler implements TagHandler { @@ -35,16 +35,16 @@ public class ParamTagHandler implements TagHandler { * the tag handled by this tag handler. */ private GuacamoleConfiguration config; - + /** * The name of the parameter. */ private String name; - + /** * Creates a new handler for an "param" tag having the given * attributes. - * + * * @param config The GuacamoleConfiguration to update with the data parsed * from the "protocol" tag. * @param attributes The attributes of the "param" tag. @@ -67,5 +67,5 @@ public class ParamTagHandler implements TagHandler { public void complete(String textContent) throws SAXException { config.setParameter(name, textContent); } - + } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java index ee0faef41..02168036d 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java @@ -25,8 +25,8 @@ import org.xml.sax.SAXException; /** * TagHandler for the "protocol" element. - * - * @author Mike Jumper + * + * @author Mike Jumper */ public class ProtocolTagHandler implements TagHandler { @@ -35,11 +35,11 @@ public class ProtocolTagHandler implements TagHandler { * the tag handled by this tag handler. */ private GuacamoleConfiguration config; - + /** * Creates a new handler for a "protocol" tag having the given * attributes. - * + * * @param config The GuacamoleConfiguration to update with the data parsed * from the "protocol" tag. * @throws SAXException If the attributes given are not valid. @@ -57,5 +57,5 @@ public class ProtocolTagHandler implements TagHandler { public void complete(String textContent) throws SAXException { config.setProtocol(textContent); } - + } diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java index 09c5d92d4..e1a71a8e1 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java @@ -26,8 +26,8 @@ import org.xml.sax.SAXException; /** * TagHandler for the "user-mapping" element. - * - * @author Mike Jumper + * + * @author Mike Jumper */ public class UserMappingTagHandler implements TagHandler { @@ -35,13 +35,13 @@ public class UserMappingTagHandler implements TagHandler { * The UserMapping which will contain all data parsed by this tag handler. */ private UserMapping user_mapping = new UserMapping(); - + @Override public TagHandler childElement(String localName, Attributes attributes) throws SAXException { // Start parsing of authorize tags, add to list of all authorizations if (localName.equals("authorize")) { - + // Get tag handler for authorize tag AuthorizeTagHandler tagHandler = new AuthorizeTagHandler(attributes); @@ -49,13 +49,13 @@ public class UserMappingTagHandler implements TagHandler { // Store authorization stub in map of authorizations Authorization auth_stub = tagHandler.asAuthorization(); user_mapping.addAuthorization(auth_stub); - + return tagHandler; - + } return null; - + } @Override @@ -70,12 +70,12 @@ public class UserMappingTagHandler implements TagHandler { * in the object returned by this function even after this function has * returned, once the data corresponding to those authorizations or * configurations has been parsed. - * + * * @return A user mapping containing all authorizations and configurations * parsed so far. */ public UserMapping asUserMapping() { return user_mapping; } - + }