I'm using Tomcat JDBCRealm to authenticated users when they follow a protected page. The authentication works properly when reaching a protected page. Now I'd like to automate this process using cURL. I've written the code below but it doesn't work :
$domainUrl = "http://mydomain.com/protectedArea?j_username=john&j_password=doe";
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $domainUrl );
//curl_setopt ( $ch, CURLOPT_POST, true );
//curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt ( $ch, CURLOPT_TIMEOUT, 7 );
$output = curl_exec ( $ch );
curl_close ( $ch );
In tomcat log we can see only http GET :
[07/Aug/2012:11:51:24 +0200] GET http://mydomain.com/protectedArea?j_username=john&j_password=doe HTTP/1.1 200 1618
whereas we should have something like that :
[07/Aug/2012:11:57:06 +0200] GET http://mydomain.com/protectedArea?j_username=john&j_password=doe HTTP/1.1 200 1516
[07/Aug/2012:11:57:06 +0200] POST http://mydomain.com/j_security_check HTTP/1.1 302 -
Does someone have any idea?
Thanks for your help
Regards