diff options
Diffstat (limited to 'id/server/idserverlib')
7 files changed, 105 insertions, 12 deletions
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 @@ <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="Maven: eu.stork.mw.core:stork-saml-engine:2.0" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.6.6" level="project" /> - <orderEntry type="library" name="Maven: eu.medsea.mimeutil:mime-util:2.1.3" level="project" /> - <orderEntry type="module" module-name="SamlEngine" /> - <orderEntry type="library" name="Maven: eu.stork:Commons:1.2.0" level="project" /> + <orderEntry type="library" name="Maven: eu.stork:SamlEngine:1.4.0" level="project" /> + <orderEntry type="library" name="Maven: eu.stork:Commons:1.4.0" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.3" level="project" /> <orderEntry type="library" name="Maven: log4j:log4j:1.2.14" level="project" /> <orderEntry type="library" name="Maven: org.opensaml:opensaml:2.6.0" level="project" /> @@ -42,7 +41,7 @@ <orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.5" level="project" /> <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.5" level="project" /> <orderEntry type="library" name="Maven: commons-io:commons-io:1.3.2" level="project" /> - <orderEntry type="library" name="Maven: eu.stork:oasis-dss-api:1.0.0-SNAPSHOT" level="project" /> + <orderEntry type="library" name="Maven: eu.stork:oasis-dss-api:1.0.0-RELEASE" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: junit:junit:3.8.1" level="project" /> <orderEntry type="library" name="Maven: eu.medsea.mimeutil:mime-util:2.1.3" level="project" /> <orderEntry type="module" module-name="moa-id-commons" /> @@ -142,7 +141,7 @@ <orderEntry type="library" name="Maven: iaik.prod:iaik_jsse:4.4" level="project" /> <orderEntry type="library" name="Maven: com.sun:webservices-tools:2.0.1" level="project" /> <orderEntry type="library" name="Maven: com.sun:webservices-rt:2.0.1" level="project" /> - <orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.1.1" level="project" /> + <orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3" level="project" /> <orderEntry type="library" name="Maven: dav4j:dav4j:0.1" level="project" /> <orderEntry type="library" name="Maven: httpsclient:httpsclient:JSSE-1.0" level="project" /> <orderEntry type="library" name="Maven: iaik.prod:iaik_X509TrustManager:0.3" level="project" /> 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 @@ <dependency>
<groupId>eu.stork</groupId>
<artifactId>Commons</artifactId>
- <version>1.2.0</version>
+ <version>1.4.0</version>
</dependency>
<dependency>
<groupId>eu.stork</groupId>
<artifactId>SamlEngine</artifactId>
- <version>1.1.0</version>
+ <version>1.4.0</version>
</dependency>
<dependency>
@@ -195,6 +195,7 @@ <dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
+ <version>1.3</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
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<AttributeProvider> getConfiguredPlugins( List<AttributeProviderPlugin> configuredAPs) { + Logger.setHierarchy("moa.id.protocols.stork2"); List<AttributeProvider> result = new ArrayList<AttributeProvider>(); - 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; // + } +} |