aboutsummaryrefslogtreecommitdiff
path: root/id/server/moa-id-commons/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/moa-id-commons/src/main/java')
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java2
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigProperty.java95
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/HttpClientWithProxySupport.java61
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java53
-rw-r--r--id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java11
5 files changed, 185 insertions, 37 deletions
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
index a3f445fcf..6efdd6223 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
@@ -152,7 +152,7 @@ public class ConfigurationDBRead {
if (result.size() == 0) {
Logger.trace("No entries found. Create fresh instance.");
- return new MOAIDConfiguration();
+ return null;
}
return (MOAIDConfiguration) result.get(0);
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigProperty.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigProperty.java
new file mode 100644
index 000000000..6e2743b81
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/ConfigProperty.java
@@ -0,0 +1,95 @@
+package at.gv.egovernment.moa.id.commons.db.dao.config;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.Table;
+
+/**
+ * Reflects a MOAID configuration entry.
+ *
+ */
+@Table(name = "configproperty")
+@Entity
+public class ConfigProperty implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @Column(name = "propertyKey", unique = true)
+ private String key;
+
+ @Lob
+ @Column(name = "propertyValue")
+ private String value;
+
+ /**
+ * Returns the property's key.
+ * @return The key.
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * Sets the property's key.
+ * @param key The key
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ /**
+ * Returns the property's value (which might be {@code null}).
+ * @return The property's value (might be {@code null}).
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the property's value.
+ * @param value The value
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((key == null) ? 0 : key.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ConfigProperty other = (ConfigProperty) obj;
+ if (key == null) {
+ if (other.key != null)
+ return false;
+ } else if (!key.equals(other.key))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("ConfigProperty [key=");
+ builder.append(key);
+ builder.append(", value=");
+ builder.append(value);
+ builder.append("]");
+ return builder.toString();
+ }
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/HttpClientWithProxySupport.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/HttpClientWithProxySupport.java
new file mode 100644
index 000000000..733c03bf0
--- /dev/null
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/utils/HttpClientWithProxySupport.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2014 Federal Chancellery Austria
+ * MOA-ID has been developed in a cooperation between BRZ, the Federal
+ * Chancellery Austria - ICT staff unit, and Graz University of Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ */
+package at.gv.egovernment.moa.id.commons.utils;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+/**
+ * @author tlenz
+ *
+ */
+public class HttpClientWithProxySupport {
+
+ public static HttpClient getHttpClient() {
+ HttpClient client = new HttpClient();
+
+ String host = System.getProperty("http.proxyHost"); //$NON-NLS-1$
+ String port = System.getProperty("http.proxyPort"); //$NON-NLS-1$
+ if (MiscUtil.isNotEmpty(host) &&
+ MiscUtil.isNotEmpty(port)) {
+ int p = Integer.parseInt(port);
+ client.getHostConfiguration().setProxy(host, p);
+ Logger.info("Initial HTTPClient with proxy usage. " +
+ "ProxyHost=" + host +
+ " ProxyPort=" + port);
+
+ String user = System.getProperty("http.proxyUser"); //$NON-NLS-1$
+ String pass = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
+ if (MiscUtil.isNotEmpty(user) && pass != null) {
+ client.getState().setProxyCredentials(new AuthScope(host, p),
+ new UsernamePasswordCredentials(user, pass));
+
+ }
+ }
+ return client;
+ }
+}
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java
index be6d7d01e..13d680b78 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/validation/ValidationHelper.java
@@ -44,14 +44,13 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
-import org.apache.log4j.Logger;
+import at.gv.egovernment.moa.logging.Logger;
public class ValidationHelper {
public static final String PUBLICSERVICE_URL_POSTFIX = ".gv.at";
- private static final Logger log = Logger.getLogger(ValidationHelper.class);
private static final String TEMPLATE_DATEFORMAT = "dd.MM.yyyy";
@@ -68,7 +67,7 @@ public class ValidationHelper {
host = host.substring(0, host.length()-1);
if (url.getHost().endsWith(PUBLICSERVICE_URL_POSTFIX)) {
- log.debug("PublicURLPrefix with .gv.at Domain found.");
+ Logger.debug("PublicURLPrefix with .gv.at Domain found.");
return true;
} else {
@@ -95,7 +94,7 @@ public class ValidationHelper {
return false;
} else {
- log.info("Found correct X509 Extension in server certificate. PublicService is allowed");
+ Logger.info("Found correct X509 Extension in server certificate. PublicService is allowed");
return true;
}
}
@@ -104,27 +103,27 @@ public class ValidationHelper {
}
} catch (MalformedURLException e) {
- log.warn("PublicURLPrefix can not parsed to URL", e);
+ Logger.warn("PublicURLPrefix can not parsed to URL", e);
return false;
} catch (UnknownHostException e) {
- log.warn("Can not connect to PublicURLPrefix Server", e);
+ Logger.warn("Can not connect to PublicURLPrefix Server", e);
return false;
} catch (IOException e) {
- log.warn("Can not connect to PublicURLPrefix Server", e);
+ Logger.warn("Can not connect to PublicURLPrefix Server", e);
return false;
} catch (CertificateEncodingException e) {
- log.warn("Can not parse X509 server certificate", e);
+ Logger.warn("Can not parse X509 server certificate", e);
return false;
} catch (CertificateException e) {
- log.warn("Can not read X509 server certificate", e);
+ Logger.warn("Can not read X509 server certificate", e);
return false;
} catch (X509ExtensionInitException e) {
- log.warn("Can not read X509 server certificate extension", e);
+ Logger.warn("Can not read X509 server certificate extension", e);
return false;
}
@@ -133,7 +132,7 @@ public class ValidationHelper {
try {
socket.close();
} catch (IOException e) {
- log.warn("SSL Socket can not be closed.", e);
+ Logger.warn("SSL Socket can not be closed.", e);
}
}
}
@@ -148,7 +147,7 @@ public class ValidationHelper {
return true;
} catch (Throwable t) {
- log.warn("No valid DataBase OAID received! " + oaIDObj);
+ Logger.warn("No valid DataBase OAID received! " + oaIDObj);
}
}
return false;
@@ -156,7 +155,7 @@ public class ValidationHelper {
public static boolean validateNumber(String value) {
- log.debug("Validate Number " + value);
+ Logger.debug("Validate Number " + value);
try {
Float.valueOf(value);
@@ -171,7 +170,7 @@ public class ValidationHelper {
}
public static boolean validatePhoneNumber(String value) {
- log.debug ("Validate PhoneNumber " + value);
+ Logger.debug ("Validate PhoneNumber " + value);
/* ************************************************************************************************
* Legende:
@@ -187,11 +186,11 @@ public class ValidationHelper {
Matcher matcher = pattern.matcher(value);
boolean b = matcher.matches();
if (b) {
- log.debug("Parameter PhoneNumber erfolgreich ueberprueft");
+ Logger.debug("Parameter PhoneNumber erfolgreich ueberprueft");
return true;
}
else {
- log.error("Fehler Ueberpruefung Parameter PhoneNumber. PhoneNumber entspricht nicht den Kriterien ^ [a-zA-Z .,;:/\\-]* [ ]* [(]{0,1}[ ]*[+]{0,1}[ ]*[0-9]{0,2}[ ]*[)]{0,1} [ ]* [0-9]*[ ]*[/\\-]{0,1} [ ]*[ ]* [0-9]* [ ]* [a-zA-Z .,;:\\/-]* $");
+ Logger.error("Fehler Ueberpruefung Parameter PhoneNumber. PhoneNumber entspricht nicht den Kriterien ^ [a-zA-Z .,;:/\\-]* [ ]* [(]{0,1}[ ]*[+]{0,1}[ ]*[0-9]{0,2}[ ]*[)]{0,1} [ ]* [0-9]*[ ]*[/\\-]{0,1} [ ]*[ ]* [0-9]* [ ]* [a-zA-Z .,;:\\/-]* $");
return false;
}
@@ -200,7 +199,7 @@ public class ValidationHelper {
public static boolean validateURL(String urlString) {
- log.debug("Validate URL " + urlString);
+ Logger.debug("Validate URL " + urlString);
if (urlString.startsWith("http") || urlString.startsWith("https")) {
try {
@@ -216,7 +215,7 @@ public class ValidationHelper {
// public static boolean validateGeneralURL(String urlString) {
//
-// log.debug("Validate URL " + urlString);
+// Logger.debug("Validate URL " + urlString);
//
// try {
// new URL(urlString);
@@ -231,17 +230,17 @@ public class ValidationHelper {
public static boolean isValidAdminTarget(String target) {
- log.debug("Ueberpruefe Parameter Target");
+ Logger.debug("Ueberpruefe Parameter Target");
Pattern pattern = Pattern.compile("[a-zA-Z-]{1,5}");
Matcher matcher = pattern.matcher(target);
boolean b = matcher.matches();
if (b) {
- log.debug("Parameter SSO-Target erfolgreich ueberprueft. SSO Target is PublicService.");
+ Logger.debug("Parameter SSO-Target erfolgreich ueberprueft. SSO Target is PublicService.");
return true;
}
else {
- log.info("Parameter SSO-Target entspricht nicht den Kriterien " +
+ Logger.info("Parameter SSO-Target entspricht nicht den Kriterien " +
"(nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang) fuer den oeffentlichen Bereich. " +
"Valiere SSO-Target fuer privatwirtschaftliche Bereiche.");
return false;
@@ -250,14 +249,14 @@ public class ValidationHelper {
public static boolean isValidTarget(String target) {
- log.debug("Ueberpruefe Parameter Target");
+ Logger.debug("Ueberpruefe Parameter Target");
if (TargetValidator.isValidTarget(target)) {
- log.debug("Parameter Target erfolgreich ueberprueft");
+ Logger.debug("Parameter Target erfolgreich ueberprueft");
return true;
}
else {
- log.error("Fehler Ueberpruefung Parameter Target. Target entspricht nicht den Kriterien (nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang)");
+ Logger.error("Fehler Ueberpruefung Parameter Target. Target entspricht nicht den Kriterien (nur Zeichen a-z, A-Z und -, sowie 1-5 Zeichen lang)");
return false;
}
@@ -265,17 +264,17 @@ public class ValidationHelper {
public static boolean isValidSourceID(String sourceID) {
- log.debug("Ueberpruefe Parameter sourceID");
+ Logger.debug("Ueberpruefe Parameter sourceID");
Pattern pattern = Pattern.compile("[\\w-_]{1,20}");
Matcher matcher = pattern.matcher(sourceID);
boolean b = matcher.matches();
if (b) {
- log.debug("Parameter sourceID erfolgreich ueberprueft");
+ Logger.debug("Parameter sourceID erfolgreich ueberprueft");
return true;
}
else {
- log.error("Fehler Ueberpruefung Parameter sourceID. SourceID entspricht nicht den Kriterien (nur Zeichen a-z, A-Z, - und _, sowie 1-20 Zeichen lang)");
+ Logger.error("Fehler Ueberpruefung Parameter sourceID. SourceID entspricht nicht den Kriterien (nur Zeichen a-z, A-Z, - und _, sowie 1-20 Zeichen lang)");
return false;
}
}
diff --git a/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java b/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java
index e4aa6a284..758209193 100644
--- a/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java
+++ b/id/server/moa-id-commons/src/main/java/org/apache/commons/httpclient/MOAHttpClient.java
@@ -26,15 +26,8 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodDirector;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.URI;
import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException;
@@ -47,7 +40,7 @@ import at.gv.egovernment.moa.id.commons.ex.MOAHttpProtocolSocketFactoryException
public class MOAHttpClient extends HttpClient {
- public void setCustomSSLTrustStore(String metadataURL, SecureProtocolSocketFactory protoSocketFactory) throws MOAHttpProtocolSocketFactoryException, MalformedURLException {
+ public void setCustomSSLTrustStore(String metadataURL, ProtocolSocketFactory protoSocketFactory) throws MOAHttpProtocolSocketFactoryException, MalformedURLException {
;
URL url = new URL(metadataURL);