From efa960b616d81e762905b531814560616b98eab4 Mon Sep 17 00:00:00 2001 From: Bojan Suzic Date: Tue, 18 Feb 2014 16:26:11 +0100 Subject: saml point --- .../id/protocols/stork2/AuthenticationRequest.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'id/server/idserverlib') 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 1fa88e0a2..55d5f3626 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 @@ -27,6 +27,7 @@ import java.util.HashMap; import eu.stork.peps.auth.engine.SAMLEngine; import sun.rmi.runtime.Log; + /** * @author bsuzic * Date: 12/3/13, Time: 2:08 PM @@ -142,6 +143,7 @@ public class AuthenticationRequest implements IAction { try { Logger.debug("authn saml:" + IOUtils.toString(authnResponse.getTokenSaml())); + Logger.debug("authn saml encodedx: " + new String(org.bouncycastle.util.encoders.Base64.encode(IOUtils.toString(authnResponse.getTokenSaml()).getBytes()))); } catch (IOException e) { e.printStackTrace(); @@ -153,18 +155,28 @@ public class AuthenticationRequest implements IAction { 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())); + //context.put("SAMLResponse", IOUtils.toString(authnResponse.getTokenSaml())); + + context.put("SAMLResponse", new String(org.bouncycastle.util.encoders.Base64.encode(IOUtils.toString(authnResponse.getTokenSaml()).getBytes()))); + Logger.debug("SAMLResponse original: " + new String(org.bouncycastle.util.encoders.Base64.encode(IOUtils.toString(authnResponse.getTokenSaml()).getBytes()))); + //Logger.info("Putting saml token in response: " + org.bouncycastle.util.encoders.Base64.encode(context.get("SAMLResponse").toString().getBytes())); Logger.debug("Putting assertion consumer url as action: " + ((STORKAuthnRequestDEL)req).getStorkAuthnRequest().getAssertionConsumerServiceURL()); context.put("action", ((STORKAuthnRequestDEL) req).getStorkAuthnRequest().getAssertionConsumerServiceURL()); Logger.debug("Starting template merge"); StringWriter writer = new StringWriter(); + //PrintWriter pwriter = new StringWriter(); + Logger.debug("Doing template merge"); template.merge(context, writer); Logger.debug("Template merge done"); - Logger.debug("Sending html content: " + writer.toString().getBytes()); - httpResp.getOutputStream().write(writer.toString().getBytes()); + + Logger.debug("Sending html content: " + writer.getBuffer().toString()); + Logger.debug("Sending html content2 : " + new String(writer.getBuffer())); + + + + httpResp.getOutputStream().write(writer.getBuffer().toString().getBytes()); } catch (Exception e) { Logger.error("Velocity error: " + e.getMessage()); @@ -172,7 +184,7 @@ public class AuthenticationRequest implements IAction { HttpSession httpSession = httpReq.getSession(); httpSession.setAttribute("STORKSessionID", "12345"); - Logger.info("Status code: " + authnResponse.getStatusCode()); + Logger.info("Status code again: " + authnResponse.getStatusCode()); -- cgit v1.2.3