From 3ca240a596e3d2d22a7a6c68ce9c34dda9168e2c Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 27 Jan 2016 06:26:52 +0100 Subject: set ContentType parameter in HTTPServletResponse --- .../modules/eidas/utils/EidasMetaDataServlet.java | 6 ++---- .../id/protocols/eidas/AuthenticationRequest.java | 24 +++++++++++----------- .../templates/eidas_postbinding_template.vm | 3 +++ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidas/utils/EidasMetaDataServlet.java b/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidas/utils/EidasMetaDataServlet.java index 470e3b0fc..6ae532210 100644 --- a/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidas/utils/EidasMetaDataServlet.java +++ b/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidas/utils/EidasMetaDataServlet.java @@ -15,17 +15,15 @@ * limitations under the Licence. *******************************************************************************/ package at.gv.egovernment.moa.id.auth.modules.eidas.utils; -import iaik.security.ecc.provider.ECCProvider; -import iaik.security.provider.IAIK; import java.io.IOException; -import java.security.Security; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; import org.slf4j.Logger; @@ -64,7 +62,7 @@ public class EidasMetaDataServlet extends HttpServlet { logger.trace(metaData); - response.setContentType("text/xml"); + response.setContentType(MediaType.TEXT_XML); response.getWriter().print(metaData); response.flushBuffer(); } catch (Exception e) { diff --git a/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/AuthenticationRequest.java b/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/AuthenticationRequest.java index 1012be1b7..ae9dd5a51 100644 --- a/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/AuthenticationRequest.java +++ b/id/server/modules/moa-id-module-eIDAS/src/main/java/at/gv/egovernment/moa/id/protocols/eidas/AuthenticationRequest.java @@ -26,6 +26,14 @@ import java.io.StringWriter; import java.text.SimpleDateFormat; import java.util.Map.Entry; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.MediaType; + +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.VelocityEngine; + import at.gv.egovernment.moa.id.auth.builder.BPKBuilder; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.auth.modules.eidas.Constants; @@ -41,13 +49,6 @@ import at.gv.egovernment.moa.id.moduls.IAction; import at.gv.egovernment.moa.id.moduls.IRequest; import at.gv.egovernment.moa.id.util.VelocityProvider; import at.gv.egovernment.moa.logging.Logger; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.velocity.Template; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.VelocityEngine; import eu.eidas.auth.commons.EIDASAuthnResponse; import eu.eidas.auth.commons.EIDASStatusCode; import eu.eidas.auth.commons.EIDASUtil; @@ -149,10 +150,10 @@ public class AuthenticationRequest implements IAction { template.merge(context, writer); Logger.trace("Template merge done"); - Logger.trace("Sending html content: " + writer.getBuffer().toString()); - Logger.trace("Sending html content2 : " + new String(writer.getBuffer())); + Logger.trace("Sending html content : " + new String(writer.getBuffer())); httpResp.getOutputStream().write(writer.getBuffer().toString().getBytes("UTF-8")); + httpResp.setContentType(MediaType.TEXT_HTML); } catch (Exception e) { Logger.error("Velocity error: " + e.getMessage()); @@ -167,9 +168,8 @@ public class AuthenticationRequest implements IAction { } @Override - public String getDefaultActionName() { - // TODO Auto-generated method stub - return null; + public String getDefaultActionName() { + return "eIDAS_AuthnRequest"; } diff --git a/id/server/modules/moa-id-module-eIDAS/src/main/resources/resources/templates/eidas_postbinding_template.vm b/id/server/modules/moa-id-module-eIDAS/src/main/resources/resources/templates/eidas_postbinding_template.vm index 8beb601c6..3bd225b00 100644 --- a/id/server/modules/moa-id-module-eIDAS/src/main/resources/resources/templates/eidas_postbinding_template.vm +++ b/id/server/modules/moa-id-module-eIDAS/src/main/resources/resources/templates/eidas_postbinding_template.vm @@ -9,6 +9,9 @@ ## Contains target attribute to delegate PEPS authentication out of iFrame + + +