You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by "Stone, Robert" <c_...@qualcomm.com> on 2008/10/22 17:32:30 UTC

HttpClient and Siteminder

Hi,

I'm trying to get access code for URL that is protected by Siteminder (SM). Elsewhere in the code I'm getting SM  cookie for the current user. Now I'm trying to reuse this cookie to access URL and get the access code. The problem is that instead of following redirect and getting actual URL I am getting InvalidRedirectLocationException for the redirect URL of SM agent.

Here's cookie I'm adding (truncated)
JSESSIONID=9775B7EA48F0FEE86221B80B88FB214C; SMCHALLENGE=YES; SMIDENTITY=OQGA6QPST1Ho82Qr...

Here's the code
                                                                                                String allCookies = getCurrentCookies();
                                                                                                HttpClient client = new HttpClient();
                                                                                                client.getHttpConnectionManager().getParams()
                                                                                                                                .setBooleanParameter(
                                                                                                                                                                "http.connection.stalecheck", true);

                                                                                                HttpMethod get = new GetMethod(location);
                                                                                                get.setFollowRedirects(true);
                                                                                                get.getParams().setCookiePolicy(
                                                                                                                                CookiePolicy.BROWSER_COMPATIBILITY);
                                                                                                get.setRequestHeader("Cookie", allCookies);
                                                                                                int rCode = client.executeMethod(get);

And here's the exception:
org.apache.commons.httpclient.InvalidRedirectLocationException: Invalid redirect location: https://logintest.foocomm.com/siteminderagent/nocert/1224689077/smgetcred.scc?TYPE=16777217&REALM=$SM$FoonetApps%20Dev%2fTest%20[08%3a24%3a37%3a8525]&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=$SM$VIKCnIwFQBmaHrauIuaDE0Vxdt37jIIv5x3U5CdHFaRgnjYIvMJC2kStw8Ioq%2byh&TARGET=$SM$http%3a%2f%2ffoonetapps-test%2efoocomm%2ecom%2fLegalContracts%2fpages%2fcontractsHome%2exhtml

Looks like HttpClient doesn't like Siteminder URL but I am not clear why does client try to process it? Shouldn't it be processed and redirected  by the SM agent and not passed to HC at all? What am I missing?

Regards,

Bob Stone


Re: HttpClient and Siteminder

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2008-10-22 at 08:32 -0700, Stone, Robert wrote:
> Hi,
> 
> I'm trying to get access code for URL that is protected by Siteminder (SM). Elsewhere in the code I'm getting SM  cookie for the current user. Now I'm trying to reuse this cookie to access URL and get the access code. The problem is that instead of following redirect and getting actual URL I am getting InvalidRedirectLocationException for the redirect URL of SM agent.
> 
> Here's cookie I'm adding (truncated)
> JSESSIONID=9775B7EA48F0FEE86221B80B88FB214C; SMCHALLENGE=YES; SMIDENTITY=OQGA6QPST1Ho82Qr...
> 
> Here's the code
>                                                                                                 String allCookies = getCurrentCookies();
>                                                                                                 HttpClient client = new HttpClient();
>                                                                                                 client.getHttpConnectionManager().getParams()
>                                                                                                                                 .setBooleanParameter(
>                                                                                                                                                                 "http.connection.stalecheck", true);
> 
>                                                                                                 HttpMethod get = new GetMethod(location);
>                                                                                                 get.setFollowRedirects(true);
>                                                                                                 get.getParams().setCookiePolicy(
>                                                                                                                                 CookiePolicy.BROWSER_COMPATIBILITY);
>                                                                                                 get.setRequestHeader("Cookie", allCookies);
>                                                                                                 int rCode = client.executeMethod(get);
> 
> And here's the exception:
> org.apache.commons.httpclient.InvalidRedirectLocationException: Invalid redirect location: https://logintest.foocomm.com/siteminderagent/nocert/1224689077/smgetcred.scc?TYPE=16777217&REALM=$SM$FoonetApps%20Dev%2fTest%20[08%3a24%3a37%3a8525]&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=$SM$VIKCnIwFQBmaHrauIuaDE0Vxdt37jIIv5x3U5CdHFaRgnjYIvMJC2kStw8Ioq%2byh&TARGET=$SM$http%3a%2f%2ffoonetapps-test%2efoocomm%2ecom%2fLegalContracts%2fpages%2fcontractsHome%2exhtml
> 

This exception is thrown when HttpClient fails to parse the redirect
URL.

> Looks like HttpClient doesn't like Siteminder URL but I am not clear why does client try to process it?

In order to extract the target hostname.

>  Shouldn't it be processed and redirected  by the SM agent and not passed to HC at all? 

I can't tell. I have not a slightest idea about Siteminder

Oleg

> What am I missing?
> 
> Regards,
> 
> Bob Stone
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: HttpClient and Siteminder

Posted by Olli Murto <ol...@atrsoft.com>.
Hello Robert,

I had the same problem with HttpClient and SiteMinder, received the same
Exception at the exact same phase.

I noticed I was using commons-httpclient-3.1.jar. I fixed this error by
changing back to the 3.0.1 version of the jar.

Can't explain why this threw the exception with the newer .jar while parsing
the redirect URL - I'm no  Java Programming guru ;-)


Cheers,

Olli



Stone, Robert-2 wrote:
> 
> Hi,
> 
> I'm trying to get access code for URL that is protected by Siteminder
> (SM). Elsewhere in the code I'm getting SM  cookie for the current user.
> Now I'm trying to reuse this cookie to access URL and get the access code.
> The problem is that instead of following redirect and getting actual URL I
> am getting InvalidRedirectLocationException for the redirect URL of SM
> agent.
> 
> Here's cookie I'm adding (truncated)
> JSESSIONID=9775B7EA48F0FEE86221B80B88FB214C; SMCHALLENGE=YES;
> SMIDENTITY=OQGA6QPST1Ho82Qr...
> 
> Here's the code
>                                                                                                
> String allCookies = getCurrentCookies();
>                                                                                                
> HttpClient client = new HttpClient();
>                                                                                                
> client.getHttpConnectionManager().getParams()
>                                                                                                                                
> .setBooleanParameter(
>                                                                                                                                                                
> "http.connection.stalecheck", true);
> 
>                                                                                                
> HttpMethod get = new GetMethod(location);
>                                                                                                
> get.setFollowRedirects(true);
>                                                                                                
> get.getParams().setCookiePolicy(
>                                                                                                                                
> CookiePolicy.BROWSER_COMPATIBILITY);
>                                                                                                
> get.setRequestHeader("Cookie", allCookies);
>                                                                                                
> int rCode = client.executeMethod(get);
> 
> And here's the exception:
> org.apache.commons.httpclient.InvalidRedirectLocationException: Invalid
> redirect location:
> https://logintest.foocomm.com/siteminderagent/nocert/1224689077/smgetcred.scc?TYPE=16777217&REALM=$SM$FoonetApps%20Dev%2fTest%20[08%3a24%3a37%3a8525]&SMAUTHREASON=0&METHOD=GET&SMAGENTNAME=$SM$VIKCnIwFQBmaHrauIuaDE0Vxdt37jIIv5x3U5CdHFaRgnjYIvMJC2kStw8Ioq%2byh&TARGET=$SM$http%3a%2f%2ffoonetapps-test%2efoocomm%2ecom%2fLegalContracts%2fpages%2fcontractsHome%2exhtml
> 
> Looks like HttpClient doesn't like Siteminder URL but I am not clear why
> does client try to process it? Shouldn't it be processed and redirected 
> by the SM agent and not passed to HC at all? What am I missing?
> 
> Regards,
> 
> Bob Stone
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/HttpClient-and-Siteminder-tp20113436p20917262.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org