From: Matt S Trout Date: Tue, 17 Jul 2007 16:57:39 +0000 (+0000) Subject: Adding Wrapper class, missed in the last one X-Git-Tag: v0.10009_01~84 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f38e3a528299616555e4ae08e1ec35af0d16c4c;p=catagits%2FCatalyst-Plugin-Authentication.git Adding Wrapper class, missed in the last one r33940@cain (orig r5490): jayk | 2006-11-10 22:31:16 +0000 --- diff --git a/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm b/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm new file mode 100644 index 0000000..cea68b0 --- /dev/null +++ b/lib/Catalyst/Plugin/Authentication/Credential/Wrapper.pm @@ -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