File Coverage

blib/lib/Lemonldap/Portal/Cda.pm
Criterion Covered Total %
statement 12 67 17.9
branch 0 14 0.0
condition 0 9 0.0
subroutine 4 14 28.5
pod 6 6 100.0
total 22 110 20.0


line stmt bran cond sub pod time code
1             package Lemonldap::Portal::Cda;
2 1     1   23205 use strict;
  1         2  
  1         33  
3 1     1   21012 use CGI;
  1         30168  
  1         9  
4 1     1   139 use warnings;
  1         8  
  1         117  
5 1     1   1092 use MIME::Base64;
  1         1013  
  1         1260  
6             our $VERSION = '0.02';
7              
8             # Preloaded methods go here.
9             sub new {
10 0     0 1   my $class = shift;
11 0           my %args = @_;
12 0   0       my $self = bless {}, ref($class) || $class;
13 0           $self->{controlUrlOrigin} = \&__controlUrlOrigin;
14 0           my $mess = { 8 => 'CDA requested', };
15 0           $self->{msg} = $mess;
16              
17 0           foreach ( keys %args ) {
18 0           $self->{$_} = $args{$_};
19             }
20 0           $self->{controlCDA} = \&__controlCDA_MASTER;
21 0 0         $self->{controlCDA} = \&__controlCDA_SLAVE if ( $self->{type} eq 'slave' );
22 0           return $self;
23             }
24              
25 0     0     sub __none { #does ...nothing .. like me eg;
26              
27             }
28             ##------------------------------------------------------------------
29             ## method controlUrlOrigin
30             ## This method looks at param cgi 'urlc' in order to determine if
31             ## the request comes with a vip url (redirection) or for the menu
32             ##------------------------------------------------------------------
33             sub __controlCDA_MASTER {
34 0     0     my $self = shift;
35 0           my $operation = $self->{param}->{'op'};
36 0           $self->{operation} = $operation;
37 0           my $opx;
38 0 0 0       $opx = 1 if ( ( $operation eq 'c' ) or ( $operation eq 't' ) );
39 0 0 0       if ( defined($operation) and $opx == 1 ) {
40              
41 0           $self->{'message'} = $self->{msg}{8};
42 0           $self->{'error'} = 1;
43 0           $self->{cda} = 1;
44              
45             }
46             }
47              
48             sub getAllRedirection {
49 0     0 1   my $self = shift;
50 0           return ( $self->{urlc}, $self->{urldc} );
51             }
52              
53             sub message {
54 0     0 1   my $self = shift;
55 0           return ( $self->{message} );
56             }
57              
58             sub error {
59 0     0 1   my $self = shift;
60 0           return ( $self->{error} );
61             }
62              
63             sub __controlCDA_SLAVE {
64 0     0     my $self = shift;
65 0           my $operation = $self->{param}->{'op'};
66 0           $self->{operation} = $operation;
67 0 0         if ( defined($operation) ) {
68 0           $self->{session} = $operation;
69 0           $self->{'message'} = $self->{msg}{8};
70 0           $self->{'error'} = 1;
71 0           $self->{cda} = 1;
72              
73             }
74             }
75              
76             sub __controlUrlOrigin {
77 0     0     my $urldc;
78 0           my $self = shift;
79 0           my $urlc = $self->{param}->{'url'};
80 0 0         if ( defined($urlc) ) {
81 0           $urldc = decode_base64($urlc);
82              
83             # $urldc =~ s#:\d+/#/#; # Suppress port number in URL
84 0           $urlc = encode_base64( $urldc, '' );
85 0           $self->{'urlc'} = $urlc;
86 0           $self->{'urldc'} = $urldc;
87             }
88             }
89              
90             sub getSession {
91 0     0 1   my $self = shift;
92 0 0         return ( $self->{session} ) if $self->{session};
93 0           return (0);
94              
95             }
96              
97             sub process {
98 0     0 1   my $self = shift;
99 0           my %args = @_;
100 0           foreach ( keys %args ) {
101 0           $self->{$_} = $args{$_};
102             }
103 0           &{ $self->{controlUrlOrigin} }($self); # no error avaiable in this step
  0            
104 0           &{ $self->{controlCDA} }($self);
  0            
105 0 0         return ($self) if $self->{'error'}; ## it's not necessary to go next.
106              
107             }
108              
109             # Autoload methods go after =cut, and are processed by the autosplit program.
110              
111             1;
112             __END__