From 1aa6fd1a5b007a9c234e096e6d145cb0235cfd70 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 09:34:59 +0100 Subject: init eHvd AP Plugin --- .../protocols/stork2/AttributeProviderFactory.java | 8 ++-- .../stork2/EHvdAttributeProviderPlugin.java | 50 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java (limited to 'id') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java index 98d354e8a..23edf69f9 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java @@ -18,6 +18,7 @@ public class AttributeProviderFactory { public static List getAvailablePlugins() { List result = new ArrayList(); result.add("StorkAttributeRequestProvider"); + result.add("EHvdAttributeProvider"); return result; } @@ -31,10 +32,11 @@ public class AttributeProviderFactory { * @return the attribute provider */ public static AttributeProvider create(String shortname, String url) { - switch (shortname) { - case "StorkAttributeRequestProvider": + if (shortname.equals("StorkAttributeRequestProvider")) { return new StorkAttributeRequestProvider(url); - default: + } else if(shortname.equals("EHvdAttributeProvider")) { + return new EHvdAttributeProviderPlugin(url); + } else { return null; } } 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 new file mode 100644 index 000000000..8783026c2 --- /dev/null +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java @@ -0,0 +1,50 @@ +package at.gv.egovernment.moa.id.protocols.stork2; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import at.gv.egovernment.moa.id.auth.exception.MOAIDException; +import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; +import eu.stork.peps.auth.commons.IPersonalAttributeList; +import eu.stork.peps.auth.commons.PersonalAttribute; + +/** + * Fetches the attribute IsHealthcareProfessional from the BAGDAD SOAP service + */ +public class EHvdAttributeProviderPlugin implements AttributeProvider { + + public EHvdAttributeProviderPlugin(String url) { + // TODO Auto-generated constructor stub + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(eu.stork.peps.auth.commons.PersonalAttribute) + */ + @Override + public IPersonalAttributeList acquire(PersonalAttribute attributes) + throws UnsupportedAttributeException, + ExternalAttributeRequestRequiredException { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#performRedirect(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, at.gv.egovernment.moa.id.config.auth.OAAuthParameter) + */ + @Override + public void performRedirect(String url, String citizenCountyCode, + HttpServletRequest req, HttpServletResponse resp, + OAAuthParameter oaParam) throws MOAIDException { + // there is no redirect required + } + + /* (non-Javadoc) + * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#parse(javax.servlet.http.HttpServletRequest) + */ + @Override + public IPersonalAttributeList parse(HttpServletRequest httpReq) + throws UnsupportedAttributeException, MOAIDException { + // TODO Auto-generated method stub + return null; + } +} -- cgit v1.2.3 From 2b655368aa6bfb7a0250589a23b2ac328b25c5aa Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 09:36:39 +0100 Subject: disable parse and redirect functionality of eHVD ap plugin --- .../moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'id') 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 8783026c2..8813ec8dc 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 @@ -44,7 +44,7 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { @Override public IPersonalAttributeList parse(HttpServletRequest httpReq) throws UnsupportedAttributeException, MOAIDException { - // TODO Auto-generated method stub - return null; + // there is no redirect required, so we throw an exception when someone asks us to parse a response + throw new UnsupportedAttributeException(); } } -- cgit v1.2.3 From b7a64411283c5a5496383164ced201ef42eb3d63 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 09:46:41 +0100 Subject: sketched communication process --- .../stork2/EHvdAttributeProviderPlugin.java | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'id') 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 8813ec8dc..28f5b23a3 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 @@ -7,6 +7,7 @@ import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import eu.stork.peps.auth.commons.IPersonalAttributeList; import eu.stork.peps.auth.commons.PersonalAttribute; +import eu.stork.peps.auth.commons.PersonalAttributeList; /** * Fetches the attribute IsHealthcareProfessional from the BAGDAD SOAP service @@ -24,8 +25,28 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { public IPersonalAttributeList acquire(PersonalAttribute attributes) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException { - // TODO Auto-generated method stub - return null; + + try { + // create SOAP connection + + // assemble SOAP request + + // perform SOAP call + + // parse SOAP response + + // assemble attribute + PersonalAttribute acquiredAttribute = new PersonalAttribute(); + + // pack and return the result + PersonalAttributeList result = new PersonalAttributeList(); + result.add(acquiredAttribute); + + return result; + } catch (Exception e) { + // TODO in case of an error, we might want to inform someone somehow different than by just saying nothing + return null; + } } /* (non-Javadoc) -- cgit v1.2.3 From 2f4f739506a1f054c0fbb3f28e97e1c13f798758 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 10:02:16 +0100 Subject: report an attribute request that is not supported by eHVD AP plugin --- .../moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'id') 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 28f5b23a3..7dc4b8ac1 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 @@ -26,6 +26,10 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException { + // break when we cannot handle the requested attribute + if(!attributes.getFriendlyName().equals("isHealthcareProfessional")) + throw new UnsupportedAttributeException(); + try { // create SOAP connection -- cgit v1.2.3 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') 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 From 5dd5959e9ddd730452d0007fbf2c091d2c2506e1 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 13:54:44 +0100 Subject: parse the SOAP response --- .../stork2/EHvdAttributeProviderPlugin.java | 143 +++++++++++++++++---- 1 file changed, 117 insertions(+), 26 deletions(-) (limited to 'id') 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 42652464b..fdf0806b8 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,10 +1,13 @@ package at.gv.egovernment.moa.id.protocols.stork2; +import java.io.StringWriter; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; 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; @@ -14,6 +17,12 @@ import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPEnvelope; import javax.xml.soap.SOAPMessage; import javax.xml.soap.SOAPPart; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -58,13 +67,13 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { 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"); - + 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: @@ -74,34 +83,116 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { - + see https://stork.ehealth.gv.at/GDAService.asmx?op=IsHealthcareProfessional */ - // SOAP Envelope - SOAPEnvelope envelope = requestPart.getEnvelope(); + // 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"); - // 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(); - requestMessage.saveChanges(); - // perform SOAP call - SOAPMessage responseMessage = soapConnection.call(requestMessage, destination); - + SOAPMessage responseMessage = soapConnection.call(requestMessage, destination); + // parse SOAP response - - // assemble attribute - PersonalAttribute acquiredAttribute = new PersonalAttribute(); - + + /* + + + + + boolean + string + boolean + string + string + string + + + + + + see https://stork.ehealth.gv.at/GDAService.asmx?op=IsHealthcareProfessional + */ + SOAPBody responseBody = responseMessage.getSOAPBody(); + + // iterate through tree + SOAPElement responseElement = (SOAPElement) responseBody.getChildElements().next(); + SOAPElement resultElement = (SOAPElement) responseElement.getChildElements().next(); + SOAPElement tmp; + + // collect all info in a map + Iterator it = resultElement.getChildElements(); + Map collection = new HashMap(); + while (it.hasNext()) { + SOAPElement current = (SOAPElement) it.next(); + + collection.put(current.getNodeName(), current.getTextContent()); + + } + + // check if there is anything valid in the map + if (collection.isEmpty() || collection.size() != 6) { + // TODO report error + } + + // - fetch request validity + if (collection.get("RequestOK").equals("false")) { + // TODO report error + } + + PersonalAttribute acquiredAttribute = null; + + if (collection.get("IsHealthcareProfessional").equals("false")) { + // the citizen is no HCP + acquiredAttribute = new PersonalAttribute("isHCP", false, new ArrayList(), "NotAvailable"); + } else { + // go on and parse the data + + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); + + Element orgname = doc.createElement("nameOfOrganisation"); + orgname.appendChild(doc.createTextNode(collection.get("NameOfOrganization"))); + doc.appendChild(orgname); + + Element type = doc.createElement("HCP"); + // TODO fix value mapping + if (collection.get("Type").equals("Medical Doctors")) + type.appendChild(doc.createTextNode("D")); + doc.appendChild(type); + + Element specialization = doc.createElement("specialisation"); + // TODO fix value mapping + specialization.appendChild(doc.createTextNode(collection.get("Specialization").substring(0, 2))); + doc.appendChild(specialization); + + // get string from dom tree + Source source = new DOMSource(doc); + StringWriter out = new StringWriter(); + Result result = new StreamResult(out); + + TransformerFactory tFactory = TransformerFactory.newInstance(); + Transformer transformer = tFactory.newTransformer(); + transformer.transform(source, result); + + ArrayList value = new ArrayList(); + value.add(out.toString()); + + acquiredAttribute = new PersonalAttribute("isHCP", false, value, "Available"); + } + // pack and return the result PersonalAttributeList result = new PersonalAttributeList(); result.add(acquiredAttribute); - + return result; } catch (Exception e) { // TODO in case of an error, we might want to inform someone somehow different than by just saying nothing -- cgit v1.2.3 From 02800dff9580924a9b912ca9f2ff56c9a40d2152 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 14:06:36 +0100 Subject: error handling --- .../moa/id/protocols/stork2/AttributeCollector.java | 3 +++ .../moa/id/protocols/stork2/AttributeProvider.java | 2 +- .../id/protocols/stork2/EHvdAttributeProviderPlugin.java | 15 ++++++++------- .../resources/properties/id_messages_de.properties | 1 + 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'id') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java index 937f6da74..f36232eb9 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java @@ -113,6 +113,9 @@ public class AttributeCollector implements IAction { container.getResponse().getPersonalAttributeList().add(current); } catch(UnsupportedAttributeException e) { // ok, try the next attributeprovider + } catch(MOAIDException e) { + // the current plugin had an error. Try the next one. + // TODO we might want to add the non-fetchable attribute as "NotAvailable" to prevent an infinite loop } } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java index adf57d77b..9e6cba923 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java @@ -25,7 +25,7 @@ public interface AttributeProvider { * @throws UnsupportedAttributeException the unsupported attribute exception * @throws ExternalAttributeRequestRequiredException an attribute request to an external service has to be done */ - public IPersonalAttributeList acquire(PersonalAttribute attributes) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException; + public IPersonalAttributeList acquire(PersonalAttribute attributes) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException; /** * Perform redirect. 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 fdf0806b8..474dcb8fa 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 @@ -29,6 +29,7 @@ import org.w3c.dom.Element; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; +import at.gv.egovernment.moa.logging.Logger; import eu.stork.peps.auth.commons.IPersonalAttributeList; import eu.stork.peps.auth.commons.PersonalAttribute; import eu.stork.peps.auth.commons.PersonalAttributeList; @@ -56,8 +57,8 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { @Override public IPersonalAttributeList acquire(PersonalAttribute attributes) throws UnsupportedAttributeException, - ExternalAttributeRequestRequiredException { - + ExternalAttributeRequestRequiredException, MOAIDException { + // break when we cannot handle the requested attribute if(!attributes.getFriendlyName().equals("isHCP")) throw new UnsupportedAttributeException(); @@ -136,17 +137,18 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { SOAPElement current = (SOAPElement) it.next(); collection.put(current.getNodeName(), current.getTextContent()); - } // check if there is anything valid in the map if (collection.isEmpty() || collection.size() != 6) { - // TODO report error + Logger.warn("eHVD returned an unexpected count of values. Expected 6 got " + collection.size()); + throw new IndexOutOfBoundsException("response attributes not like specified"); } // - fetch request validity if (collection.get("RequestOK").equals("false")) { - // TODO report error + Logger.warn("eHVD reported an invalid request. The error message is: " + collection.get("Message")); + throw new Exception("eHVD reported an invalid request"); } PersonalAttribute acquiredAttribute = null; @@ -195,8 +197,7 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { return result; } catch (Exception e) { - // TODO in case of an error, we might want to inform someone somehow different than by just saying nothing - return null; + throw new MOAIDException("stork.13", new Object[] { e }); } } diff --git a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties index 0e252e981..4007eacdc 100644 --- a/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties +++ b/id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties @@ -207,6 +207,7 @@ stork.09=Fehler beim \u00FCberpr\u00FCfen der STORK B\u00FCrgerInnen Signatur stork.10=Fehler in der Verbindung zum SZR-Gateway stork.11=Fehler beim Sammeln von StorkAttributen stork.12=Konnte keine VIDP Konfiguration finden +stork.13=Fehler beim Sammeln eines Attributes in einem AttributProviderPlugin pvp2.00={0} ist kein gueltiger consumer service index pvp2.01=Fehler beim kodieren der PVP2 Antwort -- cgit v1.2.3 From 03952b60036874105f8d5575ca2d06594e70c759 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Wed, 26 Feb 2014 15:05:27 +0100 Subject: use appropriate PK in eHVD AP plugin --- .../gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java | 6 +++--- .../gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java | 5 ++++- .../moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java | 3 ++- .../moa/id/protocols/stork2/DemoRedirectAttributeProvider.java | 3 ++- .../moa/id/protocols/stork2/EHvdAttributeProviderPlugin.java | 7 +++---- .../moa/id/protocols/stork2/StorkAttributeRequestProvider.java | 3 ++- 6 files changed, 16 insertions(+), 11 deletions(-) (limited to 'id') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java index f36232eb9..b7fa37757 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java @@ -79,7 +79,7 @@ public class AttributeCollector implements IAction { container.getResponse().getPersonalAttributeList().add(current); // see if we need some more attributes - return processRequest(container, httpReq, httpResp, oaParam); + return processRequest(container, httpReq, httpResp, moasession, oaParam); } /** @@ -90,7 +90,7 @@ public class AttributeCollector implements IAction { * @return the string * @throws MOAIDException */ - public String processRequest(DataContainer container, HttpServletRequest request, HttpServletResponse response, OAAuthParameter oaParam) throws MOAIDException { + public String processRequest(DataContainer container, HttpServletRequest request, HttpServletResponse response, AuthenticationSession moasession, OAAuthParameter oaParam) throws MOAIDException { // check if there are attributes we need to fetch IPersonalAttributeList requestAttributeList = container.getRequest().getPersonalAttributeList(); IPersonalAttributeList responseAttributeList = container.getResponse().getPersonalAttributeList(); @@ -106,7 +106,7 @@ public class AttributeCollector implements IAction { for (AttributeProvider currentProvider : AttributeProviderFactory.getConfiguredPlugins(oaParam.getStorkAPs())) { try { // - hand over control to the suitable plugin - IPersonalAttributeList aquiredAttributes = currentProvider.acquire(currentAttribute); + IPersonalAttributeList aquiredAttributes = currentProvider.acquire(currentAttribute, moasession); // - add the aquired attribute to the container for(PersonalAttribute current : aquiredAttributes) diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java index 9e6cba923..59376fef6 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProvider.java @@ -3,6 +3,7 @@ package at.gv.egovernment.moa.id.protocols.stork2; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -21,11 +22,13 @@ public interface AttributeProvider { * the response. * * @param attributes the list of attributes to be acquired + * @param moasession the moasession * @return the personal attribute * @throws UnsupportedAttributeException the unsupported attribute exception * @throws ExternalAttributeRequestRequiredException an attribute request to an external service has to be done + * @throws MOAIDException the mOAID exception */ - public IPersonalAttributeList acquire(PersonalAttribute attributes) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException; + public IPersonalAttributeList acquire(PersonalAttribute attributes, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException; /** * Perform redirect. diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java index e6f340c77..669a9389b 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoNoRedirectAttributeProvider.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import eu.stork.peps.auth.commons.IPersonalAttributeList; @@ -20,7 +21,7 @@ public class DemoNoRedirectAttributeProvider implements AttributeProvider { * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(java.lang.String) */ @Override - public IPersonalAttributeList acquire(PersonalAttribute attributeName) + public IPersonalAttributeList acquire(PersonalAttribute attributeName, AuthenticationSession moasession) throws UnsupportedAttributeException { PersonalAttributeList requestedAttributes = new PersonalAttributeList(1); requestedAttributes.add(new PersonalAttribute("sepp", true, new ArrayList(), "")); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java index 5d4336149..2f6b69075 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/DemoRedirectAttributeProvider.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import eu.stork.peps.auth.commons.IPersonalAttributeList; @@ -20,7 +21,7 @@ public class DemoRedirectAttributeProvider implements AttributeProvider { * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(java.lang.String) */ @Override - public IPersonalAttributeList acquire(PersonalAttribute attributeName) + public IPersonalAttributeList acquire(PersonalAttribute attributeName, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException { throw new ExternalAttributeRequestRequiredException(this); } 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 474dcb8fa..8b96e0d10 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 @@ -27,6 +27,7 @@ import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.w3c.dom.Element; +import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; import at.gv.egovernment.moa.logging.Logger; @@ -55,7 +56,7 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(eu.stork.peps.auth.commons.PersonalAttribute) */ @Override - public IPersonalAttributeList acquire(PersonalAttribute attributes) + public IPersonalAttributeList acquire(PersonalAttribute attributes, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException { @@ -95,8 +96,7 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { SOAPBody requestBody = envelope.getBody(); SOAPElement requestBodyElem = requestBody.addChildElement("IsHealthcareProfessional"); SOAPElement requestBodyElem1 = requestBodyElem.addChildElement("bPK"); - // TODO fetch bpk_gh from somewhere - requestBodyElem1.addTextNode("bpk_gh"); + requestBodyElem1.addTextNode(moasession.getIdentityLink().getIdentificationValue()); requestMessage.saveChanges(); @@ -128,7 +128,6 @@ public class EHvdAttributeProviderPlugin implements AttributeProvider { // iterate through tree SOAPElement responseElement = (SOAPElement) responseBody.getChildElements().next(); SOAPElement resultElement = (SOAPElement) responseElement.getChildElements().next(); - SOAPElement tmp; // collect all info in a map Iterator it = resultElement.getChildElements(); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java index 3c689cac9..bd6f192dc 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/StorkAttributeRequestProvider.java @@ -8,6 +8,7 @@ import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; +import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.auth.stork.VelocityProvider; import at.gv.egovernment.moa.id.config.auth.OAAuthParameter; @@ -47,7 +48,7 @@ public class StorkAttributeRequestProvider implements AttributeProvider { * @see at.gv.egovernment.moa.id.protocols.stork2.AttributeProvider#acquire(java.lang.String) */ @Override - public IPersonalAttributeList acquire(PersonalAttribute attribute) + public IPersonalAttributeList acquire(PersonalAttribute attribute, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException { requestedAttributes = new PersonalAttributeList(1); requestedAttributes.add(attribute); -- cgit v1.2.3