summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml28
-rw-r--r--src/main/java/at/gv/util/client/mis/simple/MISSimpleClient.java25
-rw-r--r--src/main/java/at/gv/util/client/omsp/OMSPClient.java39
-rw-r--r--src/main/java/at/gv/util/client/szr/SZRClient.java5
4 files changed, 71 insertions, 26 deletions
diff --git a/pom.xml b/pom.xml
index 9690c8d..014502b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,6 +11,26 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.owasp</groupId>
+ <artifactId>dependency-check-maven</artifactId>
+ <version>1.2.5</version>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+
<dependencies>
<dependency>
<groupId>xerces</groupId>
@@ -80,11 +100,17 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
- <dependency>
+<!-- <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
+ </dependency> -->
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.3.5</version>
</dependency>
+
</dependencies>
</project>
diff --git a/src/main/java/at/gv/util/client/mis/simple/MISSimpleClient.java b/src/main/java/at/gv/util/client/mis/simple/MISSimpleClient.java
index 34ba951..6886c44 100644
--- a/src/main/java/at/gv/util/client/mis/simple/MISSimpleClient.java
+++ b/src/main/java/at/gv/util/client/mis/simple/MISSimpleClient.java
@@ -9,9 +9,11 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClients;
import org.apache.xpath.XPathAPI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -188,15 +190,16 @@ public class MISSimpleClient {
throw new NullPointerException("Argument request must not be null.");
}
try {
- HttpClient httpclient = new HttpClient();
- PostMethod post = new PostMethod(webServiceURL);
- StringRequestEntity re = new StringRequestEntity(DOMUtils.serializeNode(packIntoSOAP(request)),"text/xml", "UTF-8");
- post.setRequestEntity(re);
- int responseCode = httpclient.executeMethod(post);
- if (responseCode != 200) {
- throw new MISSimpleClientException("Invalid HTTP response code " + responseCode);
+ HttpClient httpclient = HttpClients.createDefault();
+ HttpPost post = new HttpPost(webServiceURL);
+ StringEntity re = new StringEntity(DOMUtils.serializeNode(packIntoSOAP(request)),"text/xml");
+ post.setEntity(re);
+
+ HttpResponse response = httpclient.execute(post);
+ if (response.getStatusLine().getStatusCode() != 200) {
+ throw new MISSimpleClientException("Invalid HTTP response code " + response.getStatusLine().getStatusCode());
}
- return unpackFromSOAP(DOMUtils.parseXmlNonValidating(post.getResponseBodyAsStream()));
+ return unpackFromSOAP(DOMUtils.parseXmlNonValidating(post.getEntity().getContent()));
} catch(IOException e) {
throw new MISSimpleClientException(e);
} catch (TransformerException e) {
diff --git a/src/main/java/at/gv/util/client/omsp/OMSPClient.java b/src/main/java/at/gv/util/client/omsp/OMSPClient.java
index 42ef55a..3cab58e 100644
--- a/src/main/java/at/gv/util/client/omsp/OMSPClient.java
+++ b/src/main/java/at/gv/util/client/omsp/OMSPClient.java
@@ -1,15 +1,21 @@
package at.gv.util.client.omsp;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.HttpClients;
import at.gv.util.MiscUtil;
import at.gv.util.xsd.omsp.SignedStatusResponse;
@@ -19,28 +25,33 @@ public class OMSPClient {
public static SignedStatusResponse checkMandateStatus(String serviceURL, String mandateId, Date date) throws OMSPClientException {
MiscUtil.assertNotNull(serviceURL, "serviceURL");
MiscUtil.assertNotNull(mandateId, "mandateId");
- HttpClient httpclient = new HttpClient();
- GetMethod method = new GetMethod(serviceURL);
- String queryString = mandateId;
+ HttpClient httpclient = HttpClients.createDefault();
+ HttpGet method = new HttpGet(serviceURL);
if (date != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
mandateId += "+" + sdf.format(date);
}
- method.setQueryString(queryString);
try {
- int code = httpclient.executeMethod(method);
- if (code != 200) {
- throw new OMSPClientException("Response code " + code + " returned. Must be 200.");
+ URI uri = new URIBuilder(method.getURI()).addParameter("", mandateId).build();
+ method.setURI(uri);
+
+ HttpResponse response = httpclient.execute(method);
+
+ if (response.getStatusLine().getStatusCode() != 200) {
+ throw new OMSPClientException("Response code " + response.getStatusLine().getStatusCode() + " returned. Must be 200.");
+
}
+
JAXBContext ctx = JAXBContext.newInstance(SignedStatusResponse.class.getPackage().getName());
- return (SignedStatusResponse) ctx.createUnmarshaller().unmarshal(method.getResponseBodyAsStream());
- } catch (HttpException e) {
- throw new OMSPClientException(e);
+ return (SignedStatusResponse) ctx.createUnmarshaller().unmarshal(response.getEntity().getContent());
+
} catch (IOException e) {
throw new OMSPClientException(e);
} catch (JAXBException e) {
throw new OMSPClientException(e);
- }
+ } catch (URISyntaxException e) {
+ throw new OMSPClientException(e);
+ }
}
}
diff --git a/src/main/java/at/gv/util/client/szr/SZRClient.java b/src/main/java/at/gv/util/client/szr/SZRClient.java
index cb98210..97e3d12 100644
--- a/src/main/java/at/gv/util/client/szr/SZRClient.java
+++ b/src/main/java/at/gv/util/client/szr/SZRClient.java
@@ -125,6 +125,11 @@ public class SZRClient {
szrURL = config.getSZRProductionEnvironmentURL();
}
+ if (MiscUtil.isEmpty(szrURL)) {
+ log.info("No SZR service URL found. SZR-Client initalisiation failed.");
+ throw new EgovUtilException("No SZR service URL found. SZR-Client initalisiation failed.");
+ }
+
log.trace("SZR connection URL: " + szrURL);
BindingProvider bindingProvider = (BindingProvider) szr;
Map<String, Object> requestContext = bindingProvider.getRequestContext();