From 60ac2a89fce86eb1e8344eb22535cfdd0b9aa147 Mon Sep 17 00:00:00 2001 From: Bojan Suzic Date: Fri, 14 Mar 2014 18:37:56 +0100 Subject: attr --- id/ConfigWebTool/ConfigurationInterface.iml | 9 ++-- id/pom.xml | 5 +++ id/server/auth/moa-id-auth.iml | 9 ++-- id/server/idserverlib/moa-id-lib.iml | 9 ++-- id/server/idserverlib/pom.xml | 5 ++- .../id/protocols/stork2/AttributeCollector.java | 1 + .../protocols/stork2/AttributeProviderFactory.java | 10 ++++- .../id/protocols/stork2/AuthenticationRequest.java | 32 ++++++++++++- .../moa/id/protocols/stork2/ConsentEvaluator.java | 8 +++- .../stork2/MandateAttributeRequestProvider.java | 52 ++++++++++++++++++++++ .../src/main/resources/config/moaid_config_2.0.xsd | 2 +- id/server/pom.xml | 2 +- id/server/proxy/moa-id-proxy.iml | 9 ++-- 13 files changed, 124 insertions(+), 29 deletions(-) create mode 100644 id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java (limited to 'id') diff --git a/id/ConfigWebTool/ConfigurationInterface.iml b/id/ConfigWebTool/ConfigurationInterface.iml index 13c327c84..77fafd064 100644 --- a/id/ConfigWebTool/ConfigurationInterface.iml +++ b/id/ConfigWebTool/ConfigurationInterface.iml @@ -35,7 +35,6 @@ - @@ -106,8 +105,8 @@ - - + + @@ -125,7 +124,7 @@ - + @@ -165,7 +164,7 @@ - + diff --git a/id/pom.xml b/id/pom.xml index bd3344638..5eb67cc9f 100644 --- a/id/pom.xml +++ b/id/pom.xml @@ -43,6 +43,11 @@ org.slf4j:1.5* org.slf4j:1.6* + SamlEngine:1.1* + SamlEngine:1.2* + Commons:1.1* + Commons:1.2* + diff --git a/id/server/auth/moa-id-auth.iml b/id/server/auth/moa-id-auth.iml index 815c21ef2..c431a320c 100644 --- a/id/server/auth/moa-id-auth.iml +++ b/id/server/auth/moa-id-auth.iml @@ -23,7 +23,6 @@ - @@ -78,8 +77,8 @@ - - + + @@ -98,7 +97,7 @@ - + @@ -153,7 +152,7 @@ - + diff --git a/id/server/idserverlib/moa-id-lib.iml b/id/server/idserverlib/moa-id-lib.iml index 47c38c069..0bcb37f55 100644 --- a/id/server/idserverlib/moa-id-lib.iml +++ b/id/server/idserverlib/moa-id-lib.iml @@ -13,9 +13,8 @@ - - - + + @@ -42,7 +41,7 @@ - + @@ -142,7 +141,7 @@ - + diff --git a/id/server/idserverlib/pom.xml b/id/server/idserverlib/pom.xml index 59275055f..f495ba9b3 100644 --- a/id/server/idserverlib/pom.xml +++ b/id/server/idserverlib/pom.xml @@ -56,12 +56,12 @@ eu.stork Commons - 1.2.0 + 1.4.0 eu.stork SamlEngine - 1.1.0 + 1.4.0 @@ -195,6 +195,7 @@ commons-fileupload commons-fileupload + 1.3 commons-httpclient 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 7dbbb5734..1dfccb6c0 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 @@ -178,6 +178,7 @@ public class AttributeCollector implements IAction { } catch (Exception e1) { // TODO should we return the response as is to the PEPS? Logger.error("Error putting incomplete Stork response into temporary storage", e1); + e1.printStackTrace(); throw new MOAIDException("stork.11", null); } 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 c998b5f69..a8a9d9677 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 @@ -1,6 +1,7 @@ package at.gv.egovernment.moa.id.protocols.stork2; import at.gv.egovernment.moa.id.commons.db.dao.config.AttributeProviderPlugin; +import at.gv.egovernment.moa.logging.Logger; import java.util.ArrayList; import java.util.List; @@ -20,6 +21,7 @@ public class AttributeProviderFactory { result.add("StorkAttributeRequestProvider"); result.add("EHvdAttributeProvider"); result.add("SignedDocAttributeRequestProvider"); + result.add("MandateAttributeRequestProvider"); return result; } @@ -38,6 +40,8 @@ public class AttributeProviderFactory { return new EHvdAttributeProviderPlugin(url, attributes); } else if (shortname.equals("SignedDocAttributeRequestProvider")) { return new SignedDocAttributeRequestProvider(url, attributes); + } else if (shortname.equals("MandateAttributeRequestProvider")) { + return new MandateAttributeRequestProvider(url, attributes); } else { return null; } @@ -51,10 +55,14 @@ public class AttributeProviderFactory { */ public static List getConfiguredPlugins( List configuredAPs) { + Logger.setHierarchy("moa.id.protocols.stork2"); List result = new ArrayList(); - for (AttributeProviderPlugin current : configuredAPs) + for (AttributeProviderPlugin current : configuredAPs) { + result.add(create(current.getName(), current.getUrl(), current.getAttributes())); + Logger.debug("Adding configured attribute provider: " + current.getClass().getName() + current.getName() + " at " + current.getUrl()); + } return result; } 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 3d5fbd337..442fa8a5b 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 @@ -10,8 +10,11 @@ import at.gv.egovernment.moa.id.moduls.IRequest; import at.gv.egovernment.moa.id.util.client.mis.simple.MISMandate; import at.gv.egovernment.moa.logging.Logger; import eu.stork.peps.auth.commons.*; +import eu.stork.peps.auth.engine.STORKSAMLEngine; +import eu.stork.peps.exceptions.STORKSAMLEngineException; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.runtime.RuntimeConstants; +import org.joda.time.DateTime; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -61,13 +64,25 @@ public class AuthenticationRequest implements IAction { // check if we have authentication request else if (moaStorkRequest.isAuthnRequest()) { Logger.debug("Starting AuthenticationRequest"); - moaStorkResponse.setSTORKAuthnResponse(new STORKAuthnResponse()); + // Get personal attributtes from MOA/IdentityLink moaStorkResponse.setPersonalAttributeList(populateAttributes()); + + + STORKSAMLEngine engine = STORKSAMLEngine.getInstance("VIDP"); + STORKAuthnResponse authnResponse = new STORKAuthnResponse(); + + Logger.debug("Starting generation of SAML response"); + try { + moaStorkResponse.setSTORKAuthnResponse(engine.generateSTORKAuthnResponse(moaStorkRequest.getStorkAuthnRequest(), moaStorkResponse.getStorkAuthnResponse(),httpReq.getRemoteAddr(), false)); + } catch (STORKSAMLEngineException ex) { + // TODO + } + } - moaStorkResponse.setCountry(moaStorkRequest.getSpCountry()); + //moaStorkResponse.setCountry(moaStorkRequest.getSpCountry()); // Prepare extended attributes Logger.debug("Preparing data container"); @@ -84,6 +99,19 @@ public class AuthenticationRequest implements IAction { container.setRemoteAddress(httpReq.getRemoteAddr()); + STORKAuthnResponse arep = moaStorkResponse.getStorkAuthnResponse(); + + + arep.setCountry("XX"); + arep.setInResponseTo("xxxx"); + arep.setMessage("xxxx"); + arep.setSamlId("xxxx"); + arep.setStatusCode("xxxx"); + + // arep.setNotBefore(new DateTime().withTimeAtStartOfDay()); + // arep.setNotOnOrAfter(new DateTime().withTimeAtStartOfDay()); + + Logger.debug("Data container prepared"); return (new AttributeCollector()).processRequest(container, httpReq, httpResp, moasession, oaParam); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/ConsentEvaluator.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/ConsentEvaluator.java index 79404d4f0..19ec754ee 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/ConsentEvaluator.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/ConsentEvaluator.java @@ -15,11 +15,13 @@ import at.gv.egovernment.moa.id.storage.AssertionStorage; import at.gv.egovernment.moa.logging.Logger; import eu.stork.peps.auth.commons.PEPSUtil; import eu.stork.peps.auth.commons.PersonalAttribute; +import eu.stork.peps.auth.commons.STORKAuthnResponse; import eu.stork.peps.auth.engine.STORKSAMLEngine; import eu.stork.peps.exceptions.STORKSAMLEngineException; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; +import org.joda.time.DateTime; import org.opensaml.common.impl.SecureRandomIdentifierGenerator; import javax.servlet.http.HttpServletRequest; @@ -92,7 +94,8 @@ public class ConsentEvaluator implements IAction { } catch (Exception e1) { // TODO should we return the response as is to the PEPS? - Logger.error("Error putting incomplete Stork response into temporary storage", e1); + e1.printStackTrace(); + Logger.error("Error putting incomplete Stork response into temporary storage", e1); throw new MOAIDException("stork.17", null); } @@ -143,7 +146,8 @@ public class ConsentEvaluator implements IAction { response.setSTORKAuthnResponse(engine.generateSTORKAuthnResponse(request.getStorkAuthnRequest(), response.getStorkAuthnResponse(), container.getRemoteAddress(), false)); else response.setSTORKAttrResponse(engine.generateSTORKAttrQueryResponse(request.getStorkAttrQueryRequest(), response.getStorkAttrQueryResponse(), container.getRemoteAddress(), "", false)); - + + //generateSAML Token Logger.info("SAML response succesfully generated!"); } catch (STORKSAMLEngineException e) { diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java new file mode 100644 index 000000000..123999166 --- /dev/null +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java @@ -0,0 +1,52 @@ +package at.gv.egovernment.moa.id.protocols.stork2; + +import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate; +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; +import eu.stork.peps.auth.commons.IPersonalAttributeList; +import eu.stork.peps.auth.commons.PersonalAttribute; +import eu.stork.peps.auth.commons.PersonalAttributeList; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Provides mandate attribute from MIS + * + */ +public class MandateAttributeRequestProvider implements AttributeProvider { + /** The destination. */ + private Object destination; + + /** The attributes. */ + private String attributes; + + public MandateAttributeRequestProvider(String url, String supportedAttributes) { + Logger.setHierarchy("moa.id.protocols.stork2"); + destination = url; + attributes = supportedAttributes; + } + + public IPersonalAttributeList acquire(PersonalAttribute attribute, String spCountyCode, AuthenticationSession moasession) throws UnsupportedAttributeException, ExternalAttributeRequestRequiredException, MOAIDException { + Logger.info("Acquiring attribute: " + this.getClass().getName()); + // break if we cannot handle the requested attribute + if(!attributes.contains(attribute.getName())) + throw new UnsupportedAttributeException(); + PersonalAttributeList result = new PersonalAttributeList(); + //return result; + throw new ExternalAttributeRequestRequiredException(this); + } + + public void performRedirect(String url, HttpServletRequest req, HttpServletResponse resp, OAAuthParameter oaParam) throws MOAIDException { + Logger.info("Redirecting: " + this.getClass().getName()); + + } + + public IPersonalAttributeList parse(HttpServletRequest httpReq) throws UnsupportedAttributeException, MOAIDException { + Logger.info("Parsing attribute: " + this.getClass().getName()); + + return null; // + } +} diff --git a/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd b/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd index 936363169..3a2b8cc62 100644 --- a/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd +++ b/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd @@ -892,7 +892,7 @@ - + diff --git a/id/server/pom.xml b/id/server/pom.xml index 056accdad..fbaeaeaf1 100644 --- a/id/server/pom.xml +++ b/id/server/pom.xml @@ -18,7 +18,7 @@ proxy auth moa-id-commons - stork2-saml-engine + diff --git a/id/server/proxy/moa-id-proxy.iml b/id/server/proxy/moa-id-proxy.iml index d0e7de0b2..ebb14c7b0 100644 --- a/id/server/proxy/moa-id-proxy.iml +++ b/id/server/proxy/moa-id-proxy.iml @@ -21,7 +21,6 @@ - @@ -75,8 +74,8 @@ - - + + @@ -95,7 +94,7 @@ - + @@ -150,7 +149,7 @@ - + -- cgit v1.2.3