| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package LWP::AuthenAgent; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#============================================================================== |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Start of POD |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
#============================================================================== |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
LWP::AuthenAgent - a simple subclass of LWP::UserAgent to allow the user to |
|
12
|
|
|
|
|
|
|
type in username / password information if required for autentication. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use LWP::AuthenAgent; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $ua = new LWP::AuthenAgent; |
|
19
|
|
|
|
|
|
|
my $response = $ua->request( new HTTP::Request 'GET' => $url ); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
LWP::AuthenAgent simple overloads the get_basic_credentials method of |
|
24
|
|
|
|
|
|
|
LWP::UserAgent. It prompts the user for username / passsword for a given realm, |
|
25
|
|
|
|
|
|
|
supressing tty echoing of the password. Authentication details are stored |
|
26
|
|
|
|
|
|
|
in the object for each realm, so that they can be re-used in subsequest |
|
27
|
|
|
|
|
|
|
requests for the same realm, if necessary. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
LWP::AuthenAgent inherits all the methods available in LWP::UserAgent. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
LWP::UserAgent |
|
36
|
|
|
|
|
|
|
Term::ReadKey |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 AUTHOR |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Ave Wrigley EAve.Wrigley@itn.co.ukE |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Copyright (c) 1997 Canon Research Centre Europe (CRE). All rights reserved. |
|
45
|
|
|
|
|
|
|
This script and any associated documentation or files cannot be distributed |
|
46
|
|
|
|
|
|
|
outside of CRE without express prior permission from CRE. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
#============================================================================== |
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# End of POD |
|
53
|
|
|
|
|
|
|
# |
|
54
|
|
|
|
|
|
|
#============================================================================== |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
1
|
|
1932
|
use Term::ReadKey; |
|
|
1
|
|
|
|
|
6822
|
|
|
|
1
|
|
|
|
|
130
|
|
|
57
|
1
|
|
|
1
|
|
16
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
31
|
|
|
58
|
1
|
|
|
1
|
|
7
|
use vars qw( $VERSION @ISA ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
406
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$VERSION = '0.001'; |
|
61
|
|
|
|
|
|
|
@ISA = qw( LWP::UserAgent ); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
64
|
|
|
|
|
|
|
# |
|
65
|
|
|
|
|
|
|
# overload get_basic_credentials method |
|
66
|
|
|
|
|
|
|
# |
|
67
|
|
|
|
|
|
|
#------------------------------------------------------------------------------ |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub get_basic_credentials |
|
70
|
|
|
|
|
|
|
{ |
|
71
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
72
|
0
|
|
|
|
|
|
my $realm = shift; |
|
73
|
0
|
|
|
|
|
|
my $uri = shift; |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
local( $| ) = 1; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
0
|
0
|
|
|
|
unless ( |
|
78
|
|
|
|
|
|
|
$self->{ 'username' }{ $realm } and |
|
79
|
|
|
|
|
|
|
$self->{ 'password' }{ $realm } |
|
80
|
|
|
|
|
|
|
) |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
0
|
|
|
|
|
|
print "\n\nAuthenticating URI $uri in realm $realm\n\n"; |
|
83
|
0
|
|
|
|
|
|
do { |
|
84
|
0
|
|
|
|
|
|
print "Enter username : "; |
|
85
|
0
|
|
|
|
|
|
$self->{ 'username' }{ $realm } = ; |
|
86
|
0
|
|
|
|
|
|
chomp( $self->{ 'username' }{ $realm } ); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
until ( length $self->{ 'username' }{ $realm } ); |
|
89
|
0
|
|
|
|
|
|
do { |
|
90
|
0
|
|
|
|
|
|
print "Enter password : "; |
|
91
|
0
|
|
|
|
|
|
ReadMode 'noecho'; |
|
92
|
0
|
|
|
|
|
|
$self->{ 'password' }{ $realm } = ; |
|
93
|
0
|
|
|
|
|
|
ReadMode 'normal'; |
|
94
|
0
|
|
|
|
|
|
print "\n"; # because we disabled echo |
|
95
|
0
|
|
|
|
|
|
chomp( $self->{ 'password' }{ $realm } ); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
until ( length $self->{ 'password' }{ $realm } ); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
0
|
|
|
|
|
|
return ( $self->{ 'username' }{ $realm }, $self->{ 'password' }{ $realm } ); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
#============================================================================== |
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
# Return TRUE |
|
105
|
|
|
|
|
|
|
# |
|
106
|
|
|
|
|
|
|
#============================================================================== |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |