6

In my current application(A), I redirect user to a different website(B) where user logs in with his/her account and finishes some activity and now that website(B) has a button to return my application(A), the redirection happens by posting a SAMLResponse.

When user clicks that button, user return to my application(A) with specific unique user id assigned by that website(B) in "Form Data" of header information.Basically website B is also posting SAMLResponse as a form parameter in a request.

How do I read this request information in php and java?

Satheesh Cheveri
  • 3,621
  • 3
  • 27
  • 46
yogsma
  • 10,142
  • 31
  • 97
  • 154

2 Answers2

4

The "form data" part is unclear, but you can print the source code of your desired url/form to the console like this:

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
}
prouvaire
  • 305
  • 1
  • 9
3

The following links are helpful although they are not exactly what you want. Do have a look.....

Regards

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

[2] Consume SAMLResponse Token

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

Community
  • 1
  • 1
Mitesh Pathak
  • 1,306
  • 10
  • 14