-
renater.salaun authored
First working version of the code git-svn-id: https://svn.geant.net/GEANT/edugain_testidp_account_manager/trunk@20 047e039d-479c-447e-8a29-aa6bf4a09bab
renater.salaun authoredFirst working version of the code git-svn-id: https://svn.geant.net/GEANT/edugain_testidp_account_manager/trunk@20 047e039d-479c-447e-8a29-aa6bf4a09bab
AuthenticationToken.pm 3.74 KiB
package IdPAccountManager::AuthenticationToken;
use strict;
use IdPAccountManager::Data::Authenticationtoken;
use IdPAccountManager::Data::Authenticationtoken::Manager;
use IdPAccountManager::Tools;
use Conf;
use Digest::MD5;
require Exporter;
my @ISA = qw(Exporter);
my @EXPORT = qw();
use Carp;
INIT {
## Set error mode to non fatal
IdPAccountManager::Data::Authenticationtoken::Manager->error_mode('return');
}
sub new {
my ($pkg) = shift;
my %args = @_;
my $self = {};
## Bless AuthenticationToken object
bless $self, $pkg;
## Object may be created either with a hashref as argument or an IdPAccountManager::Data::Authenticationtoken object
## Second case is usefull when fetching a set of IdPAccountManager::Data::Authenticationtoken via IdPAccountManager::Data::Authenticationtoken::Manager
if (ref($_[0]) eq 'IdPAccountManager::Data::Authenticationtoken') {
$self->{'persistent'} = $_[0];
}else {
$self->{'persistent'} = IdPAccountManager::Data::Authenticationtoken->new(%args);
}
return $self;
}
## Load an authentication token from DB
sub load {
my $self = shift;
return $self->{'persistent'}->load(speculative => 1);
}
## Get object parameter
sub get {
my $self = shift;
my $attribute_name = shift;
return $self->{'persistent'}->$attribute_name;
}
## Set object parameters
sub set {
my $self = shift;
my %parameters = @_;
foreach my $parameter_name (keys %parameters) {
$self->{'persistent'}->$parameter_name($parameters{$parameter_name});
}
return 1;
}