Need help with an Authentication problem using OSLC Workshop Query RM example for RRC 3.0.1.3
Hello, I am using the Java example of the OSLC workshop (pdf page 134, LAB 6 Chapter 5.7 Query) and run against an existing RRC deployment.
Java to Query RRC using OSLC-RM REST service. In this example there are three steps: 1. Retrieve the Service Providers catalog (does not need authentication: execution ok) 2. Retrieve the designated Service Provider (Project Area) (needs authentication: execution fails) 3. Find the query capability element Step 2 seems to run well (no errors) until the original request is re-executed at which point it ends in an exception. <RRC_Server:Port>, <JTS_Server:Port>, <user>, <password> Schematic of communication: 1. Request resource information
https:// <RRC_Server:Port>/rdm/discovery/RMCatalog
> returns result: 401
Now we have the AuthURL. Then inside doRRCOAuth():
2. Request AuthURL {http.protocol.handle-redirects=false}
In the console I get two warnings:
18-Mar-2013 10:27:53 org.apache.http.impl.client.DefaultRequestDirector handleResponse WARNING: Authentication error: Unable to respond to any of these challenges: {oauth=WWW-Authenticate: OAuth realm="Jazz"} > returns result: 302
Now we have Location. 3. Request Location {http.protocol.handle-redirects=false} > returns result: 200
And now we login:
4. Post https://<JTS_Server:Port>/jts/j_security_check entity = j_username=<user>&j_password=<password> > returns result: 302
We get another location, which looks the same as we requested in action 3 back
5. Request Location {http.protocol.handle-redirects=false}
> returns result: 302
Extract from Location URL the oauth_token, oauth_callback and enter these as parameters in 6 6. Post https://<JTS_Server:Port>/jts/j_security_check
{authorize=true, oauth_callback=https%3A%2F%2F<RRC_Server:Port>%2Frdm%2Fdiscovery%2FRMCatalog%3Frequest_token_secret
> returns result: 200 No headers… 7. Exact retry action 1. See results 1. 401 etc… + Unauthorized Exception…
What I changed to the code was the query split function; it receives a URL and is designed to handle only the query string. It was not returning all the parameters. I am really hoping someone can help me resolve this frustrating issue. Thanks in advance,
|
2 answers
In step 6, you show a POST again to /jts/j_security_check:
6. Post https://<jts_server:port>/jts/j_security_check At that stage, I believe that should be a POST to /jts/oauth-authorize Was that a misprint, or is a second call to /jts/j_security_check being called here instead? Tom Comments
Marc van Leeuwen
commented Mar 21 '13, 1:07 p.m.
Hi Tom,
HttpPost formPost2 = new HttpPost(jtsURI+"/j_security_check");formPost2.getParams().setParameter("oauth_token", oauthToken);formPost2.getParams().setParameter("oauth_callback", oauthCallback);formPost2.getParams().setParameter("authorize", "true");formPost2.addHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");What is missing from the output, my mistake, is the POST header "Content-Type" which was there and I had not printed in the output. What do you think now? Should I change it for /jts/oauth-authorize ? Marc. Tom,
|
Marc, here is my output before submitting the query >> GET(1) https://<servername>:9443/rm/rootservices >> Response Headers: |
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.
Comments
Marc
Example05 works for me as-is against a 3.0.1.x server. I want to understand how you got to your issue. Was Example05 ever working for you? Did it work before you modified the performQuery() method? If so, can you tell me or post what you changed in the method so I can see how that could cause anything.
And what version of the workshop are you running? The latest code was refreshed in Feb 2013.
Hello Rosa,
Here are the answers to your questions:
- I am using the zip file named: 2013-02-11-oslc-workshop.zip
- Example 5 was never fully working for me. For two reasons.
1. getQueryMap(String query) is not build to parse a URL, only the query string part. location3.getValue() returns a URL, oauthToken would be null without adding .split("\?")[1] Because oauth_token is the first query parameter. It could be that you have another first parameter returned in your URL (which will not get mapped correctly then).
2. I never get to performQuery() . In example 5 's void run // step 2 getServiceProvider(catalogURI, projectAreaName) requires authentication (which fails).
- I changed some printing functions to get out more information while debug=true, the results with debug=false remain the same.
Thanks for looking into it. I am sorry you had to wait so long for a response, I assume we are in different parts of the world.
Marc.
Marc,
Let me provide my output and see if it shows any helpful hints when contrasted with your output. If you're willing to post your email, I can send it to you. It's too much to post here.