1package DJabberd::Authen; 2use strict; 3use base 'DJabberd::Plugin'; 4 5sub register { 6 my ($self, $vhost) = @_; 7 8# my $which; 9# if (($which = $self->can('foo')) && $which != &base_class_one) { 10# } 11 12 if ($self->can_retrieve_cleartext) { 13 $vhost->register_hook("GetPassword", sub { 14 my (undef, $cb, %args) = @_; 15 # args as 'username' and 'conn'; 16 # cb can ->set or ->decline 17 $self->get_password($cb, %args); 18 }); 19 } 20 21 if ($self->can_check_digest) { 22 $vhost->register_hook("CheckDigest", sub { 23 my (undef, $cb, %args) = @_; 24 # args as 'username', 'conn', 'digest' 25 # cb can ->accept or ->reject 26 $self->check_digest($cb, %args); 27 }); 28 } 29 30 $vhost->register_hook("CheckCleartext", sub { 31 my (undef, $cb, %args) = @_; 32 # args containing: username, conn, password 33 $self->check_cleartext($cb, %args); 34 }); 35 36 $vhost->register_hook("CheckJID", sub { 37 my (undef, $cb, %args) = @_; 38 # args contain: username and conn 39 $self->check_jid($cb, %args); 40 41 }); 42 43 if ($self->can_register_jids) { 44 $vhost->register_hook("RegisterJID", sub { 45 my (undef, $cb, %args) = @_; 46 # args containing: username, password 47 # cb can: 48 # conflict 49 # error 50 # saved 51 $self->register_jid($cb, %args); 52 }); 53 } 54 55 if ($self->can_unregister_jids) { 56 $vhost->register_hook("UnregisterJID", sub { 57 my (undef, $cb, %args) = @_; 58 # args containing: username 59 # cb can: 60 # conflict 61 # error 62 # saved 63 $self->unregister_jid($cb, %args); 64 }); 65 } 66 67} 68 69sub can_register_jids { 70 0; 71} 72 73sub can_unregister_jids { 74 0; 75} 76 77sub can_retrieve_cleartext { 78 0; 79} 80 81sub can_check_digest { 82 0; 83} 84 85sub check_jid { 86 my ($self, $cb, %args) = @_; 87 return 0; 88} 89 90sub unregister_jid { 91 my ($self, $cb, %args) = @_; 92 return 0; 93} 94 95sub check_cleartext { 96 my ($self, $cb, %args) = @_; 97 $cb->reject; 98} 99 100sub check_digest { 101 my ($self, $cb, %args) = @_; 102 $cb->reject; 103} 104 105 1061; 107