I got it. It's gotten with:
$client->responseContent()
$ perl ga_rest_ses.pl
{"gabriel":"8D79E9DBCA94436CD26B55D926C57BF9EC3AB595F3524FA2898B4CFD632A712E"}$
$ cat ga_rest_ses.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Config::File::Simple;
use REST::Client;
use MIME::Base64;
use JSON qw//;
use Data::Dumper;
my $pathProp = $ENV{"REST_PROP"};
our $config = new Config::File::Simple($pathProp . ".ga_rest.properties");
my @arrPar = split(/,/, $config->read('restConnection'));
my $headers = {'Connection' => 'close', 'Content-Type' => 'application/json',
Authorization => 'Basic '
. encode_base64($arrPar[1] . ':' . $arrPar[2])};
my $client = REST::Client->new();
$client->setHost($arrPar[0]);
$client->GET('/ga/api/tokens/all', $headers);
my $response = $client->responseCode();
if ($response eq 200) {
print $client->responseContent();
} else {
print Dumper($client) . "\n";
}
-Gabriel
-----Mensaje original-----
De: Gabriel Huerta Araujo
Enviado el: miƩrcoles, 21 de junio de 2023 02:19 p. m.
Para: [email protected]
Asunto: RE: Access to data associated to guac-organization from Java code
>> I want to create a REST Service call (GET), where Guacamole Application
>> gives all users logged(sessionMap attribute(its keys) from
>> HashTokenSessionMap class). First this call is going to be called from a
>> script >> perl. One by one, by its identifier is going to be called other
>> REST Service call (from TokenRESTService.java file). This last call, is also
>> called from Perl script.
>> @DELETE
>> @Path("/{token}")
>> public void invalidateToken(@PathParam("token") String authToken)
>> throws GuacamoleException {
>> // Invalidate session, if it exists
>> if (!authenticationService.destroyGuacamoleSession(authToken))
>> throw new GuacamoleResourceNotFoundException("No such
>> token.");
>> }
>> All this, in order to cancel users of the web application. This will be
>> temporal, meanwhile I finish the logged in users page, similar to the
>> active sessions page
This is REST service call response:
$VAR1 = bless( {
'_res' => bless( {
'_rc' => '200',
'_msg' => '',
'_content' =>
'{"gabriel":"4C78017C80148A5742E32E155D9A072A93AD9FFCFFC92A97FBE8F3B547469475"}',
'_request' => bless( {
'_uri' => bless(
do{\(my $o = 'http://XX.XX.X.XXX:XXX /ga/api/tokens/all')}, 'URI::http' ),
'_headers' => bless(
{
'content-type' => 'application/json',
'content-length' => 0,
'authorization' => 'Basic Y25zc2lzdGU6VDF0NG4zcyE= ',
'connection' => 'close',
'user-agent' => 'REST::Client/281'
}, 'HTTP::Headers' ),
'_method' => 'GET',
'_content' => '',
'_uri_canonical' =>
$VAR1->{'_res'}{'_request'}{'_uri'}
}, 'HTTP::Request' ),
'_headers' => bless( {
'::std_case' => {
'client-response-num' => 'Client-Response-Num',
'client-peer' => 'Client-Peer',
'client-date' => 'Client-Date'
},
'client-response-num' => 1,
'client-date' =>
'Wed, 21 Jun 2023 19:24:30 GMT',
'connection' =>
'close',
'content-type' =>
'application/json',
'client-peer' =>
'XX.XX.X.XXX:XXX',
'date' => 'Wed, 21
Jun 2023 19:24:30 GMT',
'content-length' =>
'78'
}, 'HTTP::Headers' ),
'_protocol' => 'HTTP/1.1'
}, 'HTTP::Response' ),
'_config' => {
'host' => 'http://XX.XX.X.XXX:XXX ',
'useragent' => bless( {
'handlers' => {
'response_header' => bless( [
{
'line' => '/usr/share/perl5/LWP/UserAgent.pm:768',
'callback' => sub { "DUMMY" },
'owner' => 'LWP::UserAgent::parse_head',
'm_media_type' => 'html'
}
], 'HTTP::Config' )
},
'show_progress' =>
undef,
'protocols_allowed' =>
undef,
'max_size' => undef,
'no_proxy' => [],
'timeout' => 300,
'requests_redirectable'
=> [
'GET',
'HEAD'
],
'def_headers' => bless(
{
'user-agent' => 'REST::Client/281'
}, 'HTTP::Headers' ),
'protocols_forbidden'
=> undef,
'max_redirect' => 7,
'send_te' => 1,
'use_eval' => 1,
'ssl_opts' => {
'verify_hostname' => 1
},
'proxy' => {},
'local_address' => undef
}, 'LWP::UserAgent' )
}
}, 'REST::Client' );
From Perl script with $client->responseCode(), I get 200 (which is '_rc' =>
'200'). How can I get field _content?
'_content' =>
'{"gabriel":"4C78017C80148A5742E32E155D9A072A93AD9FFCFFC92A97FBE8F3B547469475"}',
-Gabriel
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
