All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.coveo.saml.BrowserUtils Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package com.coveo.saml;

import org.apache.commons.lang.StringEscapeUtils;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;

public class BrowserUtils {
  /**
   * Renders an HTTP response that will cause the browser to POST the specified values to an url.
   * @param url the url where to perform the POST.
   * @param response the {@link HttpServletResponse}.
   * @param values the values to include in the POST.
   * @throws IOException thrown if an IO error occurs.
   */
  public static void postUsingBrowser(
      String url, HttpServletResponse response, Map values) throws IOException {

    response.setContentType("text/html");
    Writer writer = response.getWriter();
    writer.write(
        "
"); for (String key : values.keySet()) { String encodedKey = StringEscapeUtils.escapeHtml(key); String encodedValue = StringEscapeUtils.escapeHtml(values.get(key)); writer.write( ""); } writer.write( "
"); writer.flush(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy