【问题标题】:How to read Form Data from headers如何从标题中读取表单数据
【发布时间】:2013-11-20 02:30:02
【问题描述】:

在我当前的应用程序(A)中,我将用户重定向到另一个网站(B),用户使用他/她的帐户登录并完成一些活动,现在该网站(B)有一个按钮来返回我的应用程序(A ),重定向通过发布 SAMLResponse 来实现。

当用户单击该按钮时,用户返回我的应用程序 (A),并在标题信息的“Form Data”中使用该网站 (B) 分配的特定唯一用户 ID。基本上,网站 B 也将 SAMLResponse 发布为请求中的表单参数。

如何在php和java中读取这个请求信息?

【问题讨论】:

标签: java http-headers saml-2.0


【解决方案1】:

“表单数据”部分不清楚,但您可以将所需 url/表单的源代码打印到控制台,如下所示:

import java.io.*;
import java.net.*;

public class Client {

 public String getHTML(String urlToRead) {
  URL url;
  HttpURLConnection conn;
  BufferedReader rd;
  String line;
  String result = "";
  try {
     url = new URL(urlToRead);
     conn = (HttpURLConnection) url.openConnection();
     conn.setRequestMethod("GET");
     rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
     while ((line = rd.readLine()) != null) {
      //basically makes a huge string
         result += line;
     }
     rd.close();
  } catch (Exception e) {
     e.printStackTrace();
  }
  return result;
 }

public static void main(String args[])
{
  Client c = new Client();
 System.out.println(c.getHTML("YOUR URL HERE"));
 //prints source code to console

}

//from here, you need to know which item you want to do is at which index of the string
}

【讨论】:

    【解决方案2】:

    以下链接很有帮助,尽管它们并不是您想要的。 看看吧.....

    问候

    [1]http://www.coderanch.com/t/545270/java/java/Decode-SAML-Request

    [2]Consume SAMLResponse Token

    [3]http://goo.gl/iW1N9V

    【讨论】:

      猜你喜欢
      • 2016-08-18
      • 2014-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多