summaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/util/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/util/client')
-rw-r--r--src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java68
1 files changed, 55 insertions, 13 deletions
diff --git a/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java b/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java
index ab8acd8..947b558 100644
--- a/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java
+++ b/src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java
@@ -39,6 +39,7 @@ import javax.xml.ws.Service;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.SOAPBinding;
+import org.apache.xpath.XPathAPI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
@@ -55,10 +56,10 @@ import at.gv.util.wsdl.SignatureVerificationService;
import at.gv.util.xsd.moaspss.CreateXMLSignatureRequest;
import at.gv.util.xsd.moaspss.CreateXMLSignatureResponseType;
import at.gv.util.xsd.moaspss.ErrorResponseType;
+import at.gv.util.xsd.moaspss.VerifyCMSSignatureResponseType;
import at.gv.util.xsd.moaspss.VerifyXMLSignatureRequestType;
import at.gv.util.xsd.moaspss.VerifyXMLSignatureResponseType;
-import com.sun.org.apache.xpath.internal.XPathAPI;
import com.sun.xml.ws.developer.JAXWSProperties;
/**
@@ -203,12 +204,61 @@ public class MOASPSSClient {
}
}
+ public VerifyCMSSignatureResponseType sendCMSSignatureVerificationRequest(
+ String serviceURL, InputStream signatureVerificationRequest)
+ throws MOASPSSClientException {
+ log.debug("Verifying CMS signature using raw VerifyXMLSignatureRequest.");
+
+ try {
+ byte[] moaResponse = sendBasicSignatureVerificationRequest(serviceURL, signatureVerificationRequest);
+
+ JAXBContext ctx = JAXBContext
+ .newInstance(VerifyCMSSignatureResponseType.class.getPackage()
+ .getName());
+ JAXBElement<VerifyCMSSignatureResponseType> jaxbElement = (JAXBElement<VerifyCMSSignatureResponseType>) ctx
+ .createUnmarshaller()
+ .unmarshal(new ByteArrayInputStream(moaResponse));
+ VerifyCMSSignatureResponseType verifyXMLResponse = jaxbElement.getValue();
+ log.trace(new String(moaResponse));
+ return verifyXMLResponse;
+
+ } catch (JAXBException e) {
+ throw new MOASPSSClientException(e);
+
+ }
+
+
+ }
+
+
@SuppressWarnings("unchecked")
public VerifyXMLSignatureResponseType sendSignatureVerificationRequest(
String serviceURL, InputStream signatureVerificationRequest)
throws MOASPSSClientException {
log.debug("Verifying XML signature using raw VerifyXMLSignatureRequest.");
+ try {
+ byte[] moaResponse = sendBasicSignatureVerificationRequest(serviceURL, signatureVerificationRequest);
+
+ JAXBContext ctx = JAXBContext
+ .newInstance(VerifyXMLSignatureRequestType.class.getPackage()
+ .getName());
+ JAXBElement<VerifyXMLSignatureResponseType> jaxbElement = (JAXBElement<VerifyXMLSignatureResponseType>) ctx
+ .createUnmarshaller()
+ .unmarshal(new ByteArrayInputStream(moaResponse));
+ VerifyXMLSignatureResponseType verifyXMLResponse = jaxbElement.getValue();
+ log.trace(new String(moaResponse));
+ return verifyXMLResponse;
+
+ } catch (JAXBException e) {
+ throw new MOASPSSClientException(e);
+
+ }
+
+ }
+
+ private byte[] sendBasicSignatureVerificationRequest(String serviceURL, InputStream signatureVerificationRequest)
+ throws MOASPSSClientException {
// check for arguments
if (serviceURL == null) {
throw new NullPointerException("Argument 'serviceURL' must not be null.");
@@ -281,26 +331,18 @@ public class MOASPSSClient {
log.trace("Parsing MOA-SP response.");
byte[] moaResponse = MiscUtil.sourceToByteArray(response);
- JAXBContext ctx = JAXBContext
- .newInstance(VerifyXMLSignatureRequestType.class.getPackage()
- .getName());
- JAXBElement<VerifyXMLSignatureResponseType> jaxbElement = (JAXBElement<VerifyXMLSignatureResponseType>) ctx
- .createUnmarshaller()
- .unmarshal(new ByteArrayInputStream(moaResponse));
- VerifyXMLSignatureResponseType verifyXMLResponse = jaxbElement.getValue();
- log.trace(new String(moaResponse));
- return verifyXMLResponse;
+
+ return moaResponse;
+
} catch (TransformerException e) {
throw new MOASPSSClientException(e);
} catch (IOException e) {
throw new MOASPSSClientException(e);
- } catch (JAXBException e) {
- throw new MOASPSSClientException(e);
} catch (EgovUtilException e) {
throw new MOASPSSClientException(e);
}
}
-
+
public static boolean isSuccess(VerifyXMLSignatureResponseType verifyResult) {
if (verifyResult == null) {
throw new NullPointerException(