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