[315] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r460 - trunk/owl/perl/lib/Net/XMPP

daemon@ATHENA.MIT.EDU (asedeno@MIT.EDU)
Thu Oct 29 18:04:49 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
To: dirty-owl-hackers@mit.edu
From: asedeno@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Sat, 11 Nov 2006 03:03:57 -0500 (EST)

Author: asedeno
Date: 2006-11-11 03:03:56 -0500 (Sat, 11 Nov 2006)
New Revision: 460

Modified:
   trunk/owl/perl/lib/Net/XMPP/Protocol.pm
Log:
Protocol.pm: allow IQ Auth to take a password callback like SASL's.


Modified: trunk/owl/perl/lib/Net/XMPP/Protocol.pm
===================================================================
--- trunk/owl/perl/lib/Net/XMPP/Protocol.pm	2006-11-10 20:47:57 UTC (rev 459)
+++ trunk/owl/perl/lib/Net/XMPP/Protocol.pm	2006-11-11 08:03:56 UTC (rev 460)
@@ -1830,6 +1830,11 @@
 
     delete($args{digest});
     delete($args{type});
+    my $password = delete $args{password};
+    if (ref($password) eq 'CODE')
+    {
+        $password = $password->();
+    }
 
     #--------------------------------------------------------------------------
     # 0k authenticaion (http://core.jabber.org/0k.html)
@@ -1843,7 +1848,7 @@
     #--------------------------------------------------------------------------
     if ($authType eq "zerok")
     {
-        my $hashA = Digest::SHA1::sha1_hex(delete($args{password}));
+        my $hashA = Digest::SHA1::sha1_hex($password);
         $args{hash} = Digest::SHA1::sha1_hex($hashA.$token);
 
         for (1..$sequence)
@@ -1862,7 +1867,6 @@
     #--------------------------------------------------------------------------
     if ($authType eq "digest")
     {
-        my $password = delete($args{password});
         $args{digest} = Digest::SHA1::sha1_hex($self->GetStreamID().$password);
     }
 
@@ -1884,6 +1888,7 @@
     # From the reply IQ determine if we were successful or not.  If yes then
     # return "".  If no then return error string from the reply.
     #--------------------------------------------------------------------------
+    $password =~ tr/\0-\377/x/;
     return unless defined($iqLogin);
     return ( $iqLogin->GetErrorCode() , $iqLogin->GetError() )
         if ($iqLogin->GetType() eq "error");


home help back first fref pref prev next nref lref last post