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


Finance-Bank-Cahoot documentation  | view source Contained in the Finance-Bank-Cahoot distribution.

Index


NAME

Top

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

SYNOPSIS

Top

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

DESCRIPTION

Top

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

METHODS

Top

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

Top

_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

Top

Jon Connell <jon@figsandfudge.com>

LICENSE AND COPYRIGHT

Top


Finance-Bank-Cahoot documentation  | view source Contained in the Finance-Bank-Cahoot distribution.