| 1 | package OpenID::Lite::RelyingParty::Associator; | ||
| 2 | |||
| 3 | 1 | ▶ | use Any::Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | with 'OpenID::Lite::Role::ErrorHandler'; | ||
| 5 | with 'OpenID::Lite::Role::AgentHandler'; | ||
| 6 | with 'OpenID::Lite::Role::Associator'; | ||
| 7 | |||
| 8 | 0 | ▶ | use OpenID::Lite::SessionHandlers; |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 9 | use OpenID::Lite::RelyingParty::Associator::Base; | ||
| 10 | use Carp (); | ||
| 11 | |||
| 12 | sub associate { | ||
| 13 | my ( $self, $service ) = @_; | ||
| 14 | |||
| 15 | my $associator = $self->create_method_for( $self->session_type ); | ||
| 16 | my $association = $associator->associate($service) | ||
| 17 | or return $self->ERROR( $associator->errstr ); | ||
| 18 | return $association; | ||
| 19 | } | ||
| 20 | |||
| 21 | # factory method | ||
| 22 | sub create_method_for { | ||
| 23 | my ( $self, $type ) = @_; | ||
| 24 | my $session = OpenID::Lite::SessionHandlers->select_session($type); | ||
| 25 | Carp::croak "invalid session type" unless $session; | ||
| 26 | my $associator = OpenID::Lite::RelyingParty::Associator::Base->new( | ||
| 27 | agent => $self->agent, | ||
| 28 | assoc_type => $self->assoc_type, | ||
| 29 | session => $session, | ||
| 30 | ); | ||
| 31 | return $associator; | ||
| 32 | } | ||
| 33 | |||
| 34 | no Any::Moose; | ||
| 35 | __PACKAGE__->meta->make_immutable; | ||
| 36 | 1; | ||
| 37 | |||