Changeset 864

Show
Ignore:
Timestamp:
04/04/09 01:04:55 (8 months ago)
Author:
ykerherve
Message:

Modified to use new SASL async API (that still live on github)

Location:
trunk/DJabberd/lib/DJabberd
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/DJabberd/lib/DJabberd/SASL/Manager/AuthenSASL.pm

    r841 r864  
    3636    my $saslmgr    = Authen::SASL->new( 
    3737        mechanism => $mechanisms, 
    38         callback => { 
     38        callback  => { 
    3939            checkpass => sub { 
    4040                my $sasl = shift; 
    41                 my ($user, $pass, $realm) = @_; 
     41                my $args = shift; 
     42                my $cb   = shift; 
    4243 
    43                 my $success; 
     44                my $user = $args->{user}; 
     45                my $pass = $args->{pass}; 
     46 
    4447                if ($vhost->are_hooks("CheckCleartext")) { 
    45                     $vhost->run_hook_chain(phase => "CheckCleartext", 
    46                             args  => [ username => $user, password => $pass ], 
    47                             methods => { 
    48                                 accept => sub { $success = 1 }, 
    49                                 reject => sub { $success = 0 }, 
    50                             }, 
     48                    $vhost->run_hook_chain( 
     49                        phase   => "CheckCleartext", 
     50                        args    => [ username => $user, password => $pass ], 
     51                        methods => { 
     52                            accept => sub { $cb->(1) }, 
     53                            reject => sub { $cb->(0) }, 
     54                        }, 
    5155                    ); 
    5256                } 
    53                 return $success; 
    5457            }, 
    5558            getsecret => sub { 
    5659                my $sasl = shift; 
    57                 my ($user, $authname) = @_; 
    58                 my $pass; 
     60                my $args = shift; 
     61                my $cb   = shift; 
     62 
     63                my $user = $args->{user}; 
    5964 
    6065                if ($vhost->are_hooks("GetPassword")) { 
    61                     $vhost->run_hook_chain(phase => "GetPassword", 
    62                             args  => [ username => $user, ], 
    63                             methods => { 
    64                                 set => sub { 
    65                                     my (undef, $good_password) = @_; 
    66                                     $pass = $good_password; 
    67                                 }, 
     66                    $vhost->run_hook_chain( 
     67                        phase   => "GetPassword", 
     68                        args    => [ username => $user, ], 
     69                        methods => { 
     70                            set => sub { 
     71                                my (undef, $good_password) = @_; 
     72                                $cb->($good_password); 
    6873                            }, 
     74                        }, 
    6975                    ); 
    7076                } 
    71                 return $pass; 
    7277            }, 
    7378        }, 
  • trunk/DJabberd/lib/DJabberd/Stanza/SASL.pm

    r845 r864  
    5959    $conn->log->info("Got the response $response"); 
    6060 
    61     my $challenge = $sasl->server_step($response); 
    62     return $self->send_reply($sasl, $challenge => $conn); 
     61    $sasl->server_step( 
     62        $response => sub { $self->send_reply($conn->{sasl}, shift() => $conn) }, 
     63    ); 
    6364} 
    6465 
     
    9899    my $init = $self->first_child; 
    99100    if (!$init or $init eq '=') { 
    100         $init = '' 
     101        $init = ''; 
    101102    } 
    102103    else { 
     
    104105    } 
    105106 
    106     my $challenge = $sasl_conn->server_start($init); 
    107     return $self->send_reply($sasl_conn, $challenge => $conn); 
     107    $sasl_conn->server_start( 
     108        $init => sub { $self->send_reply($conn->{sasl}, shift() => $conn) }, 
     109    ); 
    108110} 
    109111