| 1 | # Copyright (c) 2004-2006 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 2.2100; | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 16 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 16 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 16 | ▶ | use vars qw(@Plugins); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 16 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 16 | @Plugins = qw( | |||||||||||||||||||||||||||||||
| 14 | Authen::SASL::XS | ||||||||||||||||||||||||||||||||
| 15 | Authen::SASL::Perl | ||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 18 | ▶ | sub import { | ||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||
| 20 | 18 | shift; | |||||||||||||||||||||||||||||||
| 21 | 18 | ▶ | return unless @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 17 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||
| 24 | 17 | ▶ | @Plugins = grep { /^[:\w]+$/ and eval "require $_" } map { /::/ ? $_ : "Authen::SASL::$_" } @_ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
/^[:\w]+$/ && eval "require $_"
MC/DC0%0/2
/^[:\w]+$/ && eval "require $_"
/^[:\w]+$/
eval "require $_"
Truth table33%1/3
A && B
A= /^[:\w]+$/B= eval "require $_"
| |||||||||||||||||||||||||||||||||
| 25 | or croak "no valid Authen::SASL plugins found"; | ||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | 53 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||
| 30 | 53 | my $pkg = shift; | |||||||||||||||||||||||||||||||
| 31 | 53 | ▶ | my %opt = ((@_ % 2 ? 'mechanism' : ()), @_); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | my $self = bless { | ||||||||||||||||||||||||||||||||
| 34 | mechanism => $opt{mechanism} || $opt{mech}, | ||||||||||||||||||||||||||||||||
| 35 | callback => {}, | ||||||||||||||||||||||||||||||||
| 36 | debug => $opt{debug}, | ||||||||||||||||||||||||||||||||
| 37 | 53 | ▶ | }, $pkg; | ||||||||||||||||||||||||||||||
|
Condition100%3/3
$opt{'mechanism'} || $opt{'mech'}
MC/DC100%2/2
$opt{'mechanism'} || $opt{'mech'}
$opt{'mechanism'}
$opt{'mech'}
Truth table100%3/3
A || B
A= $opt{'mechanism'}B= $opt{'mech'}
| |||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 53 | ▶ | $self->callback(%{$opt{callback}}) if ref($opt{callback}) eq 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | # Compat | ||||||||||||||||||||||||||||||||
| 42 | 53 | ▶ | $self->callback(user => ($self->{user} = $opt{user})) if exists $opt{user}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 43 | 53 | ▶ | $self->callback(pass => $opt{password}) if exists $opt{password}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | 53 | ▶ | $self->callback(pass => $opt{response}) if exists $opt{response}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | 53 | $self; | |||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 82 | ▶ | sub mechanism { | ||||||||||||||||||||||||||||||
|
Subroutine
mechanism: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 51 | 82 | my $self = shift; | |||||||||||||||||||||||||||||||
| 52 | @_ ? $self->{mechanism} = shift | ||||||||||||||||||||||||||||||||
| 53 | 82 | ▶ | : $self->{mechanism}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 200 | ▶ | sub callback { | ||||||||||||||||||||||||||||||
|
Subroutine
callback: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 57 | 200 | my $self = shift; | |||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 200 | ▶ | return $self->{callback}{$_[0]} if @_ == 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 200 | my %new = @_; | |||||||||||||||||||||||||||||||
| 62 | 200 | @{$self->{callback}}{keys %new} = values %new; | |||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | 200 | $self->{callback}; | |||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | # The list of packages should not really be hardcoded here | ||||||||||||||||||||||||||||||||
| 68 | # We need some way to discover what plugins are installed | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 36 | ▶ | sub client_new { # $self, $service, $host, $secflags | ||||||||||||||||||||||||||||||
|
Subroutine
client_new: called CC=6 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 71 | 36 | my $self = shift; | |||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | 36 | my $err; | |||||||||||||||||||||||||||||||
| 74 | 36 | foreach my $pkg (@Plugins) { | |||||||||||||||||||||||||||||||
| 75 | 37 | ▶ | if (eval "require $pkg" and $pkg->can("client_new")) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
eval "require $pkg" and $pkg->can("client_new")
MC/DC50%1/2
eval "require $pkg" and $pkg->can("client_new")
eval "require $pkg"
$pkg->can("client_new")
Truth table66%2/3
A and B
A= eval "require $pkg"B= $pkg->can("client_new")
| |||||||||||||||||||||||||||||||||
| 76 | 36 | ▶ | if ($self->{conn} = eval { $pkg->client_new($self, @_) }) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 77 | 36 | return $self->{conn}; | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | 0 | $err = $@; | |||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | croak $err || "Cannot find a SASL Connection library"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$err || 'Cannot find a SASL Connection library'
MC/DC0%0/1
$err || 'Cannot find a SASL Connection library'
$err
Truth table0%0/2
A
A= $err
| |||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | 20 | ▶ | sub server_new { # $self, $service, $host, $secflags | ||||||||||||||||||||||||||||||
|
Subroutine
server_new: called CC=6 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 87 | 20 | my $self = shift; | |||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||
| 89 | 20 | my $err; | |||||||||||||||||||||||||||||||
| 90 | 20 | foreach my $pkg (@Plugins) { | |||||||||||||||||||||||||||||||
| 91 | 20 | ▶ | if (eval "require $pkg" and $pkg->can("server_new")) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
eval "require $pkg" and $pkg->can("server_new")
MC/DC0%0/2
eval "require $pkg" and $pkg->can("server_new")
eval "require $pkg"
$pkg->can("server_new")
Truth table33%1/3
A and B
A= eval "require $pkg"B= $pkg->can("server_new")
| |||||||||||||||||||||||||||||||||
| 92 | 20 | ▶ | if ($self->{conn} = eval { $pkg->server_new($self, @_) } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 93 | 20 | return $self->{conn}; | |||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||
| 95 | 0 | $err = $@; | |||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | croak $err || "Cannot find a SASL Connection library for server-side authentication"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$err || 'Cannot find a SASL Connection library for server-side authentication'
MC/DC0%0/1
$err || 'Cannot find a SASL Connection library for server-side authentication'
$err
Truth table0%0/2
A
A= $err
| |||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 1 | ▶ | sub error { | ||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 102 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 103 | 1 | ▶ | $self->{conn} && $self->{conn}->error; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | # Compat. | ||||||||||||||||||||||||||||||||
| 107 | 3 | ▶ | sub user { | ||||||||||||||||||||||||||||||
|
Subroutine
user: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 108 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 109 | 3 | my $user = $self->{callback}{user}; | |||||||||||||||||||||||||||||||
| 110 | 3 | ▶ | $self->{callback}{user} = shift if @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 111 | 3 | $user; | |||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | sub challenge { | ||||||||||||||||||||||||||||||
|
Subroutine
challenge: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 115 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 116 | 1 | $self->{conn}->client_step(@_); | |||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | sub initial { | ||||||||||||||||||||||||||||||
|
Subroutine
initial: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 120 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 121 | 1 | $self->client_new($self)->client_start; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 3 | ▶ | sub name { | ||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 125 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 126 | 3 | ▶ | $self->{conn} ? $self->{conn}->mechanism : (($self->{mechanism} || '') =~ /(\S+)/)[0]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{'mechanism'} || ''
MC/DC100%1/1
$self->{'mechanism'} || ''
$self->{'mechanism'}
Truth table100%2/2
A
A= $self->{'mechanism'}
| |||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||
| 129 | 16 | 1; | |||||||||||||||||||||||||||||||