From b6fda0f206849c920441363a22fe524a94f09268 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Thu, 22 Aug 2013 10:19:19 -0700 Subject: [PATCH] Ticket #399: Made modification methods not part of the public Interface. --- .../simple/SimpleConnectionDirectory.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleConnectionDirectory.java b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleConnectionDirectory.java index 09a919c08..11d9b6256 100644 --- a/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleConnectionDirectory.java +++ b/guacamole-ext/src/main/java/net/sourceforge/guacamole/net/auth/simple/SimpleConnectionDirectory.java @@ -95,30 +95,18 @@ public class SimpleConnectionDirectory @Override public void add(Connection connection) throws GuacamoleException { - - if(connections.containsKey(connection.getIdentifier())) - throw new GuacamoleException("Connection identifier already present."); - - connections.put(connection.getIdentifier(), connection); + throw new GuacamoleSecurityException("Permission denied."); } @Override public void update(Connection connection) throws GuacamoleException { - - if(!connections.containsKey(connection.getIdentifier())) - throw new GuacamoleException("Connection not found."); - - connections.put(connection.getIdentifier(), connection); + throw new GuacamoleSecurityException("Permission denied."); } @Override public void remove(String identifier) throws GuacamoleException { - - if(!connections.containsKey(identifier)) - throw new GuacamoleException("Connection not found."); - - connections.remove(identifier); + throw new GuacamoleSecurityException("Permission denied."); } @Override @@ -126,5 +114,25 @@ public class SimpleConnectionDirectory throws GuacamoleException { throw new GuacamoleSecurityException("Permission denied."); } + + /** + * An internal method for modifying the Connections in this Directory. + * Returns the previous connection for the given identifier, if found. + * + * @param connection The connection to add or update the Directory with. + * @return The previous connection for the connection identifier, if found. + */ + public Connection putConnection(Connection connection) { + return connections.put(connection.getIdentifier(), connection); + } + + /** + * An internal method for removing a Connection from this Directory. + * @param identifier The identifier of the Connection to remove. + * @return The previous connection for the given identifier, if found. + */ + public Connection removeConnection(String identifier) { + return connections.remove(identifier); + } }