minor updates
[catagits/Catalyst-Plugin-Authentication.git] / lib / Catalyst / Plugin / Authentication / Credential / Wrapper.pm
CommitLineData
8f38e3a5 1package Catalyst::Plugin::Authentication::Credential::Wrapper;
2
3use strict;
4use warnings;
5
6sub new {
7 my ($myclass, $hash, $app) = @_;
8
9
10 if (!exists($hash->{'class'})) {
11 Carp::croak "Couldn't setup a wrapped Credential, no module specified";
12 }
13 my $data = {};
14 my $wrappedclass = $hash->{'class'};
15 my $authroutine = $hash->{'authroutine'} ||= 'authenticate';
16 $data->{authroutine} = $wrappedclass->can($authroutine);
17
18 if (!$data->{'authroutine'}) {
19 Carp::croak "Couldn't set up a wrapped Credential, auth sub: $authroutine was not found";
20 }
21
22 bless $data, $myclass;
23}
24
25sub authenticate {
26 my ($self, $c, $store, $authinfo) = @_;
27
28 return $self->{'authroutine'}->($c, $store, $authinfo);
29}
30
31__PACKAGE__;
32
33__END__