Hello All,

I need help in debugging my issue with ca Siteminder login.fcc connection with javax.net.ssl.HttpsURLConnection java client.

I am creating HTTPSURLConnection client and POST ing my request with valid USER, PASSWORD and target parameter to https://<myDomain>.com/siteminderagent/forms/login.fcc, actually I am expecting to get redirected to success (target) page or sucessful SMSESSION as a header response.

But instead siteminder is redirecting my request to unsuccessful/ invalid credentials page.

Following is my code snippet, Please see anybody an give me vital inputs to resolve this. Any help would be appreciated a lot.

Same program I wrote using Apache commons HTTPClient library, that worked fine, however we don't want to use Apache commons for this implementation.


package com.test;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Map;
import java.util.Set;

import javax.net.ssl.HttpsURLConnection;

public class HTTPSURLTest {

public static void main(String args[]){

try{

String content = "USER=" + URLEncoder.encode ("cal")
+ "&PASSWORD=" + URLEncoder.encode ("tester")+"&target=https://<mydomain>.com/en_US/OCS/protected/mobile_pre_account_transaction.jsp";


URL u = new URL("https://<mydomain>.com/siteminderagent/forms/login.fcc");

// Just to give proper certificate value
System.setProperty("javax.net.ssl.trustStore", "jssecacerts");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");


HttpsURLConnection http = (HttpsURLConnection)u.openConnection();

http.setRequestMethod("POST");

http.setDoInput (true);
http.setDoOutput (true);

http.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");

// tried toogling this parameter
http.setInstanceFollowRedirects(true);

DataOutputStream out = new DataOutputStream(http.getOutputStream());

// Writing post data to the contents
out.writeBytes(content);

out.flush();
out.close();

InputStream ins = http.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);

String inputLine;

while ((inputLine = in.readLine()) != null)
{
System.out.println(inputLine);
}

// I am expecting SMSESSION value in cookie or any header field
Map getHeaders = http.getHeaderFields();
Set<String> headerSet = getHeaders.keySet();
for (String header : headerSet) {
System.out.println(header + ":" + getHeaders.get(header));
}

in.close();







}catch(Exception e){
e.printStackTrace();
}


}

}


Please help me in resolving this issue, as I got stuck in resolving this.