From 3b5b2f43eba915af48054b883f3e98fdc140dfb3 Mon Sep 17 00:00:00 2001 From: Florian Asche Date: Tue, 15 Apr 2014 12:44:20 +0200 Subject: [PATCH] Refs #5385 : Removed Realm --- apps/tomcat/web/mode/application.pm | 5 --- apps/tomcat/web/mode/libconnect.pm | 45 ++++++++++--------------- apps/tomcat/web/mode/listapplication.pm | 5 --- apps/tomcat/web/mode/sessions.pm | 5 --- 4 files changed, 17 insertions(+), 43 deletions(-) diff --git a/apps/tomcat/web/mode/application.pm b/apps/tomcat/web/mode/application.pm index 02ba72446..9fc319040 100644 --- a/apps/tomcat/web/mode/application.pm +++ b/apps/tomcat/web/mode/application.pm @@ -60,7 +60,6 @@ sub new { "proxyurl:s" => { name => 'proxyurl' }, "timeout:s" => { name => 'timeout', default => '3' }, "path:s" => { name => 'path', default => '/manager/text/list' }, - "realm:s" => { name => 'realm', default => 'Tomcat Manager Application' }, "name:s" => { name => 'name' }, "regexp" => { name => 'use_regexp' }, "regexp-isensitive" => { name => 'use_regexpi' }, @@ -204,10 +203,6 @@ Specify username for basic authentification (Mandatory if --credentials is speci Specify password for basic authentification (Mandatory if --credentials is specidied) -=item B<--realm> - -Credentials Realm (Default: 'Tomcat Manager Application') - =item B<--timeout> Threshold for HTTP timeout diff --git a/apps/tomcat/web/mode/libconnect.pm b/apps/tomcat/web/mode/libconnect.pm index 50528ab07..9955483b6 100644 --- a/apps/tomcat/web/mode/libconnect.pm +++ b/apps/tomcat/web/mode/libconnect.pm @@ -43,43 +43,32 @@ use LWP::UserAgent; sub connect { my ($self, %options) = @_; - my $ua = LWP::UserAgent->new( protocols_allowed => ['http','https'], timeout => $self->{option_results}->{timeout}); + my $ua = LWP::UserAgent->new( protocols_allowed => ['http', 'https'], timeout => $self->{option_results}->{timeout}); my $connection_exit = defined($options{connection_exit}) ? $options{connection_exit} : 'unknown'; - my $response; - my $content; + my ($response, $content); - if (defined $self->{option_results}->{credentials}) { - #$ua->credentials($self->{option_results}->{hostname}.':'.$self->{option_results}->{port},$self->{option_results}->{username},$self->{option_results}->{password}); - $ua->credentials($self->{option_results}->{hostname}.':'.$self->{option_results}->{port},$self->{option_results}->{realm},$self->{option_results}->{username},$self->{option_results}->{password}); + my $req = HTTP::Request->new( GET => $self->{option_results}->{proto}."://" .$self->{option_results}->{hostname}.':'.$self->{option_results}->{port}.$self->{option_results}->{path}); + + if (defined($self->{option_results}->{credentials})) { + $req->authorization_basic($self->{option_results}->{username}, $self->{option_results}->{password}); } - if ($self->{option_results}->{proto} eq "https") { - if (defined $self->{option_results}->{proxyurl}) { - $ua->proxy(['https'], $self->{option_results}->{proxyurl}); - $response = $ua->get('https://'.$self->{option_results}->{hostname}.':'.$self->{option_results}->{port}.$self->{option_results}->{path}); - } else { - $response = $ua->get('https://'.$self->{option_results}->{hostname}.':'.$self->{option_results}->{port}.$self->{option_results}->{path}); - } - } else { - if (defined $self->{option_results}->{proxyurl}) { - $ua->proxy(['http'], $self->{option_results}->{proxyurl}); - $response = $ua->get($self->{option_results}->{proto}."://" .$self->{option_results}->{hostname}.$self->{option_results}->{path}); - } else { - $response = $ua->get('http://'.$self->{option_results}->{hostname}.':'.$self->{option_results}->{port}.$self->{option_results}->{path}); - } + if (defined($self->{option_results}->{proxyurl})) { + $ua->proxy(['http', 'https'], $self->{option_results}->{proxyurl}); } + + $response = $ua->request($req); - if ($response->is_success) { + if ($response->is_success) { $content = $response->content; return $content; - } else { - $self->{output}->output_add(severity => $connection_exit, - short_msg => $response->status_line); - $self->{output}->display(); - $self->{output}->exit(); - } - + } + + $self->{output}->output_add(severity => $connection_exit, + short_msg => $response->status_line); + $self->{output}->display(); + $self->{output}->exit(); } 1; diff --git a/apps/tomcat/web/mode/listapplication.pm b/apps/tomcat/web/mode/listapplication.pm index 0a16c8273..e4383835d 100644 --- a/apps/tomcat/web/mode/listapplication.pm +++ b/apps/tomcat/web/mode/listapplication.pm @@ -60,7 +60,6 @@ sub new { "proxyurl:s" => { name => 'proxyurl' }, "timeout:s" => { name => 'timeout', default => '3' }, "path:s" => { name => 'path', default => '/manager/text/list' }, - "realm:s" => { name => 'realm', default => 'Tomcat Manager Application' }, "filter-name:s" => { name => 'filter_name', }, "filter-state:s" => { name => 'filter_state', }, "filter-path:s" => { name => 'filter_path', }, @@ -181,10 +180,6 @@ Specify username for basic authentification (Mandatory if --credentials is speci Specify password for basic authentification (Mandatory if --credentials is specidied) -=item B<--realm> - -Credentials Realm (Default: 'Tomcat Manager Application') - =item B<--timeout> Threshold for HTTP timeout diff --git a/apps/tomcat/web/mode/sessions.pm b/apps/tomcat/web/mode/sessions.pm index 8c7b846fb..8384aaf69 100644 --- a/apps/tomcat/web/mode/sessions.pm +++ b/apps/tomcat/web/mode/sessions.pm @@ -60,7 +60,6 @@ sub new { "proxyurl:s" => { name => 'proxyurl' }, "timeout:s" => { name => 'timeout', default => '3' }, "path:s" => { name => 'path', default => '/manager/text/list' }, - "realm:s" => { name => 'realm', default => 'Tomcat Manager Application' }, "warning:s" => { name => 'warning' }, "critical:s" => { name => 'critical' }, "name:s" => { name => 'name' }, @@ -207,10 +206,6 @@ Specify username for basic authentification (Mandatory if --credentials is speci Specify password for basic authentification (Mandatory if --credentials is specidied) -=item B<--realm> - -Credentials Realm (Default: 'Tomcat Manager Application') - =item B<--timeout> Threshold for HTTP timeout