Skip to content

Commit 7bed76a

Browse files
Neil Maddenjoebandenburg
Neil Madden
authored andcommitted
OPENAM-9216
1 parent 57209d9 commit 7bed76a

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

openam-federation/openam-federation-library/src/main/java/com/sun/identity/saml/servlet/SAMLPOSTProfileServlet.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
44
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
@@ -24,7 +24,7 @@
2424
*
2525
* $Id: SAMLPOSTProfileServlet.java,v 1.4 2009/06/12 22:21:39 mallas Exp $
2626
*
27-
* Portions Copyrighted 2011-2013 ForgeRock AS
27+
* Portions Copyrighted 2011-2016 ForgeRock AS
2828
*/
2929
package com.sun.identity.saml.servlet;
3030

@@ -65,6 +65,8 @@
6565
import javax.servlet.http.HttpServletRequest;
6666
import javax.servlet.http.HttpServletResponse;
6767

68+
import org.owasp.esapi.ESAPI;
69+
6870
/**
6971
* This servlet is used to support SAML 1.x Web Browser/POST Profile.
7072
*/
@@ -233,18 +235,19 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
233235
LogUtils.REDIRECT_TO_URL, data, token);
234236
}
235237
response.setContentType("text/html; charset=UTF-8");
236-
PrintWriter out = response.getWriter();
237-
out.println("<HTML>");
238-
out.println("<BODY Onload=\"document.forms[0].submit()\">");
239-
out.println("<FORM METHOD=\"POST\" ACTION=\"" + destSiteUrl + "\">");
240-
out.println("<INPUT TYPE=\"HIDDEN\" NAME=\"" +
241-
SAMLConstants.POST_SAML_RESPONSE_PARAM + "\" ");
242-
out.println("VALUE=\"" + encodedResponse + "\">");
243-
out.println("<INPUT TYPE=\"HIDDEN\" NAME=\"" +
244-
SAMLConstants.POST_TARGET_PARAM + "\" VALUE=\"" + target
245-
+ "\"> </FORM>");
246-
out.println("</BODY></HTML>");
247-
out.close();
238+
try (PrintWriter out = response.getWriter()) {
239+
out.println("<HTML>");
240+
out.println("<BODY Onload=\"document.forms[0].submit()\">");
241+
out.println("<FORM METHOD=\"POST\" ACTION=\""
242+
+ ESAPI.encoder().encodeForHTMLAttribute(destSiteUrl) + "\">");
243+
out.println("<INPUT TYPE=\"HIDDEN\" NAME=\"" +
244+
SAMLConstants.POST_SAML_RESPONSE_PARAM + "\" ");
245+
out.println("VALUE=\"" + ESAPI.encoder().encodeForHTMLAttribute(encodedResponse) + "\">");
246+
out.println("<INPUT TYPE=\"HIDDEN\" NAME=\"" +
247+
SAMLConstants.POST_TARGET_PARAM + "\" VALUE=\"" + ESAPI.encoder().encodeForHTMLAttribute(target)
248+
+ "\"> </FORM>");
249+
out.println("</BODY></HTML>");
250+
}
248251
}
249252

250253
private SAMLServiceManager.SiteEntry getDestSite(String target) {

0 commit comments

Comments
 (0)