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

How do you authenticate to an RTC server using LWP?

We just recently upgraded our servers to RHEL 7 and our perl scripts are no longer working. When I run the code below, I'm able to retrieve the root services document for our ccm server, but when I attempt to retrieve the catalog, I get a response telling me that authentication is required again. I run the same code on a different server that is still running RHEL 6 and the script runs perfectly. Why does this script no longer work?

!/usr/bin/perl


use Data::Dumper;
use LWP::UserAgent;
use HTTP::Request::Common;
use HTTP::Cookies;
use XML::Simple;
use MIME::Base64;
use URI::Escape;

*******


User Login Information


*******


my $username = 'username';
my $password = 'password';

*******


Define RTC URL


*******


my $rtc_url = "https://serverlocation:9443/ccm";
my $jts_url = "https://serverlocation:9443/jts";
my $catalog_header = 'oslc_cm:cmServiceProviders';

*******


Set Up User Agent


*******


my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0}, );

my $req = GET "$rtc_url/ccm/authenticated/j_security_check?j_username=$username&j_password=$password";
my $res = $ua->request($req);

*******


Get Root Services


*******


my $req = GET "$rtc_url/rootservices";
my $res = $ua->request($req);

my $content = $res->content;

my $xml = new XML::Simple;
my $root_services_data = $xml->XMLin($content);

*******


Get Project URLs


*******


my $catalog = $root_services_data->{$catalog_header}->{'rdf:resource'};   

my $req = HTTP::Request->new("GET" => "$catalog");
$req->header('Accept', "application/rdf+xml");
$req->header('OSLC-Core-Version', "2.0");

my $res = $ua->request($req);

my $xml = new XML::Simple;
my $catalog_data = $xml->XMLin($res->content,ForceArray => ['oslc:serviceProvider']);
my $projects_hash;
foreach my $project (@{$catalog_data->{'oslc:ServiceProviderCatalog'}->{'oslc:serviceProvider'}})
{
    my $str_project_name        = $project->{'oslc:ServiceProvider'}->{'dcterms:title'}->{'content'};
    my $str_project_details_url = $project->{'oslc:ServiceProvider'}->{'oslc:details'}->{'rdf:resource'};
    $projects_hash{$str_project_name} = $str_project_details_url;
}

0 votes

Comments

Note: The server this script worked on was a RHEL 5 server, not RHEL 6. It won't let me edit it.

What exactly is going wrong ?   I have LWP authenticating to jazz on RHEL 7.  


One thing I don't see in your "setup" :


    push @{ $Browser->requests_redirectable }, 'POST';



"It won't let me edit" ?  Do you mean you cannot save changes ?

It flags my change to the original post as spam and the captcha server is down.

The response I get for the last request call is:

<html >
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=10">
<title></title>

<link type="text/css" rel="stylesheet" href="/ccm/web/_style/?include=D~&etag=ECU0fM4MFTZ_en_US&_proxyURL=%2Fccm&ss=NyjAL">
<link rel="shortcut icon" href="/ccm/web/net.jazz.ajax/jazz.ico">

<style type="text/css">

net-jazz-ajax-NoScriptMessage {


    width: 100%;
    color: #D0D0D0;
    font-size: 2em;
    text-align: center;
    position: absolute;
    top: 1%;
    z-index: 999;
}
</style>

</head>

<body class="claro">
    <noscript><div id="net-jazz-ajax-NoScriptMessage">Javascript is either disabled or not available in your Browser</div></noscript>
    <div id="net-jazz-ajax-InitialLoadMessage">Loading...</div>
    <div id="net-jazz-ajax-WorkbenchRoot"></div>
    
    <script type="text/javascript">
        djConfig = {
            isDebug: false,
            layout: "",
            usePlainJson: true,
            baseUrl: "/ccm/web/dojo/",
            locale: "en-us",
            localizationComplete: true
        };

        /null/
        net = {jazz: {ajax: {}}};
        net.jazz.ajax._contextRoot = "/ccm";
        net.jazz.ajax._appPath = "/ccm/auth/authrequired";
        net.jazz.ajax._webuiPrefix = "/web/";
    </script>
    
    <script type="text/javascript" src="/ccm/web/_js/?include=D~&etag=ECU0fM4MFTZ_en_US&_pr
oxyURL=%2Fccm&ss=NyjAL&locale=en-us"></script>

<script type="text/javascript">
require("dojo/main").getObject('jazz.core.loader', true)._serverStartup="NyjAL";
require("dojo/main").getObject('jazz.core.loader',true)._loaded=["D"];
</script>

    <script type="text/javascript">
    / <![CDATA[ /
        dojo.addOnLoad( function() {
            net.jazz.ajax.ui.PlatformUI.createAndRunWorkbench("net.jazz.web.app.authrequired");
        });
    / ]]> /
    </script>
</body>
</html>

showing 5 of 6 show 1 more comments

Be the first one to answer this question!

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,940
× 516

Question asked: Nov 05 '18, 1:08 p.m.

Question was seen: 1,546 times

Last updated: Nov 05 '18, 1:57 p.m.

Confirmation Cancel Confirm