From 804dc4bcd6b3b0edbeae3e002727ace91ad77797 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 4 Jul 2014 15:13:57 +0200 Subject: change SZR-GW webservice and MIS-STORK webservice for monitoring --- .../at/gv/util/client/moaspss/MOASPSSClient.java | 68 +++++++++++++++++----- 1 file changed, 55 insertions(+), 13 deletions(-) (limited to 'src/main/java/at/gv/util/client/moaspss/MOASPSSClient.java') 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 jaxbElement = (JAXBElement) 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 jaxbElement = (JAXBElement) 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 jaxbElement = (JAXBElement) 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( -- cgit v1.2.3