Authen-CAS-Client
view release on metacpan or search on metacpan
lib/Authen/CAS/Client/Response.pm view on Meta::CPAN
require 5.006_001;
use strict;
use warnings;
#======================================================================
# Authen::CAS::Client::Response
#
package Authen::CAS::Client::Response;
our $VERSION = '0.03';
sub _ATTRIBUTES () { _ok => undef, doc => undef }
sub new {
my ( $class, %args ) = @_;
my %self = $class->_ATTRIBUTES;
for my $attribute ( keys %self ) {
$self{$attribute} = $args{$attribute}
if exists $args{$attribute};
}
bless \%self, $class
}
sub is_error { my ( $self ) = @_; ! defined $self->{_ok} }
sub is_failure { my ( $self ) = @_; defined $self->{_ok} && ! $self->{_ok} }
sub is_success { my ( $self ) = @_; defined $self->{_ok} && $self->{_ok} }
sub doc { my ( $self ) = @_; $self->{doc} }
#======================================================================
# Authen::CAS::Client::Response::Error
#
package Authen::CAS::Client::Response::Error;
use base qw/ Authen::CAS::Client::Response /;
sub _ATTRIBUTES () { error => 'An internal error occurred', $_[0]->SUPER::_ATTRIBUTES }
sub new { my $class = shift; $class->SUPER::new( @_, _ok => undef ) }
sub error { my ( $self ) = @_; $self->{error} }
#======================================================================
# Authen::CAS::Client::Response::Failure
#
package Authen::CAS::Client::Response::Failure;
use base qw/ Authen::CAS::Client::Response /;
sub _ATTRIBUTES () { code => undef, message => '', $_[0]->SUPER::_ATTRIBUTES }
sub new { my $class = shift; $class->SUPER::new( @_, _ok => 0 ) }
sub code { my ( $self ) = @_; $self->{code} }
sub message { my ( $self ) = @_; $self->{message} }
#======================================================================
# Authen::CAS::Client::Response::AuthFailure
#
package Authen::CAS::Client::Response::AuthFailure;
use base qw/ Authen::CAS::Client::Response::Failure /;
#======================================================================
# Authen::CAS::Client::Response::ProxyFailure
#
package Authen::CAS::Client::Response::ProxyFailure;
use base qw/ Authen::CAS::Client::Response::Failure /;
#======================================================================
# Authen::CAS::Client::Response::Success
#
package Authen::CAS::Client::Response::Success;
use base qw/ Authen::CAS::Client::Response /;
sub new { my $class = shift; $class->SUPER::new( @_, _ok => 1 ) }
#======================================================================
# Authen::CAS::Client::Response::AuthSuccess
#
package Authen::CAS::Client::Response::AuthSuccess;
use base qw/ Authen::CAS::Client::Response::Success /;
sub _ATTRIBUTES () { user => undef, iou => undef, proxies => [ ], $_[0]->SUPER::_ATTRIBUTES }
sub user { my ( $self ) = @_; $self->{user} }
sub iou { my ( $self ) = @_; $self->{iou} }
sub proxies { my ( $self ) = @_; wantarray ? @{ $self->{proxies} } : [ @{ $self->{proxies} } ] }
#======================================================================
# Authen::CAS::Client::Response::ProxySuccess
#
package Authen::CAS::Client::Response::ProxySuccess;
use base qw/ Authen::CAS::Client::Response::Success /;
sub _ATTRIBUTES () { proxy_ticket => undef, $_[0]->SUPER::_ATTRIBUTES }
sub proxy_ticket { my ( $self ) = @_; $self->{proxy_ticket} }
1
__END__
=pod
=head1 NAME
Authen::CAS::Client::Response - A set of classes for implementing
responses from a CAS server
=head1 DESCRIPTION
Authen::CAS::Client::Response implements a base class that is used to
build a hierarchy of response objects that are returned from methods in
L<Authen::CAS::Client>. Most response objects are meant to encapsulate
a type of response from a CAS server.
=head1 CLASSES AND METHODS
=head2 Authen::CAS::Client::Response
Authen::CAS::Client::Response is the base class from which all other
response classes inherit. As such it is very primitive and is never
used directly.
=head3 new( %args )
C<new()> creates an instance of an C<Authen::CAS::Client::Response> object
and assigns its data members according to the values in C<%args>.
=head3 is_error()
C<is_error()> returns true if the response represents an error object.
=head3 is_failure()
C<is_failure()> returns true if the response represents a failure object.
=head3 is_success()
C<is_success()> returns true if the response represents a success object.
=head3 doc()
C<doc()> returns the response document used to create the response object.
For errors and CAS v1.0 requests this will be the raw text response
from the server. Otherwise an L<XML::LibXML> object will be returned.
This can be used for debugging or retrieving additional information
from the CAS server's response.
=head2 Authen::CAS::Client::Response::Error
Authen::CAS::Client::Response::Error is used when an error occurs that
prevents further processing of a request. This would include not being able
connect to the CAS server, receiving an unexpected response from the server
or being unable to correctly parse the server's response according to the
( run in 1.084 second using v1.01-cache-2.11-cpan-5735350b133 )