diff options
author | Jonathan Bauer | 2015-07-08 16:58:02 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-07-08 16:58:02 +0200 |
commit | 73989b5cd12313d5192601ab453552ee3d26da10 (patch) | |
tree | 505b4c2bad9855aeecbeef4ed8780a6d431bc574 /dozentenmodul/src/main/java/config/Config.java | |
parent | [client] user feedback when login fails. (diff) | |
download | tutor-module-73989b5cd12313d5192601ab453552ee3d26da10.tar.gz tutor-module-73989b5cd12313d5192601ab453552ee3d26da10.tar.xz tutor-module-73989b5cd12313d5192601ab453552ee3d26da10.zip |
[client] implemented login -> disclaimer -> vmwarelicense logic
Diffstat (limited to 'dozentenmodul/src/main/java/config/Config.java')
-rw-r--r-- | dozentenmodul/src/main/java/config/Config.java | 117 |
1 files changed, 50 insertions, 67 deletions
diff --git a/dozentenmodul/src/main/java/config/Config.java b/dozentenmodul/src/main/java/config/Config.java index 97ede10d..cda8dab2 100644 --- a/dozentenmodul/src/main/java/config/Config.java +++ b/dozentenmodul/src/main/java/config/Config.java @@ -56,7 +56,7 @@ public class Config { configPath = appDataPath + "\\bwSuite\\config.ini"; } else { // APPDATA was empty, let's build it ourselves... - LOGGER.warn("APPDATA ist leer."); + LOGGER.warn("APPDATA is empty."); configPath = System.getProperty("user.home") + "\\AppData\\Roaming\\bwSuite\\config.ini"; } @@ -71,15 +71,15 @@ public class Config { if (!(configPath.isEmpty()||configPath == null)) { configFile = new File(configPath); } else { - throw new IOException("Konnte keinen Pfad für die Konfigurationsdatei ermitteln."); + throw new IOException("Could not determine the path to the config file."); } // Check if the directory exists. if (!configFile.getParentFile().exists()) { - LOGGER.info("Ordner " + configFile.getParentFile() + " exisitiert nicht - lege ihn jetzt an."); + LOGGER.info("Folder " + configFile.getParentFile() + " does not exist, creating it."); // Does not, create it if (!configFile.getParentFile().mkdirs()) { - throw new IOException("Konnte '" + configFile.getParentFile() + "' nicht erstellen."); + throw new IOException("Could not create '" + configFile.getParentFile() + "'."); } } @@ -91,153 +91,136 @@ public class Config { // Check if file is writeable if(configFile.canWrite()) { ini = new Wini(configFile); - LOGGER.info("Erzeuge '" + configFile + "'..."); + LOGGER.info("Creating '" + configFile + "'..."); // write default configuration options and values - ini.put("main", "BillOfRights", false); - ini.put("main", "vmware", false); - ini.put("main", "Benutzername speichern", false); - ini.put("main", "Benutzername", ""); - ini.put("main", "Letzter Downloadpfad", ""); - ini.put("main", "Letzter Uploadpfad", ""); - ini.put("main", "IdP", ""); + ini.put("main", "disclaimer_agreement", false); + ini.put("main", "vmware_license_agreement", false); + ini.put("main", "auth_method", ""); + ini.put("main", "username", ""); + ini.put("main", "download_path", ""); + ini.put("main", "upload_path", ""); + ini.put("main", "identity_provider", ""); ini.store(); } else { - throw new IOException("Konnte nicht in '" + configFile + "' schreiben. Haben Sie Rechte dazu?"); + throw new IOException("Can not write to '" + configFile + "'. Do you have permissions?"); } } else { - LOGGER.info("'" + configFile + "' existiert bereits - keine weitere Aktion."); ini = new Wini(configFile); + LOGGER.info("Loaded '" + configFile + "'."); } } // end constructor. /** + * Query the path of the configuration file + * @return path to the configuration file + */ + public static String getPath() { + if (ini.getFile().getParentFile().isDirectory()) + return ini.getFile().getParentFile().toString(); + else + return null; + } + /** * Query the value of 'BillOfRights' from the configuration file. * @return true if the user already accepted bill of rights, false otherwise. */ - public static boolean getBillOfRights() { - return getBoolean("main", "BillOfRights", false); + public static boolean getDisclaimerAgreement() { + return getBoolean("main", "disclaimer_agreement", false); } /** * Query the value of 'vmware' from the configuration file. * @return true if the user already accepted vmware license, false otherwise. */ - public static boolean getVmwareLicense() { - return getBoolean("main", "vmware", false); - } - /** - * Query the value of 'Benutzername speichern' from the configuration file. - * @return true if the username should be saved, false otherwise. - */ - public static boolean getSaveUsername() { - return getBoolean("main", "Benutzername speichern", false); + public static boolean getVmwareLicenseAgreement() { + return getBoolean("main", "vmware_license_agreement", false); } /** * Query the value of 'Benutzername' from the configuration file. * @return username if saved, an empty string otherwise. */ public static String getUsername() { - return getString("main", "Benutzername", ""); + return getString("main", "username", ""); } /** * Query the value of 'Letzter Downloadpfad' from the configuration file. * @return last download path if saved, the path to the user's home otherwise. */ - public static String getLastDownloadPath() { - return getString("main", "Letzter Downloadpfad", System.getProperty("user.home")); + public static String getDownloadPath() { + return getString("main", "download_path", System.getProperty("user.home")); } /** * Query the value of 'Letzter Uploadpfad' from the configuration file. * @return last upload path if saved, the path to the user's home otherwise. */ - public static String getLastUploadPath() { - return getString("main", "Letzter Uploadpfad", System.getProperty("user.home")); - } - - /** - * Query the path of the configuration file - * @return path to the configuration file - */ - public static String getPath() { - if (ini.getFile().getParentFile().isDirectory()) - return ini.getFile().getParentFile().toString(); - else - return null; + public static String getUploadPath() { + return getString("main", "upload_path", System.getProperty("user.home")); } /** * Query the IdP of the configuration file * @return stored IdP */ - public static int getIdP() { - return Integer.parseInt(getString("main", "IdP", "")); + public static String getIdentityProvider() { + return getString("main", "identity_provider", ""); } /** * Query the authentication method of the configuration file * @return stored IdP */ public static String getAuthenticationMethod() { - return getString("main", "authMethod", ""); + return getString("main", "auth_method", "bwlp"); } - - - + /** * Sets the value of 'BillOfRights' in the configuration file to 'value' * @return true if it succeeded, false otherwise */ - public static boolean setBillOfRights(boolean value) { - return setBoolean("main", "BillOfRights", value); + public static boolean setDisclaimerAgreement(boolean value) { + return setBoolean("main", "disclaimer_agreement", value); } /** * Sets the value of 'vmware' in the configuration file to 'value' * @return true if it succeeded, false otherwise */ - public static boolean setVmwareLicense(boolean value) { - return setBoolean("main", "vmware", value); - } - /** - * Sets the value of 'Benutzername speichern' in the configuration file to 'value' - * @return true if it succeeded, false otherwise - */ - public static boolean setSaveUsername(boolean value) { - return setBoolean("main", "Benutzername speichern", value); + public static boolean setVmwareLicenseAgreement(boolean value) { + return setBoolean("main", "vmware_license_agreement", value); } /** * Sets the value of 'Benutzername' in the configuration file to 'value' * @return true if it succeeded, false otherwise */ public static boolean setUsername(String value) { - return setString("main", "Benutzername", value); + return setString("main", "username", value); } /** * Sets the value of 'Letzter Downloadpfad' in the configuration file to 'value' * @return true if it succeeded, false otherwise */ - public static boolean setLastDownloadPath(String value) { - return setString("main", "Letzter Downloadpfad", value); + public static boolean setDownloadPath(String value) { + return setString("main", "download_path", value); } /** * Sets the value of "Letzter Uploadpfad" in the configuration file to 'value' * @return true if it succeeded, false otherwise */ - public static boolean setLastUploadPath(String value) { - return setString("main", "Letzter Uploadpfad", value); + public static boolean setUploadPath(String value) { + return setString("main", "upload_path", value); } /** * Sets the value of "IdP" in the configuration file to 'value' * @return true if it succeeded, false otherwise */ - public static boolean setIdP(String value) { - return setString("main", "IdP", value); + public static boolean setIdentityProvider(String value) { + return setString("main", "identity_provider", value); } /** * Sets the value of the selected authentication method in the configuration file to 'value' * @return true if it succeeded, false otherwise */ public static boolean setAuthenticationMethod(String value) { - return setString("main","authMethod", value); + return setString("main","auth_method", value); } - + /** * Save the changes to the ini file to actual file on the disk. * |