AuthorizationHeader.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 72 CC 6 SCAR 25.9
CC
6
Cov
0%
get
20.0
forge
12.0
BEGIN
2.0
CRAP 13.3
1 package Lemonldap::Handlers::AuthorizationHeader;
2 use strict;
3 use MIME::Base64;
4 our ( @ISA, $VERSION, @EXPORTS );
5 $VERSION = '2.00';
6 our $VERSION_LEMONLDAP = "2.0";
7 our $VERSION_INTERNAL = "2.0";
8  
9 sub get {
10 my $class = shift;
11 my %_param = @_;
12 my $profil = $_param{profil};
13 my $dn = $_param{dn};
14 my $header = $_param{config}->{SENDHEADER} || 'Authorization';
15 my $self;
16 my $ligne_h;
17 if ( $profil eq '_ALLOW_' ) { $profil = ""; }
18  
19 if ( $profil =~ /^uid/ ) {
20 $ligne_h = $profil;
21 }
22 else {
23 $ligne_h = $dn;
24 if ( defined($profil) ) {
25 $ligne_h .= ":$profil";
26 }
27 }
28 $self->{decoded} = "Basic %b64%$ligne_h%b64%";
29 $self->{clair} = "Basic $ligne_h";
30 bless $self, $class;
31 return $self;
32 }
33  
34 sub forge {
35 my $class = shift;
36 my %_param = @_;
37 my $line = $_param{line};
38 my $self;
39 $self->{decoded} = $line;
40 my ($user) = $line =~ /(uid.+?),/;
41 $self->{user} = $user;
42 my $header = $_param{config}->{SENDHEADER} || 'Authorization';
43 return 0 if ( $header eq 'NONE' );
44  
45 ( my $b, my $e ) = $line =~ /(.+)%b64%(.+)%b64%/;
46 if ($e) {
47 $e = encode_base64( $e, '' );
48 $line =~ s/%b64%.+%b64%/$e/;
49 }
50 else {
51  
52 # for previous version
53 ( my $b, my $e ) = $line =~ /(.+?)\s(.+)/;
54 $e = encode_base64( $e, '' );
55 $line =~ s/ (.+)$/ $e/;
56 }
57  
58 $self->{content} = $line;
59 $self->{header} = $header;
60 bless $self, $class;
61 return $self;
62 }
63 1;
64  
65 =pod
66  
67 =for html <center> <H1> Lemonldap::Handlers::AuthorizationHeader </H1></center>
68  
69  
70 =head1 NAME
71  
72 Lemonldap::Handlers::AuthorizationHeader - Plugin for Lemonldap sso system
73  
74 =head1 DESCRIPTION
75  
76 AuthorizationHeader is the default header builder manager of lemonldap websso framework .
77  
78
79 see http://lemonldap.sf.net for more infos .
80  
81 =head2 Overlay
82  
83 If you want use your own header method you must use PLUGINHEADER parameter like this :
84 in httpd.conf : perlsetvar lemonldappluginheader MyModule
85  
86 Your module must accept 3 parameters : config (all the hash of config ) , dn and sting of role (profil) .
87  
88 Your module must provide the 'get' and 'forge' methods .
89
90 Those methods work with SENDHEADER parameter which tells what will be the header (NONE value for no header)
91  
92 =head1 SEE ALSO
93  
94 Lemonldap(3), Lemonldap::Portal::Standard
95  
96 http://lemonldap.sourceforge.net/
97  
98 "Writing Apache Modules with Perl and C" by Lincoln Stein E<amp> Doug
99 MacEachern - O'REILLY
100  
101 =over 1
102  
103 =item Eric German, E<lt>germanlinux@yahoo.frE<gt>
104  
105 =item Isabelle Serre, E<lt>isabelle.serre@justice.gouv.frE<gt>
106  
107 =back
108  
109 =head1 COPYRIGHT AND LICENSE
110  
111 Copyright (C) 2004 by Eric German E<amp> Isabelle Serre
112  
113 Lemonldap originaly written by Eric german who decided to publish him in 2003
114 under the terms of the GNU General Public License version 2.
115  
116 =over 1
117  
118 =item This package is under the GNU General Public License, Version 2.
119  
120 =item The primary copyright holder is Eric German.
121  
122 =item Portions are copyrighted under the same license as Perl itself.
123  
124 =item Portions are copyrighted by Doug MacEachern and Lincoln Stein.
125 This library is under the GNU General Public License, Version 2.
126  
127 =item Portage under Apache2 is made with help of : Ali Pouya and
128 Shervin Ahmadi (MINEFI/DGI)
129  
130 =back
131  
132 This program is free software; you can redistribute it and/or modify
133 it under the terms of the GNU General Public License as published by
134 the Free Software Foundation; version 2 dated June, 1991.
135  
136 This program is distributed in the hope that it will be useful,
137 but WITHOUT ANY WARRANTY; without even the implied warranty of
138 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139 GNU General Public License for more details.
140  
141 A copy of the GNU General Public License is available in the source tree;
142 if not, write to the Free Software Foundation, Inc.,
143 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
144  
145 =cut
146