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/server/idserverlib') 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