How to read form data from headers

In my current application (A), I redirect the user to another website (B) where the user logs into his account and completes some activity, and now on the website (B) there is a button to return my application (A ), redirection occurs by placing SAMLResponse .

When a user clicks on this button, the user returns to my application (A) with a specific unique user ID assigned by this website (B) in the “ Form Data ” header information. In either case, website B also publishes SAMLResponse as form in the request.

How to read this request information in php and java?

+6
source share
2 answers

The following links are useful, although they are not exactly what you want. Take a look .....

Hello

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

[2] Use SAMLResponse token

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

+3
source

Part of the "form data" is unclear, but you can print the source code of the desired URL on the console as follows:

 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 } 
+4
source

Source: https://habr.com/ru/post/958437/


All Articles