| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (c) 2002 Graham Barr . All rights reserved. |
|
2
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
3
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Authen::SASL::Perl::PLAIN; |
|
6
|
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
1794
|
use strict; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
236
|
|
|
8
|
5
|
|
|
5
|
|
27
|
use vars qw($VERSION @ISA); |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
3676
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = "2.14"; |
|
11
|
|
|
|
|
|
|
@ISA = qw(Authen::SASL::Perl); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %secflags = ( |
|
14
|
|
|
|
|
|
|
noanonymous => 1, |
|
15
|
|
|
|
|
|
|
); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @tokens = qw(authname user pass); |
|
18
|
|
|
|
|
|
|
|
|
19
|
54
|
|
|
54
|
|
284
|
sub _order { 1 } |
|
20
|
|
|
|
|
|
|
sub _secflags { |
|
21
|
19
|
|
|
19
|
|
34
|
shift; |
|
22
|
19
|
|
|
|
|
152
|
grep { $secflags{$_} } @_; |
|
|
0
|
|
|
|
|
0
|
|
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
7
|
|
|
7
|
0
|
1124
|
sub mechanism { 'PLAIN' } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub client_start { |
|
28
|
5
|
|
|
5
|
0
|
18
|
my $self = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
5
|
|
|
|
|
9
|
$self->{error} = undef; |
|
31
|
5
|
|
|
|
|
8
|
$self->{need_step} = 0; |
|
32
|
|
|
|
|
|
|
|
|
33
|
15
|
|
|
|
|
56
|
my @parts = map { |
|
34
|
5
|
|
|
|
|
10
|
my $v = $self->_call($_); |
|
35
|
15
|
100
|
|
|
|
51
|
defined($v) ? $v : '' |
|
36
|
|
|
|
|
|
|
} @tokens; |
|
37
|
|
|
|
|
|
|
|
|
38
|
5
|
|
|
|
|
22
|
join("\0", @parts); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub server_start { |
|
42
|
24
|
|
|
24
|
0
|
439
|
my $self = shift; |
|
43
|
24
|
|
|
|
|
24
|
my $response = shift; |
|
44
|
24
|
|
100
|
1
|
|
62
|
my $user_cb = shift || sub {}; |
|
|
1
|
|
|
|
|
3
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
24
|
|
|
|
|
34
|
$self->{error} = undef; |
|
47
|
24
|
50
|
|
|
|
45
|
return $self->set_error("No response: Credentials don't match") |
|
48
|
|
|
|
|
|
|
unless defined $response; |
|
49
|
|
|
|
|
|
|
|
|
50
|
24
|
|
|
|
|
26
|
my %parts; |
|
51
|
24
|
|
|
|
|
112
|
@parts{@tokens} = split "\0", $response, scalar @tokens; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# I'm not entirely sure of what I am doing |
|
55
|
24
|
|
|
|
|
114
|
$self->{answer}{$_} = $parts{$_} for qw/authname user/; |
|
56
|
24
|
|
|
|
|
30
|
my $error = "Credentials don't match"; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
## checkpass |
|
59
|
24
|
100
|
|
|
|
71
|
if (my $checkpass = $self->callback('checkpass')) { |
|
|
|
50
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $cb = sub { |
|
61
|
22
|
|
|
22
|
|
1579
|
my $result = shift; |
|
62
|
22
|
100
|
|
|
|
42
|
unless ($result) { |
|
63
|
19
|
|
|
|
|
49
|
$self->set_error($error); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
else { |
|
66
|
3
|
|
|
|
|
15
|
$self->set_success; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
22
|
|
|
|
|
45
|
$user_cb->(); |
|
69
|
22
|
|
|
|
|
67
|
}; |
|
70
|
22
|
|
|
|
|
97
|
$checkpass->($self => { %parts } => $cb ); |
|
71
|
22
|
|
|
|
|
180
|
return; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
## getsecret |
|
75
|
|
|
|
|
|
|
elsif (my $getsecret = $self->callback('getsecret')) { |
|
76
|
|
|
|
|
|
|
my $cb = sub { |
|
77
|
2
|
|
|
2
|
|
6
|
my $good_pass = shift; |
|
78
|
2
|
100
|
50
|
|
|
18
|
if ($good_pass && $good_pass eq ($parts{pass} || "")) { |
|
|
|
|
66
|
|
|
|
|
|
79
|
1
|
|
|
|
|
8
|
$self->set_success; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
else { |
|
82
|
1
|
|
|
|
|
15
|
$self->set_error($error); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
2
|
|
|
|
|
6
|
$user_cb->(); |
|
85
|
2
|
|
|
|
|
6
|
}; |
|
86
|
2
|
|
|
|
|
16
|
$getsecret->( $self, { map { $_ => $parts{$_ } } qw/user authname/ }, $cb ); |
|
|
4
|
|
|
|
|
16
|
|
|
87
|
2
|
|
|
|
|
17
|
return; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
## error by default |
|
91
|
|
|
|
|
|
|
else { |
|
92
|
0
|
|
|
|
|
0
|
$self->set_error($error); |
|
93
|
0
|
|
|
|
|
0
|
$user_cb->(); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |