The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

 Finance::Bank::Cahoot::CredentialsProvider - Abstract base class for credentials providers

SYNOPSIS

  my $credentials = Finance::Bank::Cahoot::CredentialsProvider::Acme->new(
     credentials => [qw(account password)],
     options => {account => 'acmeuser'});

DESCRIPTION

Provides an abstract base class for deriving new credentials providers with a defined interface. Derived classes MUST implement _init and get methods.

METHODS

new

Create a new instance of a credentials provider. Each credential is available with its own access method of the same name. All methods may be optionally supplied a character offset in the credentials value (first character is 0).

credentials is an array ref of all the credentials types available via the credentials provider.
options is a hash ref of options for each credential. These are used by the credentials provider in an implementation-defined manner.

ABSTRACT METHODS

_init

Initialization routine for the derived class to implement. Called by new with the credentials options as a hash reference. In the following example, taken from the the Constant credentials provider, _init simply stores each option value in the class:

  sub _init
  {
    my ($self, $options) = @_;
    while (my ($credential, $value) = each %{$options}) {
      croak 'Invalid credential '.$credential.' supplied with callback'
        if not $self->can($credential);
      $self->{$credential} = $value;
    }
  }
get

Public access method for the derived class to implement. Called with the name of the credential to supply and an optional character offset (0 is the first character). In the following example, taken from the the Constant credentials provider, the credential is simply returned from class members created by the previous _init method:

  sub get
  {
    my ($self, $credential, $offset) = @_;
    return substr ($self->{$credential}, $offset, 1)
      if defined $offset;
    return $self->{$credential};
  }

AUTHOR

Jon Connell <jon@figsandfudge.com>

LICENSE AND COPYRIGHT

This module takes its inspiration from Finance::Bank::Natwest by Jody Belka.

Copyright 2007 by Jon Connell

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.