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
|
|
|
|
|
|
|
$Authen::SASL::Perl::PLAIN::VERSION = '2.1700'; # TRIAL |
7
|
5
|
|
|
5
|
|
1442
|
use strict; |
|
5
|
|
|
|
|
46
|
|
|
5
|
|
|
|
|
152
|
|
8
|
5
|
|
|
5
|
|
26
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
186
|
|
9
|
5
|
|
|
5
|
|
27
|
use vars qw($VERSION @ISA); |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
3054
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = "2.14"; |
12
|
|
|
|
|
|
|
@ISA = qw(Authen::SASL::Perl); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my %secflags = ( |
15
|
|
|
|
|
|
|
noanonymous => 1, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @tokens = qw(authname user pass); |
19
|
|
|
|
|
|
|
|
20
|
47
|
|
|
47
|
|
101
|
sub _order { 1 } |
21
|
|
|
|
|
|
|
sub _secflags { |
22
|
19
|
|
|
19
|
|
31
|
shift; |
23
|
19
|
|
|
|
|
94
|
grep { $secflags{$_} } @_; |
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
7
|
|
|
7
|
0
|
643
|
sub mechanism { 'PLAIN' } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub client_start { |
29
|
5
|
|
|
5
|
0
|
19
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
5
|
|
|
|
|
9
|
$self->{error} = undef; |
32
|
5
|
|
|
|
|
7
|
$self->{need_step} = 0; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my @parts = map { |
35
|
5
|
|
|
|
|
12
|
my $v = $self->_call($_); |
|
15
|
|
|
|
|
45
|
|
36
|
15
|
100
|
|
|
|
48
|
defined($v) ? $v : '' |
37
|
|
|
|
|
|
|
} @tokens; |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
|
|
32
|
join("\0", @parts); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub server_start { |
43
|
24
|
|
|
24
|
0
|
462
|
my $self = shift; |
44
|
24
|
|
|
|
|
41
|
my $response = shift; |
45
|
24
|
|
100
|
1
|
|
61
|
my $user_cb = shift || sub {}; |
46
|
|
|
|
|
|
|
|
47
|
24
|
|
|
|
|
43
|
$self->{error} = undef; |
48
|
24
|
50
|
|
|
|
48
|
return $self->set_error("No response: Credentials don't match") |
49
|
|
|
|
|
|
|
unless defined $response; |
50
|
|
|
|
|
|
|
|
51
|
24
|
|
|
|
|
30
|
my %parts; |
52
|
24
|
|
|
|
|
107
|
@parts{@tokens} = split "\0", $response, scalar @tokens; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# I'm not entirely sure of what I am doing |
56
|
24
|
|
|
|
|
100
|
$self->{answer}{$_} = $parts{$_} for qw/authname user/; |
57
|
24
|
|
|
|
|
38
|
my $error = "Credentials don't match"; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
## checkpass |
60
|
24
|
100
|
|
|
|
70
|
if (my $checkpass = $self->callback('checkpass')) { |
|
|
50
|
|
|
|
|
|
61
|
|
|
|
|
|
|
my $cb = sub { |
62
|
22
|
|
|
22
|
|
2264
|
my $result = shift; |
63
|
22
|
100
|
|
|
|
58
|
unless ($result) { |
64
|
19
|
|
|
|
|
58
|
$self->set_error($error); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else { |
67
|
3
|
|
|
|
|
14
|
$self->set_success; |
68
|
|
|
|
|
|
|
} |
69
|
22
|
|
|
|
|
42
|
$user_cb->(); |
70
|
22
|
|
|
|
|
75
|
}; |
71
|
22
|
|
|
|
|
116
|
$checkpass->($self => { %parts } => $cb ); |
72
|
22
|
|
|
|
|
187
|
return; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
## getsecret |
76
|
|
|
|
|
|
|
elsif (my $getsecret = $self->callback('getsecret')) { |
77
|
|
|
|
|
|
|
my $cb = sub { |
78
|
2
|
|
|
2
|
|
6
|
my $good_pass = shift; |
79
|
2
|
100
|
50
|
|
|
11
|
if ($good_pass && $good_pass eq ($parts{pass} || "")) { |
|
|
|
66
|
|
|
|
|
80
|
1
|
|
|
|
|
6
|
$self->set_success; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
else { |
83
|
1
|
|
|
|
|
6
|
$self->set_error($error); |
84
|
|
|
|
|
|
|
} |
85
|
2
|
|
|
|
|
12
|
$user_cb->(); |
86
|
2
|
|
|
|
|
7
|
}; |
87
|
2
|
|
|
|
|
4
|
$getsecret->( $self, { map { $_ => $parts{$_ } } qw/user authname/ }, $cb ); |
|
4
|
|
|
|
|
16
|
|
88
|
2
|
|
|
|
|
19
|
return; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
## error by default |
92
|
|
|
|
|
|
|
else { |
93
|
0
|
|
|
|
|
|
$self->set_error($error); |
94
|
0
|
|
|
|
|
|
$user_cb->(); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |