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

[Closed] RQM: Authentication issue with OSLC coding

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

0 votes


Accepted answer

Permanent link

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

0 votes

Comments

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

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,

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

0 votes

Comments

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




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

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.


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

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

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?

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

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.

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.

 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

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

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

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.

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?

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 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

Question asked: Jun 02 '16, 6:35 a.m.

Question was seen: 2,556 times

Last updated: Sep 01 '16, 11:37 p.m.

Confirmation Cancel Confirm