From 45727ed45e3deec0fff835a26f9b87adcfd0c6ba Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 8 Jul 2014 09:38:37 +0200 Subject: fix exception if attribute is not provided --- .../moa/id/auth/stork/STORKResponseProcessor.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java index 2c8b44404..2f1e50a05 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/stork/STORKResponseProcessor.java @@ -136,8 +136,10 @@ public class STORKResponseProcessor { Logger.trace("Starting call..."); // if there is no signedDoc attribute, we cannot go on + String fiscalNumber = null; String citizenSignature = getAttributeValue("signedDoc", attributeList); - String fiscalNumber = getAttributeValue("fiscalNumber", attributeList); + if (hasAttribute("fiscalNumber", attributeList)) + fiscalNumber = getAttributeValue("fiscalNumber", attributeList); // if we have a signedDoc we test for a representation case // - according to stork samlengine and commons @@ -156,14 +158,15 @@ public class STORKResponseProcessor { String eIdentifier = getAttributeValue("eIdentifier", attributeList); String givenName = getAttributeValue("givenName", attributeList); String lastName = getAttributeValue("surname", attributeList); - String dateOfBirth = getAttributeValue("dateOfBirth", attributeList); + String dateOfBirth = null; + if (hasAttribute("dateOfBirth", attributeList)) { + dateOfBirth = getAttributeValue("dateOfBirth", attributeList); + dateOfBirth = DateTimeUtils.formatPEPSDateToMOADate(dateOfBirth); + } // gender attribute is mandatory here because of some legal stuff String gender = getAttributeValue("gender", attributeList); - if (!StringUtils.isEmpty(dateOfBirth)) - dateOfBirth = DateTimeUtils.formatPEPSDateToMOADate(dateOfBirth); - identityLinkResponse = AuthenticationServer.getInstance().getIdentityLink(eIdentifier, givenName, lastName, dateOfBirth, gender, citizenSignature, null, null, mandate, targetType, targetValue, oaFriendlyName, filters, fiscalNumber); @@ -187,14 +190,15 @@ public class STORKResponseProcessor { String eIdentifier = getAttributeValue("eIdentifier", attributeList); String givenName = getAttributeValue("givenName", attributeList); String lastName = getAttributeValue("surname", attributeList); - String dateOfBirth = getAttributeValue("dateOfBirth", attributeList); + String dateOfBirth = null; + if (hasAttribute("dateOfBirth", attributeList)) { + dateOfBirth = getAttributeValue("dateOfBirth", attributeList); + dateOfBirth = DateTimeUtils.formatPEPSDateToMOADate(dateOfBirth); + } // gender attribute is mandatory here because of some legal stuff String gender = getAttributeValue("gender", attributeList); - - if (!StringUtils.isEmpty(dateOfBirth)) - dateOfBirth = DateTimeUtils.formatPEPSDateToMOADate(dateOfBirth); - + identityLinkResponse = AuthenticationServer.getInstance().getIdentityLink(eIdentifier, givenName, lastName, dateOfBirth, gender, citizenSignature, representative, represented, mandate, targetType, targetValue, oaFriendlyName, filters, fiscalNumber); @@ -204,9 +208,11 @@ public class STORKResponseProcessor { String eIdentifier = getAttributeValue("eIdentifier", attributeList); String givenName = getAttributeValue("givenName", attributeList); String lastName = getAttributeValue("surname", attributeList); - String dateOfBirth = getAttributeValue("dateOfBirth", attributeList); - if (!StringUtils.isEmpty(dateOfBirth)) + String dateOfBirth = null; + if (hasAttribute("dateOfBirth", attributeList)) { + dateOfBirth = getAttributeValue("dateOfBirth", attributeList); dateOfBirth = DateTimeUtils.formatPEPSDateToMOADate(dateOfBirth); + } identityLinkResponse = AuthenticationServer.getInstance().getIdentityLink(eIdentifier, givenName, lastName, dateOfBirth, citizenSignature, fiscalNumber); } -- cgit v1.2.3