aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeCollector.java1
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AttributeProviderFactory.java10
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java32
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/ConsentEvaluator.java8
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/MandateAttributeRequestProvider.java52
5 files changed, 98 insertions, 5 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 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; //
+ }
+}