From 27b4ca05aeac39b0a180a13e44ed354e80fb47dd Mon Sep 17 00:00:00 2001 From: Bojan Suzic Date: Wed, 26 Feb 2014 19:28:55 +0100 Subject: attribute collector --- .../data/deploy/conf/moa-id/stork/SamlEngine.xml | 16 ++++ .../conf/moa-id/stork/StorkSamlEngine_VIDP.xml | 93 ++++++++++++++++++++++ .../id/protocols/stork2/AttributeCollector.java | 30 +++++-- .../id/protocols/stork2/AuthenticationRequest.java | 2 + 4 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 id/server/data/deploy/conf/moa-id/stork/StorkSamlEngine_VIDP.xml diff --git a/id/server/data/deploy/conf/moa-id/stork/SamlEngine.xml b/id/server/data/deploy/conf/moa-id/stork/SamlEngine.xml index e6a29ea18..75245d8f0 100644 --- a/id/server/data/deploy/conf/moa-id/stork/SamlEngine.xml +++ b/id/server/data/deploy/conf/moa-id/stork/SamlEngine.xml @@ -33,5 +33,21 @@ + + + + + + + + + + + + + + + + diff --git a/id/server/data/deploy/conf/moa-id/stork/StorkSamlEngine_VIDP.xml b/id/server/data/deploy/conf/moa-id/stork/StorkSamlEngine_VIDP.xml new file mode 100644 index 000000000..fb786529a --- /dev/null +++ b/id/server/data/deploy/conf/moa-id/stork/StorkSamlEngine_VIDP.xml @@ -0,0 +1,93 @@ + + + + + SAML constants for AuthnRequests and Responses. + + + unspecified + + + obtained + + + entity + + + + HTTP-POST + + + + + + + + + + false + + + true + + + http://S-PEPS.gov.xx + + + http://C-PEPS.gov.xx + + + 300 + + + false + + + + http://www.stork.gov.eu/1.0/eIdentifier + http://www.stork.gov.eu/1.0/givenName + http://www.stork.gov.eu/1.0/surname + http://www.stork.gov.eu/1.0/inheritedFamilyName + http://www.stork.gov.eu/1.0/adoptedFamilyName + http://www.stork.gov.eu/1.0/gender + http://www.stork.gov.eu/1.0/dateOfBirth + http://www.stork.gov.eu/1.0/countryCodeOfBirth + http://www.stork.gov.eu/1.0/nationalityCode + http://www.stork.gov.eu/1.0/maritalStatus + http://www.stork.gov.eu/1.0/residenceAddress + http://www.stork.gov.eu/1.0/eMail + http://www.stork.gov.eu/1.0/academicTitle + http://www.stork.gov.eu/1.0/pseudonym + http://www.stork.gov.eu/1.0/age + http://www.stork.gov.eu/1.0/isAgeOver + + http://www.stork.gov.eu/1.0/textResidenceAddress + http://www.stork.gov.eu/1.0/canonicalResidenceAddress + + http://www.stork.gov.eu/1.0/title + http://www.stork.gov.eu/1.0/residencePermit + + http://www.stork.gov.eu/1.0/signedDoc + http://www.stork.gov.eu/1.0/citizen509Certificate + + http://www.stork.gov.eu/1.0/newAttribute1 + http://www.stork.gov.eu/1.0/newAttribute2 + http://www.stork.gov.eu/1.0/hasDegree + http://www.stork.gov.eu/1.0/mandateContent + http://www.stork.gov.eu/1.0/representative + http://www.stork.gov.eu/1.0/represented + + 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 bc5a0c0c6..57c68e94c 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 @@ -69,6 +69,7 @@ public class AttributeCollector implements IAction { } catch (UnsupportedAttributeException e1) { // the current provider cannot find anything familiar within the // provided httpreq. Try the next one. + // TODO check the loop } if (null == newAttributes) { @@ -89,6 +90,8 @@ public class AttributeCollector implements IAction { throw new MOAIDException("stork.11", null); } + + // - insert the embedded attribute(s) into the container for (PersonalAttribute current : newAttributes) container.getResponse().getPersonalAttributeList().add(current); @@ -117,6 +120,7 @@ public class AttributeCollector implements IAction { if (!responseAttributeList.containsKey(current)) missingAttributes.add(current); + // Try to get all missing attributes try { // for each attribute still missing for (PersonalAttribute currentAttribute : missingAttributes) { @@ -138,6 +142,16 @@ public class AttributeCollector implements IAction { } } + + // build response + generateSTORKResponse(); + + // set new http response + generateRedirectResponse(); + response = httpResp; + + return "12345"; // AssertionId + } catch (ExternalAttributeRequestRequiredException e) { // the attribute request is ongoing and requires an external service. try { @@ -145,6 +159,13 @@ public class AttributeCollector implements IAction { // - generate new key String newArtifactId = new SecureRandomIdentifierGenerator() .generateIdentifier(); + // - put container in temporary store. + AssertionStorage.getInstance().put(newArtifactId, container); + + // add container-key to redirect embedded within the return URL + e.getAp().performRedirect(AuthConfigurationProvider.getInstance().getPublicURLPrefix() + "?" + ARTIFACT_ID + "=" + newArtifactId, container.getRequest().getCitizenCountryCode(), request, response, oaParam); + + } catch (Exception e1) { // TODO should we return the response as is to the PEPS? Logger.error("Error putting incomplete Stork response into temporary storage", e); @@ -154,14 +175,7 @@ public class AttributeCollector implements IAction { return "12345"; // TODO what to do here? } - // build response - generateSTORKResponse(); - - // set new http response - generateRedirectResponse(); - response = httpResp; - return "12345"; // AssertionId } @@ -171,7 +185,7 @@ public class AttributeCollector implements IAction { try { //Get SAMLEngine instance - STORKSAMLEngine engine = STORKSAMLEngine.getInstance("vidp"); + STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP"); Logger.debug("Starting generation of SAML response"); authnResponse = engine.generateSTORKAuthnResponse(authnRequest, authnResponse, container.getRemoteAddress(), false); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java index b3f009ae2..d4996c26a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java @@ -105,6 +105,8 @@ public class AuthenticationRequest implements IAction { // - memorize the target url were we have to return the result container.setTarget(((MOASTORKAuthnRequest) req).getStorkAuthnRequest().getAssertionConsumerServiceURL()); + container.setRemoteAddress(httpReq.getRemoteAddr()); + Logger.debug("Data container prepared"); -- cgit v1.2.3