diff options
author | Florian Reimair <florian.reimair@iaik.tugraz.at> | 2014-02-26 14:06:36 +0100 |
---|---|---|
committer | Florian Reimair <florian.reimair@iaik.tugraz.at> | 2014-02-26 15:07:58 +0100 |
commit | 02800dff9580924a9b912ca9f2ff56c9a40d2152 (patch) | |
tree | 3c3749238714dc46da9be5e6d748394b9cb54cfa /id/server/idserverlib/src/main/java/at/gv/egovernment | |
parent | 5dd5959e9ddd730452d0007fbf2c091d2c2506e1 (diff) | |
download | moa-id-spss-02800dff9580924a9b912ca9f2ff56c9a40d2152.tar.gz moa-id-spss-02800dff9580924a9b912ca9f2ff56c9a40d2152.tar.bz2 moa-id-spss-02800dff9580924a9b912ca9f2ff56c9a40d2152.zip |
error handling
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment')
3 files changed, 12 insertions, 8 deletions
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 }); } } |