File Coverage

blib/lib/OpenID/Lite/Association.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 0 3 0.0
total 33 36 91.6


line stmt bran cond sub pod time code
1             package OpenID::Lite::Association;
2              
3 3     3   2470 use Any::Moose;
  3         179815  
  3         22  
4              
5 3     3   3711 use OpenID::Lite::Types qw(AssocType SessionType);
  3         39  
  3         23  
6 3     3   1569 use OpenID::Lite::Constants::AssocType qw(HMAC_SHA1 HMAC_SHA256);
  3         7  
  3         158  
7 3     3   1007 use String::Random;
  3         3466  
  3         149  
8 3     3   4137 use MIME::Base64;
  3         3292  
  3         732  
9              
10             has 'handle' => (
11             is => 'rw',
12             isa => 'Str',
13             required => 1,
14             );
15              
16             has 'secret' => (
17             is => 'rw',
18             isa => 'Str',
19             required => 1,
20             );
21              
22             has 'type' => (
23             is => 'rw',
24             isa => AssocType,
25             required => 1,
26             );
27              
28             has 'expires_in' => (
29             is => 'rw',
30             isa => 'Int',
31             required => 1,
32             );
33              
34             has 'issued' => (
35             is => 'rw',
36             isa => 'Int',
37             required => 1,
38             );
39              
40             sub copy {
41 9     9 0 11 my $self = shift;
42 9         145 return ref($self)->new(
43             handle => $self->handle,
44             secret => $self->secret,
45             type => $self->type,
46             expires_in => $self->expires_in,
47             issued => $self->issued,
48             );
49             }
50              
51             sub expires_at {
52 4     4 0 5 my $self = shift;
53 4         26 return ( $self->issued + $self->expires_in );
54             }
55              
56             sub is_expired {
57 4     4 0 6 my $self = shift;
58 4         8 return ( $self->expires_at < time() );
59             }
60              
61 3     3   19 no Any::Moose;
  3         7  
  3         35  
62             __PACKAGE__->meta->make_immutable;
63             1;
64              
65             =head1 NAME
66              
67             OpenID::Lite::Association - Association class
68              
69             =head1 SYNOPSIS
70              
71             $assoc->handle;
72             $assoc->secret;
73             $assoc->type;
74             $assoc->expires_in;
75             $assoc->issued;
76             $assoc->expires_at;
77             $assoc->is_expires;
78             $assoc->copy;
79              
80             =head1 DESCRIPTION
81              
82             This class's object represents association that established between RP and OP.
83             You don't need to build association by yourself.
84              
85             =head1 AUTHOR
86              
87             Lyo Kato, Elyo.kato@gmail.comE
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             Copyright (C) 2009 by Lyo Kato
92              
93             This library is free software; you can redistribute it and/or modify
94             it under the same terms as Perl itself, either Perl version 5.8.8 or,
95             at your option, any later version of Perl 5 you may have available.
96              
97             =cut