Implemented login through command line arguments

* Moved Config and ConfigItem to data package
* Added mandatory property to ConfigItem
* Added user and password ConfigItems to Config
This commit is contained in:
2020-02-06 22:17:14 +01:00
parent 74715bbf82
commit effe41f458
7 changed files with 91 additions and 27 deletions

View File

@ -11,7 +11,6 @@ import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import envoy.client.Config;
import envoy.client.Settings;
import envoy.client.data.*;
import envoy.client.net.Client;
@ -63,7 +62,7 @@ public class Startup {
// Override configuration values with command line arguments
if (args.length > 0) config.load(args);
// Check if all configuration values have been initialized
// Check if all mandatory configuration values have been initialized
if (!config.isInitialized()) throw new EnvoyException("Server or port are not defined");
} catch (Exception e) {
JOptionPane
@ -76,8 +75,8 @@ public class Startup {
EnvoyLog.setFileLevelBarrier(config.getFileLevelBarrier());
EnvoyLog.setConsoleLevelBarrier(config.getConsoleLevelBarrier());
// Ask the user for their user name and password
LoginCredentials credentials = new LoginDialog().getCredentials();
// Acquire login credentials
LoginCredentials credentials = config.hasLoginCredentials() ? config.getLoginCredentials() : new LoginDialog().getCredentials();
if (credentials == null) {
logger.info("The login process has been aborted by the user. Exiting...");