aboutsummaryrefslogtreecommitdiff
path: root/id
diff options
context:
space:
mode:
Diffstat (limited to 'id')
-rw-r--r--id/ConfigWebTool/ConfigurationInterface.iml2
-rw-r--r--id/oa/moa-id-oa.iml4
-rw-r--r--id/server/auth/moa-id-auth.iml4
-rw-r--r--id/server/idserverlib/moa-id-lib.iml4
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/AuthenticationRequest.java99
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java1
-rw-r--r--id/server/proxy/moa-id-proxy.iml4
-rw-r--r--id/templates/moa-id-templates.iml4
8 files changed, 107 insertions, 15 deletions
diff --git a/id/ConfigWebTool/ConfigurationInterface.iml b/id/ConfigWebTool/ConfigurationInterface.iml
index bb7e047b2..20f45337e 100644
--- a/id/ConfigWebTool/ConfigurationInterface.iml
+++ b/id/ConfigWebTool/ConfigurationInterface.iml
@@ -57,7 +57,7 @@
<orderEntry type="library" name="Maven: iaik.prod:iaik_moa:1.5" level="project" />
<orderEntry type="library" name="Maven: jaxen:jaxen:1.0-FCS" level="project" />
<orderEntry type="library" name="Maven: saxpath:saxpath:1.0-FCS" level="project" />
- <orderEntry type="library" name="Maven: joda-time:joda-time:1.6.2" level="project" />
+ <orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
<orderEntry type="library" name="Maven: org.jvnet.hyperjaxb3:hyperjaxb3-ejb-runtime:0.5.6" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.6.2" level="project" />
diff --git a/id/oa/moa-id-oa.iml b/id/oa/moa-id-oa.iml
index 0b7bf00de..6d9905e25 100644
--- a/id/oa/moa-id-oa.iml
+++ b/id/oa/moa-id-oa.iml
@@ -13,8 +13,8 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <output url="file://$MODULE_DIR$/../target/classes" />
+ <output-test url="file://$MODULE_DIR$/../target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
diff --git a/id/server/auth/moa-id-auth.iml b/id/server/auth/moa-id-auth.iml
index d0aa970fc..f61dfa171 100644
--- a/id/server/auth/moa-id-auth.iml
+++ b/id/server/auth/moa-id-auth.iml
@@ -14,8 +14,8 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <output url="file://$MODULE_DIR$/../../target/classes" />
+ <output-test url="file://$MODULE_DIR$/../../target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
diff --git a/id/server/idserverlib/moa-id-lib.iml b/id/server/idserverlib/moa-id-lib.iml
index 1c04295d7..cf1b34b4b 100644
--- a/id/server/idserverlib/moa-id-lib.iml
+++ b/id/server/idserverlib/moa-id-lib.iml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <output url="file://$MODULE_DIR$/../../target/classes" />
+ <output-test url="file://$MODULE_DIR$/../../target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
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 7e80273ca..1971fe12d 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
@@ -2,9 +2,16 @@ package at.gv.egovernment.moa.id.protocols.stork2;
import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
import at.gv.egovernment.moa.id.auth.exception.MOAIDException;
+import at.gv.egovernment.moa.id.auth.stork.VelocityProvider;
import at.gv.egovernment.moa.id.moduls.IAction;
import at.gv.egovernment.moa.id.moduls.IRequest;
import at.gv.egovernment.moa.logging.Logger;
+import edu.emory.mathcs.backport.java.util.Collections;
+import eu.stork.peps.auth.commons.*;
+import eu.stork.peps.auth.engine.STORKSAMLEngine;
+import eu.stork.peps.exceptions.STORKSAMLEngineException;
+import org.apache.commons.io.IOUtils;
+import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.runtime.RuntimeConstants;
@@ -14,12 +21,11 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
+import java.io.*;
+import java.util.ArrayList;
import java.util.HashMap;
import eu.stork.peps.auth.engine.SAMLEngine;
+import sun.rmi.runtime.Log;
/**
* @author bsuzic
@@ -40,6 +46,7 @@ public class AuthenticationRequest implements IAction {
Logger.debug("Starting AuthenticationRequest");
//AuthenticationServer.getInstance().startSTORKAuthentication(httpReq, httpResp, moasession);
Logger.debug("Http Response: " + httpResp.toString() + ", ");
+ Logger.debug("Remote user: " + httpReq.getRemoteAddr());
Logger.debug("Moa session: " + moasession.toString() + " " + moasession.getOAURLRequested() + " " + moasession.getPublicOAURLPrefix() + " " + moasession.getAction() + " " + moasession.getIdentityLink().getName() + " " + moasession.getTarget());
httpResp.reset();
//httpResp.addHeader("Location", "http:/www.google.com");
@@ -82,6 +89,90 @@ public class AuthenticationRequest implements IAction {
//httpResp.setStatus(200);
//VPEPSInboundPostHandler
+ // - prepare attribute list
+ PersonalAttributeList attributeList = new PersonalAttributeList();
+
+ STORKAuthnResponse authnResponse = new STORKAuthnResponse();
+ authnResponse.setCountry("AT");
+
+
+ try {
+
+ IPersonalAttributeList moaAttrList = moasession.getStorkAttributes();
+
+ for (PersonalAttribute personalAttribute : moaAttrList) {
+ Logger.info("Personal attribute found: " + personalAttribute.getName() + personalAttribute.getStatus());
+ if (personalAttribute.getValue().size() > 0) {
+ for (String value : personalAttribute.getValue()) {
+ Logger.info(" Value found: " + value);
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ Logger.error("Exception, attributes: " + e.getMessage());
+ }
+
+ PersonalAttribute newAttribute = new PersonalAttribute();
+ newAttribute.setName("eIdentifier");
+ newAttribute.setValue(new ArrayList<String>(Collections.singletonList("xxxxxxxxxxxxxxx")));
+ attributeList.add(newAttribute);
+ authnResponse.setPersonalAttributeList(attributeList);
+
+
+ try {
+ //Get SAMLEngine instance
+ STORKSAMLEngine engine = STORKSAMLEngine.getInstance("incoming");
+ Logger.debug("Starting generation of SAML response");
+ authnResponse = engine.generateSTORKAuthnResponse(((STORKAuthnRequestDEL)req).getStorkAuthnRequest(),authnResponse,httpReq.getRemoteAddr(),false);
+ //generateSAML Token
+ Logger.info("SAML response succesfully generated!");
+ }catch(STORKSAMLEngineException e){
+ Logger.error("Failed to generate STORK SAML Response", e);
+ throw new MOAIDException("stork.05", null);
+ }
+
+ Logger.info("STORK SAML Response message succesfully generated ");
+ Logger.debug("STORK response: ");
+
+ Logger.debug("authn response string: " + authnResponse.toString());
+
+ String statusCodeValue = authnResponse.getStatusCode();
+ Logger.debug("authn status code value: " + statusCodeValue);
+
+ try {
+ Logger.debug("authn saml:" + IOUtils.toString(authnResponse.getTokenSaml()));
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ try {
+ VelocityEngine velocityEngine = VelocityProvider.getClassPathVelocityEngine();
+ Template template = velocityEngine.getTemplate("/resources/templates/stork2_postbinding_template.html");
+ VelocityContext context = new VelocityContext();
+ //Logger.info("Putting saml token in response: " + org.bouncycastle.util.encoders.Base64.decode(context.get("SAMLResponse").toString()));
+
+ context.put("SAMLResponse", IOUtils.toString(authnResponse.getTokenSaml()));
+ Logger.info("Putting saml token in response: " + org.bouncycastle.util.encoders.Base64.decode(context.get("SAMLResponse").toString()));
+
+ Logger.info("Putting assertion consumer url as action: " + ((STORKAuthnRequestDEL)req).getStorkAuthnRequest().getAssertionConsumerServiceURL());
+ context.put("action", ((STORKAuthnRequestDEL) req).getStorkAuthnRequest().getAssertionConsumerServiceURL());
+ StringWriter writer = new StringWriter();
+ template.merge(context, writer);
+
+ httpResp.getOutputStream().write(writer.toString().getBytes());
+
+ } catch (Exception e) {
+ Logger.error("Velocity error: " + e.getMessage());
+ }
+
+ HttpSession httpSession = httpReq.getSession();
+ httpSession.setAttribute("STORKSessionID", "12345");
+ Logger.info("Status code: " + authnResponse.getStatusCode());
+
+
+
return "12345"; // AssertionId
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java
index 2e42a0d75..9564afa27 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/stork2/STORKProtocol.java
@@ -153,6 +153,7 @@ public class STORKProtocol implements IModulInfo, MOAIDAuthConstants {
Logger.error("spi " + authnRequest.getSpInstitution());
+ STORK2Request.setSTORKAuthnRequest(authnRequest);
return STORK2Request;
}
diff --git a/id/server/proxy/moa-id-proxy.iml b/id/server/proxy/moa-id-proxy.iml
index fb1a16d2e..86fa1b292 100644
--- a/id/server/proxy/moa-id-proxy.iml
+++ b/id/server/proxy/moa-id-proxy.iml
@@ -13,8 +13,8 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <output url="file://$MODULE_DIR$/../../target/classes" />
+ <output-test url="file://$MODULE_DIR$/../../target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
diff --git a/id/templates/moa-id-templates.iml b/id/templates/moa-id-templates.iml
index 3b8b05541..0ecf962d0 100644
--- a/id/templates/moa-id-templates.iml
+++ b/id/templates/moa-id-templates.iml
@@ -13,8 +13,8 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <output url="file://$MODULE_DIR$/../target/classes" />
+ <output-test url="file://$MODULE_DIR$/../target/test-classes" />
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>