It's all about the answers!

Ask a question

[Closed] RQM: Authentication issue with OSLC coding


Kumar Kumar (6427) | asked Jun 02 '16, 6:35 a.m.
edited Sep 01 '16, 11:37 p.m.
Hello,

I am trying to read RQM data using OSLC rest api. its reading an error message in text/html type. (I am not able to post it here)

For me It looks to be authentication problem. it Reports - "Java script is either disabled or not available in your Browser".

I have taken care of all the settings required in the browser & Java, still I am getting the same error.
I am able to read the root services which doesn't needs login but for other services which needs login, I get the above error.

I am able to read the data from REST CLIENT and I have authentication problem only with JAVA.


Can any one help me to solve this issue.

Thanks in advance

Accepted answer


permanent link
Stefan Oblinger (185213) | answered Jun 07 '16, 1:42 a.m.
edited Jun 07 '16, 1:43 a.m.

Please read the documentation carefully and place an equality sign between option and value:

-qm=https://internalserver.com:443/qm/

Kumar Kumar selected this answer as the correct answer

Comments
Kumar Kumar commented Jun 07 '16, 1:59 a.m.

I tried the same -qm=https://internalserver.com:443/qm/ Reported below error : SEVERE: java.lang.IllegalArgumentException: -qualityManagerURL requires a valid IBM Rational Quality Manager server URL java.lang.IllegalArgumentException: -qualityManagerURL requires a valid IBM Rati onal Quality Manager server URL at com.ibm.rqm.api.APIUtility.main(APIUtility.java:173)

RQM API Utility has terminated due to an error.

Note: same path I am able to open it in browser.

I tried with the space: -qm = https://internalserver.com:443/qm/ Got the same error as previous : -qualityManagerURL requires a value


Kumar Kumar commented Jun 07 '16, 3:39 a.m.

Its working I had missed -o at the end.

Now I need to find the better way to extract the test cases from specific Test plans.

Thanks,


Kumar Kumar commented Jun 07 '16, 10:27 p.m. | edited Jun 07 '16, 11:08 p.m.

I tried the same code in commandline through Java - It literally hangs, String[] cmd = { javapath, "-jar","C:\Users\cra6kor\Downloads\RQMAPIUtility\RQMAPIUtility.jar","-c=findProjectsWithRequirements","-qm=https://internalserver.com:443/qm","-u='username'","-pw=password","-o"}; Process p = Runtime.getRuntime().exec(cmd); p.waitFor(); InputStream stdin = p.getInputStream(); InputStreamReader isr = new InputStreamReader(stdin); BufferedReader br = new BufferedReader(isr); String line = null; System.out.println(" <output> "); while ( (line = br.readLine()) != null) System.out.println(line); </output>

One other answer



permanent link
Paul Slauenwhite (8.4k12) | answered Jun 02 '16, 9:36 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
You are probably seeing the HTML login page for RQM, if you haven't authenticated correctly with the RQM server.  You can use the authentication code (com.ibm.rqm.cleaner.internal.client.JazzHttpClient.login(Credential)) from the OSLC Cleaner Utility.                                             

Comments
Kumar Kumar commented Jun 03 '16, 1:04 a.m.

I don't see the option login.
I have imported the jar file from OSLC cleaner Utility.





Paul Slauenwhite commented Jun 03 '16, 10:17 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

 If you are using the OSLC Cleaner Utility, you need to specify your credentials on the command line (see the readme.txt).


Kumar Kumar commented Jun 06 '16, 4:41 a.m.

I tried with the commandline as mentioned in the readme.txt
C:\ProgramFiles\Java\jre8\bin>java.exe -jar C:\Users\cra6kor\Downloads\RQ
MAPIUtility\RQMAPIUtility.jar -qm "https://internalserver.com:443/" -u xa
xaxa -pw yyyyyyy

Reported below error: com.ibm.rqm.api.internal.util.LogUtils logError
SEVERE: java.lang.IllegalArgumentException: -qualityManagerURL requires a value
java.lang.IllegalArgumentException: -qualityManagerURL requires a value
        at com.ibm.rqm.api.APIUtility.processArgs(APIUtility.java:452)
        at com.ibm.rqm.api.APIUtility.main(APIUtility.java:108)

RQM API Utility has terminated due to an error.



Paul Slauenwhite commented Jun 06 '16, 3:24 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

 As noted in the error message, you need to specify a value for the  -qualityManagerURL argument.  Please see the readme.txt.


Kumar Kumar commented Jun 06 '16, 10:31 p.m. | edited Jun 06 '16, 10:32 p.m.

In the readme.txt :
-qm, -qualityManagerURL=<URL>
    The fully specified URL (including a trailing forward slash character) to the IBM Rational Quality Manager server: https://<server>:<port>/<context root>/

I have provided
-qm "https://internalserver.com:443/"
and I tried -qm "https://internalserver.com:443/qm/oslc_qm/catalog/" still the same error.
I am not able to understand what I am missing here


Kumar Kumar commented Jun 07 '16, 1:03 a.m.

I am bit confused with the RQM authentication.

I am able to access through HttpRequester, Rest api client but if I try the Http request with Java code, reports an error - "Javascript is either disabled or not available in your Browser".

Now I am trying the same with commandline still I get the problem with qm value.

which one is a working format, Httprequest or RQMUtility with commandline is a big question for me?


Donald Nong commented Jun 07 '16, 1:36 a.m.

When you develop your own code, you need to be mindful with the HTTP headers. If you use other tools or browsers, they send some particular HTTP headers by default. If you keep getting the text/html format response, it is probable that you have not sent the correct HTTP header to the RQM server. Refer to the below document for details about the HTTP headers.
https://jazz.net/wiki/bin/view/Main/RqmApi#Headers


Kumar Kumar commented Jun 07 '16, 2:10 a.m.

Hello, I have followed it as it is, below is my code

this.rqmHost = new HttpHost("internalserver.com", 443 , "https"); UsernamePasswordCredentials creds = new UsernamePasswordCredentials( "username", "password"); this.context = HttpClientContext.create();

HttpGet rootServiceDoc = new HttpGet("/qm/oslc_qm/catalog"); rootServiceDoc.addHeader("OSLC-Core-Version", "2.0"); rootServiceDoc.addHeader("Content-Type", "application/rdf+xml"); rootServiceDoc.addHeader("Accept", "application/rdf+xml");

rootServiceDoc.addHeader(BasicScheme.authenticate(creds,"UTF-8",false));

HttpClient httpclient = new DefaultHttpClient(); HttpUtils.setupLazySSLSupport(httpclient);

rootServiceResponse = httpclient.execute(this.rqmHost, rootServiceDoc, this.context);

Kindly let me know if you found something missing.


Paul Slauenwhite commented Jun 07 '16, 7:49 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

Your argument (-qm "https://internalserver.com:443/") has two issues:


-No equals sign.
-No context root.

The correct argument is:

-qm="https://internalserver.com:443/qm"

See the Usage Examples in the readme.txt.


Paul Slauenwhite commented Jun 07 '16, 7:52 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

 Your code looks fine from a REST perspective, but your not handling the authentication with the RQM server.  Please see the com.ibm.rqm.cleaner.internal.client.JazzHttpClient.login(Credential) method from the OSLC Cleaner Utility source


Kumar Kumar commented Jun 07 '16, 10:24 p.m.

com.ibm.rqm.cleaner.internal.client.JazzHttpClient.login(Credential) can't be used directly as login is a protected method inside the abstract class JazzHttpClient in RQMAPIUtility.jar.

I have extended my class to use it. Please see my main functioncode below, serverUrl = new URL("https://internalserver:443/qm"); testplan_ver2 d= new testplan_ver2(serverUrl); d.login(credential);

HttpResponse rootServiceResponse = Connection.INSTANCE.executeGetService(); if (rootServiceResponse.getStatusLine().getStatusCode() != 200) { EntityUtils.consume(rootServiceResponse.getEntity()); throw new HttpResponseException(rootServiceResponse.getStatusLine().getStatusCode(), rootServiceResponse.getStatusLine().getReasonPhrase()); } }

It reports the below error: Unable to create SSL_TLS context, trying SSLv3 Exception in thread "main" java.lang.NullPointerException at com.ibm.rqm.cleaner.internal.client.JazzHttpClient.fixMethodHeader(JazzHttpClient.java:249)

could you please let me know what is missing in my code


Paul Slauenwhite commented Jun 08 '16, 8:27 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

 Chethan, you need to debug your Java code to determine the root cause of this exception.  


Kumar Kumar commented Jun 08 '16, 10:36 p.m. | edited Jun 08 '16, 10:45 p.m.

I debugged it,
trouble with the function:
    private void fixMethodHeader(HttpMethodBase method){     
        Map<String, String> requestHeaders = getRequestHeaders();       
        for(String name : requestHeaders.keySet()){
            method.setRequestHeader(name, requestHeaders.get(name));           
        }
    }
I think the problem is "requestHeaders" is null always. I am not able to understand why getRequestHeaders() is returning null.

methode data:
Auth state: auth requested [false]; auth attempted [false] preemptive [false]
https://internalserver.com
null,[]
org.apache.commons.httpclient.params.HttpMethodParams@2667f029
/qm/j_security_check
Auth state: auth requested [false]; auth attempted [false] preemptive [false]

have deleted few data because of the space constraint
could you help me.


Donald Nong commented Jun 08 '16, 10:43 p.m.

You set the request headers before making a request. The server sets the response headers before sending the response back. Do you set the request headers at all anywhere in your code?


Kumar Kumar commented Jun 08 '16, 11:24 p.m. | edited Jun 09 '16, 12:09 a.m.

I have set the Header had missed the function: Map<String, String> getRequestHeaders();
Now I am getting ERROR com.ibm.rqm.cleaner.internal.Cleaner: login error (response code) - 401.
Actually the response code is 302 but it was changed in the if condition to 401.


showing 5 of 15 show 10 more comments

Your answer


Register or 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.