[Catalyst-commits] r6542 - in trunk/Catalyst-Plugin-Authentication: . lib/Catalyst/Plugin/Authentication/Credential

matthewt at dev.catalyst.perl.org matthewt at dev.catalyst.perl.org
Tue Jul 17 17:57:39 GMT 2007


Author: matthewt
Date: 2007-07-17 17:57:39 +0100 (Tue, 17 Jul 2007)
New Revision: 6542

Added:
   trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm
Modified:
   trunk/Catalyst-Plugin-Authentication/
Log:
 r33940 at cain (orig r5490):  jayk | 2006-11-10 22:31:16 +0000
 Adding Wrapper class, missed in the last one
 



Property changes on: trunk/Catalyst-Plugin-Authentication
___________________________________________________________________
Name: svk:merge
   - 4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Plugin-Authentication:5489
   + 4ad37cd2-5fec-0310-835f-b3785c72a374:/branches/Catalyst-Plugin-Authentication:5490

Added: trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm
===================================================================
--- trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm	                        (rev 0)
+++ trunk/Catalyst-Plugin-Authentication/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm	2007-07-17 16:57:39 UTC (rev 6542)
@@ -0,0 +1,33 @@
+package Catalyst::Plugin::Authentication::Credential::Wrapper;
+
+use strict;
+use warnings;
+
+sub new {
+    my ($myclass, $hash, $app) = @_;
+    
+
+    if (!exists($hash->{'class'})) {
+        Carp::croak "Couldn't setup a wrapped Credential, no module specified";
+    }
+    my $data = {};
+    my $wrappedclass = $hash->{'class'};
+    my $authroutine = $hash->{'authroutine'} ||= 'authenticate';
+    $data->{authroutine} = $wrappedclass->can($authroutine);
+    
+    if (!$data->{'authroutine'}) {
+        Carp::croak "Couldn't set up a wrapped Credential, auth sub: $authroutine was not found";
+    }
+    
+    bless $data, $myclass;   
+}
+
+sub authenticate {
+    my ($self, $c, $store, $authinfo) = @_;
+    
+    return $self->{'authroutine'}->($c, $store, $authinfo);
+}
+
+__PACKAGE__;
+
+__END__
\ No newline at end of file




More information about the Catalyst-commits mailing list