From 001161aec7e42825c21fc969cac45f77da31fb86 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 12:09:52 +0100 Subject: raise the SOAP request --- .../stork2/EHvdAttributeProviderPlugin.java | 60 +++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java index 7dc4b8ac1..42652464b 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java @@ -1,7 +1,22 @@ package at.gv.egovernment.moa.id.protocols.stork2; +import java.util.ArrayList; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.soap.MessageFactory; +import javax.xml.soap.SOAPBody; +import javax.xml.soap.SOAPConnection; +import javax.xml.soap.SOAPConnectionFactory; +import javax.xml.soap.SOAPElement; +import javax.xml.soap.SOAPEnvelope; +import javax.xml.soap.SOAPMessage; +import javax.xml.soap.SOAPPart; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -14,8 +29,16 @@ import eu.stork.peps.auth.commons.PersonalAttributeList; */ public class EHvdAttributeProviderPlugin implements AttributeProvider { + /** The destination. */ + private Object destination; + + /** + * Instantiates a new e hvd attribute provider plugin. + * + * @param url the service url + */ public EHvdAttributeProviderPlugin(String url) { - // TODO Auto-generated constructor stub + destination = url; } /* (non-Javadoc) @@ -27,15 +50,48 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { ExternalAttributeRequestRequiredException { // break when we cannot handle the requested attribute - if(!attributes.getFriendlyName().equals("isHealthcareProfessional")) + if(!attributes.getFriendlyName().equals("isHCP")) throw new UnsupportedAttributeException(); try { // create SOAP connection + SOAPConnection soapConnection = SOAPConnectionFactory.newInstance().createConnection(); // assemble SOAP request + MessageFactory messageFactory = MessageFactory.newInstance(); + SOAPMessage requestMessage = messageFactory.createMessage(); + SOAPPart requestPart = requestMessage.getSOAPPart(); + + // (soap 1.1 relevant part. could not find a solution to use soap 1.2 in time. + requestMessage.getMimeHeaders().setHeader("SOAPAction", "http://gesundheit.gv.at/BAGDAD/DataAccessService/IsHealthcareProfessional"); + + /* + Construct SOAP Request Message: + + + + string + + + + see https://stork.ehealth.gv.at/GDAService.asmx?op=IsHealthcareProfessional + */ + + // SOAP Envelope + SOAPEnvelope envelope = requestPart.getEnvelope(); + + // SOAP Body + SOAPBody requestBody = envelope.getBody(); + SOAPElement requestBodyElem = requestBody.addChildElement("IsHealthcareProfessional"); + SOAPElement requestBodyElem1 = requestBodyElem.addChildElement("bPK"); + // TODO fetch bpk_gh from somewhere + requestBodyElem1.addTextNode("bpk_gh"); + + requestMessage.saveChanges(); + // perform SOAP call + SOAPMessage responseMessage = soapConnection.call(requestMessage, destination); // parse SOAP response -- cgit v1.2.3