line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*- |
2
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4: |
3
|
|
|
|
|
|
|
package CPAN::HTTP::Credentials; |
4
|
13
|
|
|
13
|
|
80
|
use strict; |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
455
|
|
5
|
13
|
|
|
13
|
|
64
|
use vars qw($USER $PASSWORD $PROXY_USER $PROXY_PASSWORD); |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
6482
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$CPAN::HTTP::Credentials::VERSION = $CPAN::HTTP::Credentials::VERSION = "1.9601"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub clear_credentials { |
10
|
0
|
|
|
0
|
0
|
0
|
clear_non_proxy_credentials(); |
11
|
0
|
|
|
|
|
0
|
clear_proxy_credentials(); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub clear_non_proxy_credentials { |
15
|
0
|
|
|
0
|
0
|
0
|
undef $USER; |
16
|
0
|
|
|
|
|
0
|
undef $PASSWORD; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub clear_proxy_credentials { |
20
|
0
|
|
|
0
|
0
|
0
|
undef $PROXY_USER; |
21
|
0
|
|
|
|
|
0
|
undef $PROXY_PASSWORD; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub get_proxy_credentials { |
25
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
26
|
2
|
0
|
33
|
|
|
10
|
if ($PROXY_USER && $PROXY_PASSWORD) { |
27
|
0
|
|
|
|
|
0
|
return ($PROXY_USER, $PROXY_PASSWORD); |
28
|
|
|
|
|
|
|
} |
29
|
2
|
50
|
33
|
|
|
16
|
if ( defined $CPAN::Config->{proxy_user} |
30
|
|
|
|
|
|
|
&& $CPAN::Config->{proxy_user} |
31
|
|
|
|
|
|
|
) { |
32
|
2
|
|
|
|
|
6
|
$PROXY_USER = $CPAN::Config->{proxy_user}; |
33
|
2
|
|
50
|
|
|
7
|
$PROXY_PASSWORD = $CPAN::Config->{proxy_pass} || ""; |
34
|
2
|
|
|
|
|
10
|
return ($PROXY_USER, $PROXY_PASSWORD); |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
0
|
my $username_prompt = "\nProxy authentication needed! |
37
|
|
|
|
|
|
|
(Note: to permanently configure username and password run |
38
|
|
|
|
|
|
|
o conf proxy_user your_username |
39
|
|
|
|
|
|
|
o conf proxy_pass your_password |
40
|
|
|
|
|
|
|
)\nUsername:"; |
41
|
0
|
|
|
|
|
0
|
($PROXY_USER, $PROXY_PASSWORD) = |
42
|
|
|
|
|
|
|
_get_username_and_password_from_user($username_prompt); |
43
|
0
|
|
|
|
|
0
|
return ($PROXY_USER,$PROXY_PASSWORD); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub get_non_proxy_credentials { |
47
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
48
|
1
|
0
|
33
|
|
|
6
|
if ($USER && $PASSWORD) { |
49
|
0
|
|
|
|
|
0
|
return ($USER, $PASSWORD); |
50
|
|
|
|
|
|
|
} |
51
|
1
|
50
|
|
|
|
4
|
if ( defined $CPAN::Config->{username} ) { |
52
|
1
|
|
|
|
|
3
|
$USER = $CPAN::Config->{username}; |
53
|
1
|
|
50
|
|
|
4
|
$PASSWORD = $CPAN::Config->{password} || ""; |
54
|
1
|
|
|
|
|
5
|
return ($USER, $PASSWORD); |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
my $username_prompt = "\nAuthentication needed! |
57
|
|
|
|
|
|
|
(Note: to permanently configure username and password run |
58
|
|
|
|
|
|
|
o conf username your_username |
59
|
|
|
|
|
|
|
o conf password your_password |
60
|
|
|
|
|
|
|
)\nUsername:"; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
($USER, $PASSWORD) = |
63
|
|
|
|
|
|
|
_get_username_and_password_from_user($username_prompt); |
64
|
0
|
|
|
|
|
|
return ($USER,$PASSWORD); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _get_username_and_password_from_user { |
68
|
0
|
|
|
0
|
|
|
my $username_message = shift; |
69
|
0
|
|
|
|
|
|
my ($username,$password); |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
ExtUtils::MakeMaker->import(qw(prompt)); |
72
|
0
|
|
|
|
|
|
$username = prompt($username_message); |
73
|
0
|
0
|
|
|
|
|
if ($CPAN::META->has_inst("Term::ReadKey")) { |
74
|
0
|
|
|
|
|
|
Term::ReadKey::ReadMode("noecho"); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
0
|
|
|
|
|
|
$CPAN::Frontend->mywarn( |
78
|
|
|
|
|
|
|
"Warning: Term::ReadKey seems not to be available, your password will be echoed to the terminal!\n" |
79
|
|
|
|
|
|
|
); |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
$password = prompt("Password:"); |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ($CPAN::META->has_inst("Term::ReadKey")) { |
84
|
0
|
|
|
|
|
|
Term::ReadKey::ReadMode("restore"); |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
|
$CPAN::Frontend->myprint("\n\n"); |
87
|
0
|
|
|
|
|
|
return ($username,$password); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|