mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 00:53:21 +00:00 
			
		
		
		
	Ticket #269: More cleanup.
This commit is contained in:
		| @@ -1,3 +1,6 @@ | |||||||
|  |  | ||||||
|  | package net.sourceforge.guacamole.net.auth.mysql; | ||||||
|  |  | ||||||
| /* ***** BEGIN LICENSE BLOCK ***** | /* ***** BEGIN LICENSE BLOCK ***** | ||||||
|  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||||||
|  * |  * | ||||||
| @@ -33,7 +36,6 @@ | |||||||
|  * the terms of any one of the MPL, the GPL or the LGPL. |  * the terms of any one of the MPL, the GPL or the LGPL. | ||||||
|  * |  * | ||||||
|  * ***** END LICENSE BLOCK ***** */ |  * ***** END LICENSE BLOCK ***** */ | ||||||
| package net.sourceforge.guacamole.net.auth.mysql; |  | ||||||
|  |  | ||||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| @@ -46,6 +48,7 @@ import net.sourceforge.guacamole.net.auth.mysql.model.ConnectionHistory; | |||||||
| import net.sourceforge.guacamole.net.auth.mysql.utility.ProviderUtility; | import net.sourceforge.guacamole.net.auth.mysql.utility.ProviderUtility; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  |  * A ConnectionRecord which is based on data stored in MySQL. | ||||||
|  * |  * | ||||||
|  * @author James Muehlner |  * @author James Muehlner | ||||||
|  */ |  */ | ||||||
| @@ -56,18 +59,30 @@ public class MySQLConnectionRecord implements ConnectionRecord { | |||||||
|      */ |      */ | ||||||
|     private ConnectionHistory connectionHistory; |     private ConnectionHistory connectionHistory; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * DAO for accessing users. | ||||||
|  |      */ | ||||||
|     @Inject |     @Inject | ||||||
|     UserMapper userDAO; |     UserMapper userDAO; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * DAO for accessing connections. | ||||||
|  |      */ | ||||||
|     @Inject |     @Inject | ||||||
|     ConnectionMapper connectionDAO; |     ConnectionMapper connectionDAO; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Service for creating and retrieving objects. | ||||||
|  |      */ | ||||||
|     @Inject |     @Inject | ||||||
|     ProviderUtility providerUtility; |     ProviderUtility providerUtility; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Initialize this MySQLConnectionRecord with the database record it represents. |      * Initialize this MySQLConnectionRecord with the database record it | ||||||
|      * @param connectionHistory |      * represents. | ||||||
|  |      * | ||||||
|  |      * @param connectionHistory The ConnectionHistory entry from the database | ||||||
|  |      *                          corresponding to this connection record. | ||||||
|      */ |      */ | ||||||
|     public void init(ConnectionHistory connectionHistory) { |     public void init(ConnectionHistory connectionHistory) { | ||||||
|         this.connectionHistory = connectionHistory; |         this.connectionHistory = connectionHistory; | ||||||
| @@ -95,7 +110,7 @@ public class MySQLConnectionRecord implements ConnectionRecord { | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean isActive() { |     public boolean isActive() { | ||||||
|         // if the end date hasn't been stored yet, the connection is still open. |         // If the end date hasn't been stored yet, the connection is still open. | ||||||
|         return connectionHistory.getEnd_date() == null; |         return connectionHistory.getEnd_date() == null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,3 +1,6 @@ | |||||||
|  |  | ||||||
|  | package net.sourceforge.guacamole.net.auth.mysql.utility; | ||||||
|  |  | ||||||
| /* ***** BEGIN LICENSE BLOCK ***** | /* ***** BEGIN LICENSE BLOCK ***** | ||||||
|  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |  * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | ||||||
|  * |  * | ||||||
| @@ -33,7 +36,6 @@ | |||||||
|  * the terms of any one of the MPL, the GPL or the LGPL. |  * the terms of any one of the MPL, the GPL or the LGPL. | ||||||
|  * |  * | ||||||
|  * ***** END LICENSE BLOCK ***** */ |  * ***** END LICENSE BLOCK ***** */ | ||||||
| package net.sourceforge.guacamole.net.auth.mysql.utility; |  | ||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| @@ -48,39 +50,59 @@ import net.sourceforge.guacamole.protocol.GuacamoleConfiguration; | |||||||
| public class ConfigurationTranslationUtility { | public class ConfigurationTranslationUtility { | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Get a GuacamoleConfiguration based on the provided protocol and parameters. |      * Get a GuacamoleConfiguration based on the provided protocol and | ||||||
|      * @param protocol the protocol used (VNC, RDP, etc) |      * parameters. | ||||||
|      * @param parameters the parameter database records to translate |      * | ||||||
|      * @return |      * @param protocol The protocol used (VNC, RDP, etc) | ||||||
|  |      * @param parameters The parameter database records to translate | ||||||
|  |      * @return A new GuacamoleConfiguration based on the given protocol and | ||||||
|  |      *         parameters. | ||||||
|      */ |      */ | ||||||
|     public GuacamoleConfiguration getConfiguration(String protocol, Iterable<ConnectionParameter> parameters) { |     public GuacamoleConfiguration getConfiguration(String protocol, | ||||||
|  |             Iterable<ConnectionParameter> parameters) { | ||||||
|  |  | ||||||
|  |         // Create new configuration, set protocol | ||||||
|         GuacamoleConfiguration configuration = new GuacamoleConfiguration(); |         GuacamoleConfiguration configuration = new GuacamoleConfiguration(); | ||||||
|         configuration.setProtocol(protocol); |         configuration.setProtocol(protocol); | ||||||
|  |  | ||||||
|         for(ConnectionParameter parameter : parameters) { |         // Copy parameters from given parameters | ||||||
|  |         for(ConnectionParameter parameter : parameters) | ||||||
|             configuration.setParameter(parameter.getParameter_name(), parameter.getParameter_value()); |             configuration.setParameter(parameter.getParameter_name(), parameter.getParameter_value()); | ||||||
|         } |  | ||||||
|  |  | ||||||
|         return configuration; |         return configuration; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Creates a list of ConnectionParameter database records based on the provided connectionID and GuacamoleConfiguration. |      * Creates a list of ConnectionParameter database records based on the | ||||||
|      * @param connectionID the ID of the connection that these parameters are for |      * provided connectionID and GuacamoleConfiguration. | ||||||
|      * @param configuration the configuration to pull the parameter values from |      * | ||||||
|      * @return |      * @param connectionID The ID of the connection that these parameters are | ||||||
|  |      *                     for. | ||||||
|  |      * @param configuration The configuration to pull the parameter values from. | ||||||
|  |      * @return A list of ConnectionParameter database records. | ||||||
|      */ |      */ | ||||||
|     public List<ConnectionParameter> getConnectionParameters(int connectionID, GuacamoleConfiguration configuration) { |     public List<ConnectionParameter> getConnectionParameters(int connectionID, | ||||||
|         List<ConnectionParameter> connectionParameters = new ArrayList<ConnectionParameter>(); |             GuacamoleConfiguration configuration) { | ||||||
|  |  | ||||||
|         for(String parameterName : configuration.getParameterNames()) { |         List<ConnectionParameter> connectionParameters = | ||||||
|             ConnectionParameter connectionParameter = new ConnectionParameter(); |                 new ArrayList<ConnectionParameter>(); | ||||||
|  |  | ||||||
|  |         // Each connection parameter in the given configuration, create | ||||||
|  |         // a corresponding database record | ||||||
|  |         for (String parameterName : configuration.getParameterNames()) { | ||||||
|  |  | ||||||
|  |             // Get value of parameter | ||||||
|             String parameterValue = configuration.getParameter(parameterName); |             String parameterValue = configuration.getParameter(parameterName); | ||||||
|  |  | ||||||
|  |             // Create corresponding ConnectionParameter | ||||||
|  |             ConnectionParameter connectionParameter = new ConnectionParameter(); | ||||||
|             connectionParameter.setConnection_id(connectionID); |             connectionParameter.setConnection_id(connectionID); | ||||||
|             connectionParameter.setParameter_name(parameterName); |             connectionParameter.setParameter_name(parameterName); | ||||||
|             connectionParameter.setParameter_value(parameterValue); |             connectionParameter.setParameter_value(parameterValue); | ||||||
|  |  | ||||||
|  |             // Add parameter to list | ||||||
|             connectionParameters.add(connectionParameter); |             connectionParameters.add(connectionParameter); | ||||||
|  |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return connectionParameters; |         return connectionParameters; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user