diff --git a/cli/pom.xml b/cli/pom.xml
index 6eee3b8..90a38bb 100644
--- a/cli/pom.xml
+++ b/cli/pom.xml
@@ -14,6 +14,11 @@
HSAdmin-Cli
+
+ de.hsadmin
+ framework
+ 1.0-SNAPSHOT
+
org.apache.xmlrpc
xmlrpc-client
diff --git a/cli/src/main/java/de/hsadmin/jscli/RpcClient.java b/cli/src/main/java/de/hsadmin/jscli/RpcClient.java
index 833975d..1ef26cd 100644
--- a/cli/src/main/java/de/hsadmin/jscli/RpcClient.java
+++ b/cli/src/main/java/de/hsadmin/jscli/RpcClient.java
@@ -11,7 +11,8 @@ import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
-import de.hsadmin.jscli.conf.Config;
+import de.hsadmin.common.config.Config;
+import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.jscli.exception.JSCliException;
public class RpcClient {
@@ -37,6 +38,8 @@ public class RpcClient {
}
} catch (MalformedURLException e) {
throw new JSCliException(e);
+ } catch (TechnicalException e) {
+ throw new JSCliException(e);
}
}
diff --git a/cli/src/main/java/de/hsadmin/jscli/cas/CASTicketProvider.java b/cli/src/main/java/de/hsadmin/jscli/cas/CASTicketProvider.java
index 73f5749..66f763a 100644
--- a/cli/src/main/java/de/hsadmin/jscli/cas/CASTicketProvider.java
+++ b/cli/src/main/java/de/hsadmin/jscli/cas/CASTicketProvider.java
@@ -18,8 +18,9 @@ import java.util.Properties;
import javax.net.ssl.HttpsURLConnection;
+import de.hsadmin.common.config.Config;
+import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.jscli.TicketProvider;
-import de.hsadmin.jscli.conf.Config;
import de.hsadmin.jscli.console.PasswordReader;
import de.hsadmin.jscli.exception.JSCliException;
@@ -81,11 +82,11 @@ public class CASTicketProvider implements TicketProvider {
private String getGrantingTicket() throws JSCliException {
grantingTicket = null;
- String password = Config.getInstance().getProperty(user + ".passWord");
- if (password == null || password.length() <= 0) {
- password = readPasswordFromConsole();
- }
try {
+ String password = Config.getInstance().getProperty(user + ".passWord");
+ if (password == null || password.length() <= 0) {
+ password = readPasswordFromConsole();
+ }
String encodedParams = URLEncoder.encode("username", "UTF-8")
+ "=" + URLEncoder.encode(user, "UTF-8")
+ "&" + URLEncoder.encode("password", "UTF-8")
@@ -95,6 +96,8 @@ public class CASTicketProvider implements TicketProvider {
throw new JSCliException(e);
} catch (FileNotFoundException e) {
throw new JSCliException("cas server not available: " + loginURL);
+ } catch (TechnicalException e) {
+ throw new JSCliException(e);
}
return grantingTicket;
}
diff --git a/cli/src/main/java/de/hsadmin/jscli/cas/TicketProviderFactory.java b/cli/src/main/java/de/hsadmin/jscli/cas/TicketProviderFactory.java
index 47691ce..329426e 100644
--- a/cli/src/main/java/de/hsadmin/jscli/cas/TicketProviderFactory.java
+++ b/cli/src/main/java/de/hsadmin/jscli/cas/TicketProviderFactory.java
@@ -1,7 +1,8 @@
package de.hsadmin.jscli.cas;
+import de.hsadmin.common.config.Config;
+import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.jscli.TicketProvider;
-import de.hsadmin.jscli.conf.Config;
import de.hsadmin.jscli.console.PasswordReader;
import de.hsadmin.jscli.exception.JSCliException;
@@ -12,13 +13,18 @@ public class TicketProviderFactory {
public static TicketProvider getInstance(final PasswordReader console, final String user, final String runAs) throws JSCliException
{
- final Config config = Config.getInstance();
- final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
- final String loginURL = config.getProperty("loginURL", HOSTSHARING_LOGIN_URL);
- if ("TestUmgebung".equalsIgnoreCase(loginURL)) {
- return new TestTicketProvider(user, runAs);
- } else {
- return new CASTicketProvider(console, user, runAs, backendURL, loginURL);
+ Config config;
+ try {
+ config = Config.getInstance();
+ final String backendURL = config.getProperty("backendURL", HOSTSHARING_BACKEND_URL);
+ final String loginURL = config.getProperty("loginURL", HOSTSHARING_LOGIN_URL);
+ if ("TestUmgebung".equalsIgnoreCase(loginURL)) {
+ return new TestTicketProvider(user, runAs);
+ } else {
+ return new CASTicketProvider(console, user, runAs, backendURL, loginURL);
+ }
+ } catch (TechnicalException e) {
+ throw new JSCliException(e);
}
}
diff --git a/cli/src/main/java/de/hsadmin/jscli/conf/CommandlineParser.java b/cli/src/main/java/de/hsadmin/jscli/conf/CommandlineParser.java
index b900683..8da6c9a 100644
--- a/cli/src/main/java/de/hsadmin/jscli/conf/CommandlineParser.java
+++ b/cli/src/main/java/de/hsadmin/jscli/conf/CommandlineParser.java
@@ -6,6 +6,8 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
+import de.hsadmin.common.config.Config;
+import de.hsadmin.common.error.TechnicalException;
import de.hsadmin.jscli.exception.JSCliException;
public class CommandlineParser {
@@ -38,13 +40,13 @@ public class CommandlineParser {
}
}
- public String getUser() {
+ public String getUser() throws TechnicalException {
final String systemUser = System.getProperty("user.name");
final String configUser = Config.getInstance().getProperty("userName", systemUser);
return cmd.getOptionValue("user", configUser);
}
- public String getRunAs() {
+ public String getRunAs() throws TechnicalException {
return cmd.getOptionValue("runas", getUser());
}
diff --git a/cli/src/main/java/de/hsadmin/jscli/conf/Config.java b/cli/src/main/java/de/hsadmin/jscli/conf/Config.java
deleted file mode 100644
index 5b24a65..0000000
--- a/cli/src/main/java/de/hsadmin/jscli/conf/Config.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package de.hsadmin.jscli.conf;
-
-import java.io.File;
-import java.io.FileReader;
-import java.util.Properties;
-
-public class Config {
-
- private static Config instance;
-
- private Properties props;
-
- private Config() {
- props = new Properties();
- File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
- if (!file.canRead()) {
- file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
- }
- if (!file.canRead()) {
- file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
- }
- if (!file.canRead()) {
- file = new File("/etc/hsadmin.properties");
- }
- if (!file.canRead()) {
- file = new File("/etc/hsadmin/hsadmin.properties");
- }
- if (file.canRead()) {
- try {
- props.load(new FileReader(file));
- } catch (Exception e) {
- // should not happen
- e.printStackTrace();
- }
- }
- }
-
- public static Config getInstance() {
- if (instance == null) {
- instance = new Config();
- }
- return instance;
- }
-
- public String getProperty(String propertyName) {
- String property = props.getProperty(propertyName);
- if (property == null) {
- return null;
- }
- return property.trim();
- }
-
- public String getProperty(String propertyName, String defaultValue) {
- return props.getProperty(propertyName, defaultValue).trim();
- }
-
-}
diff --git a/web/pom.xml b/web/pom.xml
index fb9d956..059ba5c 100644
--- a/web/pom.xml
+++ b/web/pom.xml
@@ -21,6 +21,12 @@
provided
+
+ de.hsadmin
+ framework
+ 1.0-SNAPSHOT
+
+
org.apache.xmlrpc
xmlrpc-client