Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Problems with Form Based Authentication in Java

I want to use REST to query and update work items in RTC 2.0.0.2. I looked at some guides to get a good concept of it:
http://jazz.net/library/article/352
https://jazz.net/wiki/bin/view/Main/ResourceOrientedWorkItemAPIv2#Form_based_authentication_using

I'm trying to use the discovery chain and I can get the catalog link successfully from rootservices. But to access the catalog, I would need to be authenticated, which is where I'm stuck.

I tried following this guide for form based authentication, but I'm not having any luck. Tomcat 5 is the application server.

I outputted my cookie store and I can see that it has a JSESSIONID and JazzFormAuth.

httpClient = new DefaultHttpClient();

CookieStore cookieStore = new BasicCookieStore();
localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE,cookieStore);
HttpGet httpGetID = new HttpGet("http://"+rtcHost+":"+rtcPort+"/jazz/authenticated/identity");
httpClient.execute(httpGetID, localContext);
httpGetID.abort();
List<NameValuePair> authFormParams = new ArrayList<NameValuePair>();
authFormParams.add(new BasicNameValuePair("j_username", rtcUsername));
authFormParams.add(new BasicNameValuePair("j_password", rtcPassword));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(authFormParams, "UTF-8");
HttpPost httpPostAuth = new HttpPost("http://"+rtcHost+":"+rtcPort+"/jazz/authenticated/j_security_check");
httpPostAuth.setEntity(entity);
httpClient.execute(httpPostAuth, localContext);
httpPostAuth.abort();

HttpGet httpget = new HttpGet("http://"+rtcHost+":"+rtcPort+"/jazz/oslc/workitems/catalog");
httpget.setHeader("Accept", "text/xml");
HttpResponse response = httpClient.execute(httpget, localContext);
httpget.abort();

0 votes



One answer

Permanent link
Resolved.

After authenticating (posting to j_security_check), you need hit another page (ex. identity) to receive the another cookie:
X-com-ibm-team-foundation-auth-loop-avoidance=false

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Mar 03 '11, 4:01 p.m.

Question was seen: 6,162 times

Last updated: Mar 03 '11, 4:01 p.m.

Confirmation Cancel Confirm