| 1 | # Copyright (c) 2002 Graham Barr <gbarr@pobox.com>. 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::LOGIN 2.2100; | ||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use vars qw(@ISA); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 4 | @ISA = qw(Authen::SASL::Perl); | |||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||
| 13 | 4 | my %secflags = ( | |||||||||||||||||||||||||||||||||||||
| 14 | noanonymous => 1, | ||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||
| 17 | 39 | ▶ | sub _order { 1 } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_order: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 18 | 18 | ▶ | sub _secflags { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_secflags: called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||
| 19 | 18 | shift; | |||||||||||||||||||||||||||||||||||||
| 20 | 0 | scalar grep { $secflags{$_} } @_; | |||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||
| 23 | 5 | ▶ | sub mechanism { 'LOGIN' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
mechanism: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 4 | ▶ | sub client_start { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
client_start: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 26 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 27 | 4 | $self->{stage} = 0; | |||||||||||||||||||||||||||||||||||||
| 28 | 4 | ''; | |||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | 9 | ▶ | sub client_step { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
client_step: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 32 | 9 | my ($self, $string) = @_; | |||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||
| 34 | # XXX technically this is wrong. I might want to change that. | ||||||||||||||||||||||||||||||||||||||
| 35 | # spec say it's "staged" and that the content of the challenge doesn't | ||||||||||||||||||||||||||||||||||||||
| 36 | # matter | ||||||||||||||||||||||||||||||||||||||
| 37 | # actually, let's try | ||||||||||||||||||||||||||||||||||||||
| 38 | 9 | my $stage = ++$self->{stage}; | |||||||||||||||||||||||||||||||||||||
| 39 | 9 | ▶ | if ($stage == 1) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||
| 40 | 4 | return $self->_call('user'); | |||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||
| 42 | elsif ($stage == 2) { | ||||||||||||||||||||||||||||||||||||||
| 43 | 4 | return $self->_call('pass'); | |||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||
| 45 | elsif ($stage == 3) { | ||||||||||||||||||||||||||||||||||||||
| 46 | 1 | $self->set_success; | |||||||||||||||||||||||||||||||||||||
| 47 | 1 | return; | |||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||||||||||||||||||
| 50 | 0 | return $self->set_error("Invalid sequence"); | |||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||
| 54 | 9 | ▶ | sub server_start { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
server_start: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 55 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 56 | 9 | my $response = shift; | |||||||||||||||||||||||||||||||||||||
| 57 | 9 | ▶ | my $user_cb = shift || sub {}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
shift() || sub {
}
MC/DC0%0/2
shift() || sub {
}
shift()
sub {
}
Truth table33%1/3
A || B
A= shift()B= sub {
}
| |||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | 9 | $self->{answer} = {}; | |||||||||||||||||||||||||||||||||||||
| 60 | 9 | $self->{stage} = 0; | |||||||||||||||||||||||||||||||||||||
| 61 | 9 | $self->{need_step} = 1; | |||||||||||||||||||||||||||||||||||||
| 62 | 9 | $self->{error} = undef; | |||||||||||||||||||||||||||||||||||||
| 63 | 9 | $user_cb->('Username:'); | |||||||||||||||||||||||||||||||||||||
| 64 | 9 | return; | |||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||
| 67 | 15 | ▶ | sub server_step { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
server_step: called CC=8 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 68 | 15 | my $self = shift; | |||||||||||||||||||||||||||||||||||||
| 69 | 15 | my $response = shift; | |||||||||||||||||||||||||||||||||||||
| 70 | 15 | ▶ | my $user_cb = shift || sub {}; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
shift() || sub {
}
MC/DC0%0/2
shift() || sub {
}
shift()
sub {
}
Truth table33%1/3
A || B
A= shift()B= sub {
}
| |||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||
| 72 | 15 | my $stage = ++$self->{stage}; | |||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | 15 | ▶ | if ($stage == 1) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 75 | 8 | ▶ | unless (defined $response) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $self->set_error("Invalid sequence (empty username)"); | |||||||||||||||||||||||||||||||||||||
| 77 | 0 | return $user_cb->(); | |||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||
| 79 | 8 | $self->{answer}{user} = $response; | |||||||||||||||||||||||||||||||||||||
| 80 | 8 | return $user_cb->("Password:"); | |||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||
| 82 | elsif ($stage == 2) { | ||||||||||||||||||||||||||||||||||||||
| 83 | 7 | ▶ | unless (defined $response) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->set_error("Invalid sequence (empty pass)"); | |||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $user_cb->(); | |||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||
| 87 | 7 | $self->{answer}{pass} = $response; | |||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||
| 89 | else { | ||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->set_error("Invalid sequence (end)"); | |||||||||||||||||||||||||||||||||||||
| 91 | 0 | return $user_cb->(); | |||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||
| 93 | 7 | my $error = "Credentials don't match"; | |||||||||||||||||||||||||||||||||||||
| 94 | 7 | my $answers = { user => $self->{answer}{user}, pass => $self->{answer}{pass} }; | |||||||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | if (my $checkpass = $self->{callback}{checkpass}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 96 | 2 | ▶ | my $cb = sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 97 | 2 | my $result = shift; | |||||||||||||||||||||||||||||||||||||
| 98 | 2 | ▶ | unless ($result) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 99 | 1 | $self->set_error($error); | |||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||
| 101 | else { | ||||||||||||||||||||||||||||||||||||||
| 102 | 1 | $self->set_success; | |||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||
| 104 | 2 | $user_cb->(); | |||||||||||||||||||||||||||||||||||||
| 105 | 2 | }; | |||||||||||||||||||||||||||||||||||||
| 106 | 2 | $checkpass->($self => $answers => $cb ); | |||||||||||||||||||||||||||||||||||||
| 107 | 2 | return; | |||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||
| 109 | elsif (my $getsecret = $self->{callback}{getsecret}) { | ||||||||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | my $cb = sub { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||
| 111 | 5 | my $good_pass = shift; | |||||||||||||||||||||||||||||||||||||
| 112 | 5 | ▶ | if ($good_pass && $good_pass eq ($self->{answer}{pass} || "")) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
$good_pass and $good_pass eq ($self->{"answer"}{"pass"} || "")
$self->{'answer'}{'pass'} || ''
MC/DC50%1/2
$good_pass and $good_pass eq ($self->{"answer"}{"pass"} || "")
$good_pass
$good_pass eq ($self->{"answer"}{"pass"} || "")
MC/DC0%0/1
$self->{'answer'}{'pass'} || ''
$self->{'answer'}{'pass'}
Truth table66%2/3
A and B
A= $good_passB= $good_pass eq ($self->{"answer"}{"pass"} || "")
Truth table50%1/2
A
A= $self->{'answer'}{'pass'}
| |||||||||||||||||||||||||||||||||||||||
| 113 | 2 | $self->set_success; | |||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||
| 115 | else { | ||||||||||||||||||||||||||||||||||||||
| 116 | 3 | $self->set_error($error); | |||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||
| 118 | 5 | $user_cb->(); | |||||||||||||||||||||||||||||||||||||
| 119 | 5 | }; | |||||||||||||||||||||||||||||||||||||
| 120 | 5 | $getsecret->($self => $answers => $cb ); | |||||||||||||||||||||||||||||||||||||
| 121 | 5 | return; | |||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->set_error($error); | |||||||||||||||||||||||||||||||||||||
| 125 | 0 | $user_cb->(); | |||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return; | |||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||
| 130 | 4 | 1; | |||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||
| 132 | __END__ | ||||||||||||||||||||||||||||||||||||||