Generic4a2.pm untested

filter: Statementstmt 0.0% 0 / 495 Branchbran 0.0% 0 / 186 Conditioncond 0.0% 0 / 50 MC/DCmcdc 0.0% 0 / 32 Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 788 CC 92 SCAR 74.6
CC
92
Cov
0%
handler
2652.0
proxy_handler
1560.0
_lemonldap_internal
20.0
CRAP 1736.4
1 package Lemonldap::Handlers::Generic4a2;
2 use strict;
3  
4 ##### use ######
5 use Apache2::URI();
6 use Apache2::Const;
7 use Apache2::Connection;
8 use Apache2::ServerUtil ();
9 use MIME::Base64;
10 use LWP::UserAgent;
11 use Lemonldap::Config::Parameters;
12 use Lemonldap::Config::Initparam;
13 use Lemonldap::Handlers::Utilities;
14 use Lemonldap::Handlers::Core;
15 use Apache2::Log();
16 use Apache2::ServerRec();
17 use CGI ':cgi-lib';
18 use CGI::Cookie;
19 use Crypt::CBC;
20 use URI::Escape;
21 use Template;
22 use Sys::Hostname;
23 #A retirer en prod
24 #use Data::Dumper;
25 #### common declaration #######
26 our( @ISA, $VERSION, @EXPORTS );
27 $VERSION = '3.5.8';
28 our $VERSION_LEMONLDAP = "3.1.0";
29 our $VERSION_INTERNAL = "3.1.0";
30  
31 ####
32 ####
33 #### my declaration #########
34 my %CONFIG;
35 my %CLIENT;
36 my $SAVE_MHURI;
37 my $NOM;
38 my $UA;
39 @ISA = qw(LWP::UserAgent );
40 my $ID_COLLECTED;
41 my $__STACK;
42 my %STACK;
43 my $ID_SAVE;
44 my $s = Apache2::ServerUtil->server;
45  
46 ### this anonymous function will be call when child dead , it will delete berkeley db file
47 my $cleanup = sub {
48 my $s = Apache2::ServerUtil->server;
49 my $srv_cfg = $s->dir_config;
50  
51 my $vhosts = 0;
52 my $path_other;
53 for ( my $ser = $s->next ; $ser ; $ser = $ser->next ) {
54 $vhosts++;
55 $path_other = $ser->dir_config('cachedbpath') unless $path_other;
56  
57 }
58  
59 my $path = $srv_cfg->{'cachedbpath'} || $path_other;
60 unlink "$path/$$.db" if $path;
61  
62 };
63
64 Apache2::ServerUtil->server->push_handlers( PerlChildExitHandler => $cleanup );
65  
66 sub handler {
67 my $r = shift;
68  
69 # URL des pages d'erreur a ne pas traiter
70 if ( $r->uri =~ /^\/LemonErrorPages/ ) {
71 return DECLINED;
72 }
73 ########################
74 ## log initialization
75 ########################
76 my $log = $r->log;
77 my $messagelog;
78 my $cache2file;
79 my $APACHE_CODE;
80  
81 # Url a ne pas traiter meme sans conf
82 # exemple
83 # PerlSetVar ExcludeRegex
84 #(?i)(\.smi|\.swf|\.vrml|\.ico|\.tif|\.gif|\.jpg|\.jpeg|\.js|\.css|\.jpeg|\.png|\.avi|ajaxaction|pngbehavior\.jsp)
85  
86  
87 my $regex = $r->dir_config('excluderegex') ;
88 if (defined $regex) {
89 $log->debug("REGEXP : $regex\n");
90 my $uri_input = $r->uri;
91 if ($uri_input=~ /$regex/o) {
92 $log->debug("$uri_input : EXCLUDED\n");
93 return DECLINED;
94 }
95 }
96  
97 ########################
98 ## collect httpd param
99 ########################
100 $ID_COLLECTED = '';
101 my $con = $r->dir_config();
102  
103 $log->info($messagelog);
104  
105 my $in_process = $r->dir_config('handlerid');
106 if ( $CONFIG{$in_process} ) {
107 $log->info(
108 "$CONFIG{$in_process}->{HANDLERID} XML $CONFIG{$in_process}->{XML} config already in use"
109 );
110 $ID_COLLECTED = $in_process;
111 }
112 else {
113 my $conf = &Lemonldap::Config::Initparam::init_param_httpd($log,$con);
114 #Domain insensible a la casse
115 $conf->{DOMAIN} = lc($conf->{DOMAIN});
116  
117 #/Domain insensible a la casse
118 $ID_COLLECTED = $conf->{HANDLERID};
119 $CONFIG{$ID_COLLECTED} = $conf;
120  
121 ### I will try retieve HANDLERID from httpd conf
122 if ($ID_COLLECTED) {
123 $NOM = $ID_COLLECTED;
124 $messagelog =
125 "$NOM Phase : handler initialization LOAD HANDLERID httpd.conf:$CONFIG{$ID_COLLECTED}->{HANDLERID} : succeded";
126 }
127 else {
128  
129 # I don't find anything for this handler in order to make link with XLM conf section
130 $messagelog =
131 "$NOM: Phase : handler initialization LOAD HANDLERID httpd.conf:failed";
132 }
133 $log->info($messagelog);
134  
135 ############################################
136  
137 # my $ref = $CONFIG{$ID_COLLECTED}->{HANDLERID};
138 # $ref =~ s/\/.+// ;
139 $log->info(
140 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: Phase : handler initialization LOAD XML file $CONFIG{$ID_COLLECTED}->{CONFIGFILE} and $CONFIG{$ID_COLLECTED}->{CONFIGDBPATH}"
141 );
142 $log->info(
143 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: domain matched $CONFIG{$ID_COLLECTED}->{DOMAIN}"
144 );
145 if ( defined ($CONFIG{$ID_COLLECTED}->{CONFIGFILE}) )
146 {
147 # my $ref = $CONFIG{$ID_COLLECTED}->{HANDLERID};
148 # $ref =~ s/\/.+// ;
149 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: Phase : handler initialization LOAD XML file $CONFIG{$ID_COLLECTED}->{CONFIGFILE} and $CONFIG{$ID_COLLECTED}->{CONFIGDBPATH}");
150 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: domain matched $CONFIG{$ID_COLLECTED}->{DOMAIN}" );
151 $conf = &Lemonldap::Config::Initparam::init_param_xml( $CONFIG{$ID_COLLECTED});
152 $log->info("$conf->{message}");
153 }else
154 {
155 $conf = {};
156 }
157 my $c =
158 &Lemonldap::Config::Initparam::merge( $CONFIG{$ID_COLLECTED}, $conf );
159 $CONFIG{$ID_COLLECTED} = $c;
160  
161 # $CONFIG{$ID_COLLECTED}->{KEYIPC} .= "$$.db" if ($CONFIG{$ID_COLLECTED}->{KEYIPC});
162  
163 }
164  
165 #############################Test de CONFIG####################################
166 #################################################################################
167  
168 ## now I save the context of handler
169 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID} end of initialization");
170  
171 ## addon for FASTPATTERNS
172 if ( ( $CONFIG{$ID_COLLECTED}->{FASTPATTERNS} )
173 && !( $CONFIG{$ID_COLLECTED}->{ANONYMOUSFUNC} ) )
174 {
175 my $sub =
176 &Lemonldap::Config::Initparam::built_functionics
177 ( $CONFIG{$ID_COLLECTED}->{FASTPATTERNS} );
178 $CONFIG{$ID_COLLECTED}->{ANONYMOUSFUNC_SRC} = $sub;
179 $CONFIG{$ID_COLLECTED}->{ANONYMOUSFUNC} = eval "$sub";
180 $log->info(
181 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: Phase : FASTPATTERNS TABLE LOADED : $sub"
182 );
183 }
184  
185 ## addon for multihoming
186 if ( ( $CONFIG{$ID_COLLECTED}->{MULTIHOMING} )
187 && !( $CONFIG{$ID_COLLECTED}->{SELECTOR} ) )
188 {
189 my $sub = $CONFIG{$ID_COLLECTED}->{SUB};
190 $CONFIG{$ID_COLLECTED}->{SELECTOR_SRC} = $sub;
191 $CONFIG{$ID_COLLECTED}->{SELECTOR} = eval "$sub";
192 }
193  
194 ################
195  
196 ##
197 foreach ( keys %{ $CONFIG{$ID_COLLECTED} } ) {
198 if ( $_ ne "ENCRYPTIONKEY" ) {
199 $log->info("$ID_COLLECTED:$_ => $CONFIG{$ID_COLLECTED}->{$_}");
200 }
201 }
202  
203 ##### end of initialization
204 ##### begin process request
205 my $uri = $r->uri;
206  
207 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID} :uri requested: $uri");
208  
209 #### multihoming
210 my $MHURI;
211 if ( $CONFIG{$ID_COLLECTED}->{MH} ) {
212 $MHURI = $CONFIG{$ID_COLLECTED}->{SELECTOR}->($uri);
213  
214 # Stop process if no multihosting
215 if ( ( $MHURI eq '1' ) || ( !($MHURI) ) ) {
216 $log->warn(
217 "$CONFIG{$ID_COLLECTED}->{HANDLERID} :multihoming failed for $uri"
218 );
219 return DECLINED;
220 }
221  
222 # load combo config
223 ### I switch the context#
224 my $old_collected = $ID_COLLECTED;
225 $ID_COLLECTED = $MHURI;
226  
227 $log->info("$CONFIG{$old_collected}->{HANDLERID} :SWITCH CONFIG $MHURI"
228 );
229 if ( $CONFIG{$ID_COLLECTED}->{XML} ) {
230 $log->info(
231 "$CONFIG{$ID_COLLECTED}->{HANDLERID} :MULTIHOMING already in use "
232 );
233 }
234 else {
235 my $c =
236 &Lemonldap::Config::Initparam::mergeMH( $CONFIG{$old_collected},
237 $MHURI );
238 $CONFIG{$ID_COLLECTED} = $c;
239 }
240  
241 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID} :MULTIHOMING ON");
242 }
243  
244 #########################
245 ##### for developper ###
246 if ( ( $uri =~ /_lemonldap_internal/i ) && ( $con->get('internaldebug') ) )
247 {
248 # if ( $uri =~ /_lemonldap_internal/i ) {
249 $r->handler("perl-script");
250 $r->push_handlers( PerlHandler => \&_lemonldap_internal );
251 return OK;
252 }
253  
254 if ( ( $CONFIG{$ID_COLLECTED}->{FASTPATTERNS} )
255 && ( $CONFIG{$ID_COLLECTED}->{ANONYMOUSFUNC}->($uri) eq 'OK' ) )
256 {
257 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID} :uri FASTPATTERNS matched: $uri"
258 );
259 return DECLINED;
260 }
261 $APACHE_CODE = DECLINED;
262  
263 if ( $CONFIG{$ID_COLLECTED}->{ENABLELWP} ) {
264 $UA = __PACKAGE__->new;
265 $UA->agent( join "/", __PACKAGE__, $VERSION );
266 $log->info(
267 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: Build-in proxy actived");
268 $r->handler("perl-script");
269 $r->push_handlers( PerlHandler => \&proxy_handler );
270 $APACHE_CODE= OK ;
271 }
272  
273 ### before to enter in protected area
274 ###
275 return $APACHE_CODE if ( $CONFIG{$ID_COLLECTED}->{DISABLEACCESSCONTROL} );
276  
277 ### raz cache level 1
278 # is this area protected
279 # configuration check
280 #
281 #
282 # first check cookie
283  
284 # AUTHENTICATION
285 # cookie search
286 #for apache 2
287 my $__cookie;
288 my $entete2 = $r->headers_in();
289 my $host = $entete2->{Host};
290  
291 #<Recuperation de l'adresse IP cliente>
292 my $connection = $r->connection();
293 my $client_addr = $connection->remote_ip();
294 #</Recuperation de l'adresse IP cliente>
295  
296 #<Modification pour test time out>
297 #Recuperation du Cookie
298 my $idx_tmp = $entete2->{'Cookie'};
299 my $idx;
300 my $timeout;
301  
302 if ( defined( $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT} )
303 && $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT} != 0 )
304 {
305  
306 ( $idx, $timeout ) =
307 Lemonldap::Handlers::Utilities::get_my_timeout(
308 $CONFIG{$ID_COLLECTED}, $idx_tmp );
309  
310 }
311 else {
312 $idx = $idx_tmp;
313 }
314  
315 #</Modification pour test time out>
316  
317 ( my $id, my $cook ) =
318 Lemonldap::Handlers::Utilities::cleanupcookie( $CONFIG{$ID_COLLECTED},$idx );
319  
320 if ( $cook ne $idx ) {
321  
322 ### I must rewrite cookie header)
323 $r->headers_in->unset('Cookie');
324 $r->headers_in->add( 'Cookie' => $cook ) if $cook;
325 }
326  
327 $__cookie = $idx;
328  
329 # Load id value from cookie
330 #NEW if the config is 'softcontrol' no need cookie
331 if ( ( !( $CONFIG{$ID_COLLECTED}->{SOFTCONTROL} ) and !$id ) ) {
332  
333 # No cookie found: redirect to portal
334 $messagelog =
335 "$CONFIG{$ID_COLLECTED}->{HANDLERID} : No cookie found for "
336 . $r->uri;
337 $log->info($messagelog);
338 return &Lemonldap::Handlers::Utilities::goPortal( $r,
339 $CONFIG{$ID_COLLECTED}, 'c' );
340 }
341 my $label = $id || 'SOFTCONTROL';
342 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: id session : $label");
343  
344 #Verification du time out
345  
346 if (!( $CONFIG{$ID_COLLECTED}->{SOFTCONTROL} ) and defined( $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT} )
347 and $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT} != 0 )
348 {
349 if ( time() > $timeout ) {
350 $log->warn("SESSION EXPIRED FOR INACTIVITY");
351 if ($CONFIG{$ID_COLLECTED}->{URLCDATIMEOUT}) {
352 return &Lemonldap::Handlers::Utilities::goPortal( $r,
353 $CONFIG{$ID_COLLECTED}, 'x', $id );
354
355 } else
356 {
357 return &Lemonldap::Handlers::Utilities::goPortal( $r,
358 $CONFIG{$ID_COLLECTED}, 't', $id );
359 }
360 }
361 }
362  
363 # SESSIONS CACHE
364 ########################################################################################################################
365 #<SEARCH IN CACHE LEVEL 1>
366
367 my $ligne_h;
368 my $sessExpTime;
369
370 return $APACHE_CODE unless ($id);
371 if ( $id ne $ID_SAVE ) {
372 %CLIENT = '';
373 }
374 $ID_SAVE = $id;
375 my $cache1key;
376 #key of level one cache
377 if ( $CONFIG{$ID_COLLECTED}->{CLIENTIPCHECK} ) {
378 $cache1key = "$id#$ID_COLLECTED#$client_addr";
379 }else{
380 $cache1key = "$id#$ID_COLLECTED";
381 }
382 #value of level one cache
383 $ligne_h = $CLIENT{$cache1key};
384  
385 if ($ligne_h) {
386 if ( defined( $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} ) ) {
387 my @tab = split ( ":", $ligne_h );
388 $sessExpTime = $tab[2];
389 }
390 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: match in cache level 1 for $cache1key") if $ligne_h;
391
392 #</SEARCH IN CACHE LEVEL 1>
393 ########################################################################################################################
394 #<SEARCH IN CACHE LEVEL 2>
395 }
396 else {
397
398 # Level 2 test by IPC
399 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: No match in cache level 1 for $cache1key");
400 if ( $CONFIG{$ID_COLLECTED}->{CACHEDBPATH} ) {
401 my $message;
402 ( $ligne_h, $message ) =
403 &Lemonldap::Handlers::Utilities::cache2( $CONFIG{$ID_COLLECTED}
404 ->{CACHEDBPATH}, $$, $cache1key );
405 $__STACK = 1;
406 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}:$message");
407 if ( $ligne_h && defined( $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} )) {
408 my @tab2 = split ( ":", $ligne_h );
409 $sessExpTime = $tab2[2];
410 }
411
412 }
413
414 #</SEARCH IN CACHE LEVEL 2>
415 ###################################################################################################################################
416 #<SEARCH IN CACHE LEVEL 3>
417 unless ($ligne_h) { # no match in cache level 1 and 2
418 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID} : Search in cache level 3 for $id");
419 my $dn;
420 my $etat = 0; # 0 = denied ,NULL = not found other values is OK ;
421
422 #Search in the servers memcached
423 my $controle = &Lemonldap::Handlers::Core::locationRules(
424 config => $CONFIG{$ID_COLLECTED},
425 id => $id,
426 uri => $uri,
427 host => $host,
428 );
429
430
431 if ( $controle == 0 ) {
432 return &Lemonldap::Handlers::Utilities::goPortal( $r, $CONFIG{$ID_COLLECTED}, 't', $id );
433 }
434
435
436
437 if ( !defined( $controle->{string} ) ) {
438 if ( $controle->{response} ) {
439 $log->notice("$CONFIG{$ID_COLLECTED}->{HANDLERID}: controle: $controle->{dn} $uri :DENIED ($controle->{response}) ");
440 return $controle->{response};
441 }
442 $log->notice(
443 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: $id ERROR TIMEOUT ");
444 return &Lemonldap::Handlers::Utilities::goPortal( $r, $CONFIG{$ID_COLLECTED}, 't', $id );
445 }
446
447 #Verification of the remote adress
448  
449 if ( ($controle->{clientIPAdress} ne $client_addr) && $CONFIG{$ID_COLLECTED}->{CLIENTIPCHECK} ) {
450 $log->notice("$CONFIG{$ID_COLLECTED}->{HANDLERID}: $id ERROR WRONG IP : $client_addr");
451 return &Lemonldap::Handlers::Utilities::goPortal($r, $CONFIG{$ID_COLLECTED}, 'i', $id);
452 }
453  
454
455 my $header = &Lemonldap::Handlers::Core::getHeader(
456 config => $CONFIG{$ID_COLLECTED},
457 dn => $controle->{dn},
458 uid => $controle->{uid},
459 profil => $controle->{string},
460 );
461
462 $ligne_h = $header->{decoded};
463  
464 if ( defined( $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} ) ) {
465 $sessExpTime = $controle->{SessExpTime};
466 $ligne_h = $ligne_h.":".$sessExpTime;
467
468 }
469
470 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: $cache1key saving in cache level 2");
471
472 $__STACK = 0;
473 &Lemonldap::Handlers::Utilities::save_session( $cache1key,$ligne_h );
474
475 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: SESSION FIND IN CACHE 3 FOR ID $id");
476  
477 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: controle: $controle->{dn} $uri :ACCEPTED");
478  
479 }
480  
481 #</SEARCH IN CACHE LEVEL 3>
482  
483 #<UPDATING CACHE LEVEL 1>
484 $CLIENT{$cache1key} = $ligne_h;
485 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: $cache1key saving in cache level 1");
486 }
487  
488 #</UPDATING CACHE LEVEL 1>
489 my $titi;
490 #<REFRESH LDAP>
491  
492 if ( defined( $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} ) ) {
493 my $ttl;
494 if ( defined( $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT} ) ) {
495 $ttl = $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} + $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT};
496 }else{
497 $ttl = $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} * 2;
498 }
499 (my $return_code,my $HashSession,my $profil,my $reponse) = &Lemonldap::Handlers::Core::Check_Refresh( config => $CONFIG{$ID_COLLECTED},
500 id => $id,
501 uri => $uri,
502 host => $host,
503 logs => $log,
504 ExpTime => $sessExpTime);
505  
506 if ($return_code == -1){
507  
508 return &Lemonldap::Handlers::Utilities::goPortal( $r, $CONFIG{$ID_COLLECTED}, 't', $id );
509 }
510
511 if ($return_code != 0){
512  
513  
514 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: SessExpTime expired. Caches need to be refresh at all level");
515 if ($return_code == 1){
516 #Rafraichissement LDAP
517 #A modifier pour les versions ulte�riers
518 #
519 #
520  
521 $HashSession->{SessExpTime}= &Lemonldap::Handlers::Utilities::fake_refresh_ldap($HashSession,$CONFIG{$ID_COLLECTED},$ttl);
522 $titi = $HashSession->{SessExpTime};
523  
524 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: Reninitializing the SessExpTime on the central server memcached");
525  
526  
527  
528 }
529  
530 #Updating cache 3
531 &Lemonldap::Handlers::Utilities::save_memcached_local($HashSession,$CONFIG{$ID_COLLECTED}->{SERVERS},$ttl);
532 #Creation du Header
533  
534 my $new_header = &Lemonldap::Handlers::Core::getHeader(
535 config => $CONFIG{$ID_COLLECTED},
536 dn => $HashSession->{dn},
537 uid => $HashSession->{uid},
538 profil => $profil,
539 );
540  
541 $ligne_h = $new_header->{decoded};
542 $ligne_h = $ligne_h.":".$HashSession->{SessExpTime};
543  
544
545  
546 #Updating cache 1
547  
548 $CLIENT{$cache1key} = $ligne_h;
549  
550 #Updating cache 2
551  
552 &Lemonldap::Handlers::Utilities::save_session( $cache1key,$ligne_h );
553  
554  
555  
556 if (!defined($profil)) {
557 if ( defined($reponse) ) {
558 $log->notice("$CONFIG{$ID_COLLECTED}->{HANDLERID}: controle: $HashSession->{dn} $uri :DENIED ($reponse) ");
559 return $reponse;
560 }
561 $log->notice("$CONFIG{$ID_COLLECTED}->{HANDLERID}: $id ERROR TIMEOUT ");
562 return &Lemonldap::Handlers::Utilities::goPortal( $r, $CONFIG{$ID_COLLECTED}, 't', $id );
563 }
564  
565
566
567 $log->notice("$CONFIG{$ID_COLLECTED}->{HANDLERID}: Caches has been refresh");
568  
569 }
570 }
571 #</REFRESH LDAP>
572  
573  
574 # all is done for this phase we can cache the header .
575 # now we must up date the cache level 1 and 2 (IPC)
576  
577 ##### I must to resume here (the three caches )
578 ####
579 ###
580 #
581 ### add user in access log
582 if ( defined( $CONFIG{$ID_COLLECTED}->{SESSCACHEREFRESHPERIOD} ) ) {
583 my @tab = split ( ":", $ligne_h );
584 $ligne_h = $tab[0] . ":" . $tab[1];
585 }
586  
587 my $_header = &Lemonldap::Handlers::Core::forgeHeader(
588 config => $CONFIG{$ID_COLLECTED},
589 line => $ligne_h,
590 );
591 my $sep = "_";
592  
593 #<TEST TIMEOUT>
594 if ( defined $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT} ) {
595  
596 my $inact = $CONFIG{$ID_COLLECTED}->{INACTIVITYTIMEOUT};
597 if ( $inact != 0 ) {
598
599 my $new_time = time() + $inact;
600 if ( defined( $CONFIG{$ID_COLLECTED}->{ENCRYPTIONKEY} ) ) {
601 my $cle = $CONFIG{$ID_COLLECTED}->{ENCRYPTIONKEY};
602 my $ciphe = new Crypt::CBC(
603 -key => $cle,
604 -cipher => 'Blowfish',
605 -iv => 'lemonlda',
606 -header => 'none'
607 );
608 $new_time = $ciphe->encrypt_hex($new_time);
609 }
610  
611 my $val_test = $id . $sep . $new_time;
612 my $name = $CONFIG{$ID_COLLECTED}->{COOKIE};
613 my $domain = "." . $CONFIG{$ID_COLLECTED}->{DOMAIN};
614  
615 my $new_cookie = CGI::Cookie->new(
616 -name => $name,
617 -value => $val_test,
618 -domain => $domain,
619 -path => "/",
620 );
621  
622 $r->headers_out->add( 'Set-Cookie' => $new_cookie );
623 $log->info("Timeout re-initialized");
624 }
625 else {
626 $log->info(
627 "The inactivity timeout has been positionned at O!!!!");
628 }
629 }
630 else {
631 $log->info(
632 "The inactivity timeout hasn't been set." );
633 }
634  
635 #</TEST TIMEOUT>
636  
637 if ($_header) {
638 $r->user( $_header->{user} ) if $_header->{user};
639 my $hcode = $_header->{content};
640  
641 ############### We can insert the header #####################
642  
643 $r->headers_in->add( $_header->{header} => $hcode );
644 $log->debug(
645 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: header genered :$_header->{header} => $hcode "
646 );
647 $log->info(
648 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: header before encoding: $_header->{decoded}"
649 );
650 $log->debug(
651 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: header after encoding: $hcode"
652 );
653 }
654 else {
655 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}:no header genered ");
656  
657 }
658  
659 ### supprimer en prod ####
660 # my $l = Dumper (%CONFIG );
661 return $APACHE_CODE
662  
663 }
664  
665 ################
666 # #
667 # end handler #
668 # #
669 ################
670  
671 ####################################
672 # proxy_handler :the lwp engine #
673 # #
674 ####################################
675 #TODO : timeout
676 # 500 return code
677 # motifout instead motifin
678 sub proxy_handler {
679 my $r = shift;
680  
681 # Transformation: GET /index.html becomes http://servername/index.html
682 # $url contains the real value (hided server)
683 # $url_init contains the asked value
684 #add this in order to log
685 my $log = $r->log;
686 my $url = $r->uri;
687 my $entete2 = $r->headers_in();
688 my $HOST = $entete2->{'Host'};
689 my $flag = 0;
690 my $host_target;
691 $url = "/" unless $url;
692  
693 # replace formatin by formatout
694 #
695 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: LWP ENGINE URL $url");
696 $log->info("$CONFIG{$ID_COLLECTED}->{HANDLERID}: LWP ENGINE HOST $HOST");
697  
698 if ( $CONFIG{$ID_COLLECTED}->{MOTIFOUT} ) {
699 if ( $CONFIG{$ID_COLLECTED}->{MOTIFOUT} =~ /ANYWHERE/ ) {
700 $flag = 1;
701  
702 $r->headers_in->unset('Accept-Encoding');
703 ( $host_target, my $suite ) = $url =~ /\/(.+?)\/(.+)/;
704 ($host_target) = $url =~ /\/(.+)/ unless $host_target;
705 $host_target =~ s/\/$//;
706  
707 #$host=~ s/_/\./g;
708 $suite = "/" unless $suite;
709 $suite = "/" . $suite unless $suite =~ /^\//;
710 $suite = "/" unless $suite;
711 $url = $suite;
712  
713 $log->info(
714 "$CONFIG{$ID_COLLECTED}->{HANDLERID}:LWP ANYWHERE DESTINATION actived $host_target -- $suite "
715 );
716 $CONFIG{$ID_COLLECTED}->{BASEPRIV} = "http://$host_target";
717 }
718 else {
719 if ($CONFIG{$ID_COLLECTED}->{MOTIFOUT} eq '/' ) {
720 $url =~
721 s/$CONFIG{$ID_COLLECTED}->{MOTIFIN}//;
722 } else {
723 $url =~
724 s/$CONFIG{$ID_COLLECTED}->{MOTIFIN}/$CONFIG{$ID_COLLECTED}->{MOTIFOUT}/;
725 }
726 }
727 }
728 $url .= "?" . $r->args if ( $r->args );
729 my $url_init = $CONFIG{$ID_COLLECTED}->{BASEPUB} . $url;
730 my $uuu = $url;
731 $url = $CONFIG{$ID_COLLECTED}->{BASEPRIV} . $uuu;
732 $log->info( "$CONFIG{$ID_COLLECTED}->{HANDLERID}: URLPRIV ACTIVED: $url
733 URLPUB REQUESTED : $url_init"
734 );
735  
736 my $request = HTTP::Request->new( $r->method, $url );
737 $r->headers_in->do( sub {
738 $request->header(@_);
739 1;
740 } );
741  
742 # copy POST data, if any
743 if ( $r->method eq 'POST' ) {
744 my $len =0;
745 $len = $r->headers_in->{'Content-length'};
746 my $buf='';
747 if ($len < 0 ) { $len=0;}
748 if ($len > 0) {
749 $r->read( $buf, $len );
750 }
751 $request->content($buf);
752 $request->content_type( $r->headers_in->{'Content-Type'} );
753 }
754  
755 ###begin: some modification like mod_proxy does
756 if ( $request->header('Host') ) {
757 my $host = $request->header('Host');
758 ( my $priv ) = $CONFIG{$ID_COLLECTED}->{BASEPRIV} =~ /:\/\/(.+)/;
759 ( my $pub ) = $CONFIG{$ID_COLLECTED}->{BASEPUB} =~ /:\/\/(.+)/;
760 $host =~ s/$pub/$priv/;
761 $host =~ s/:\d+$// ;
762  
763 $request->header( 'Host' => $host );
764  
765 #DEBUG 16/07/2007
766  
767 #print STDERR "DEBUG ADONIS: PRIV: $priv PUB: $pub HOST_TARGET : $host_target " ;
768 #
769 #END
770  
771 }
772  
773 ### here I modify keep alive by close
774 # if ($request->header('Connection')){
775 # $request->header('Connection' => 'close');
776 # }
777 # if ($request->header('Keep-Alive')){
778 # $request->header('Keep-Alive' => '');
779 # }
780  
781 my $messagelog =
782 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: request " . $request->as_string();
783 $log->info($messagelog);
784 #> modif du 20/04/06 reverse condition
785 if ( !$CONFIG{$ID_COLLECTED}->{CHASEREDIRECT} ) {
786 $log->info(
787 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: LWP CHASEREDIRECT DESACTIVED(DEFAULT)");
788 my @tt = ('HEAD');
789 $UA->requests_redirectable( \@tt );
790 } else
791 {
792 my @tt = ('HEAD','GET');
793 $UA->requests_redirectable( \@tt );
794 $log->info(
795 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: LWP CHASEREDIRECT ACTIVED");
796
797 }
798  
799 ### deal this lwptimeout :
800 if ( $CONFIG{$ID_COLLECTED}->{LWPTIMEOUT} ) {
801 $log->info(
802 "$CONFIG{$ID_COLLECTED}->{HANDLERID}:LWP TIMEOUT :$CONFIG{$ID_COLLECTED}->{LWPTIMEOUT} armed"
803 );
804 $UA->timeout( $CONFIG{$ID_COLLECTED}->{LWPTIMEOUT} );
805 }
806  
807 # LWP proxy
808 # I 'll forward on an external proxy
809 if ( $CONFIG{$ID_COLLECTED}->{APPLPROXY} ) {
810 $log->info(
811 "$CONFIG{$ID_COLLECTED}->{HANDLERID}:OUTPUT PROXY:$CONFIG{$ID_COLLECTED}->{APPLPROXY}"
812 );
813  
814 $UA->proxy( http => $CONFIG{$ID_COLLECTED}->{APPLPROXY} );
815 }
816 if ( $url =~ /_lemonldap_debug/ ) {
817 $r->content_type('text/html');
818 $r->print(<<END);
819 <html>
820 <head><title>lemonldap websso</title></head>
821 <body>
822 <h1>Lemonldap websso headers</h1>
823 <p>
824 END
825 my $l = $request->as_string();
826 $l =~ s/\n/<br>/g;
827 $r->print($l);
828 $r->print( "</body>
829 </html>" );
830  
831 return OK;
832 }
833  
834 ####################################
835 # here implementation #
836 # https gateway #
837 # #
838 # #
839 # #
840 ####################################
841 #
842 if ( $CONFIG{$ID_COLLECTED}->{HTTPS} ) {
843  
844 # on veut faire du https avec le serveur a proteger
845 eval "use Crypt::SSLeay;";
846  
847 $ENV{HTTPS_VERSION} = '3';
848 if ( $CONFIG{$ID_COLLECTED}->{AUTH} ) {
849  
850 # lemonldap doit s'authentifier par certificat
851 if ( $CONFIG{$ID_COLLECTED}->{PKCS12} ) {
852  
853 # la presence de pkcs12 est testee en premier
854 $ENV{HTTPS_PKCS12_FILE} = $CONFIG{$ID_COLLECTED}->{PKCS12};
855 $ENV{HTTPS_PKCS12_PASSWORD} =
856 $CONFIG{$ID_COLLECTED}->{PKCS12_PWD};
857 }
858 else {
859 $ENV{HTTPS_CERT_FILE} = $CONFIG{$ID_COLLECTED}->{CERT_FILE};
860 $ENV{HTTPS_KEY_FILE} = $CONFIG{$ID_COLLECTED}->{KEY_FILE};
861 }
862 }
863 }
864  
865 #
866 ####################
867 # fin https gateway#
868 ####################
869 #
870 #
871 my $response = $UA->request($request);
872  
873 ### begin: somes bad requests have bad header .
874 $messagelog =
875 "$CONFIG{$ID_COLLECTED}->{HANDLERID}: response "
876 . $response->as_string();
877  
878 $log->info($messagelog);
879  
880 my $content = $response->header('Content-type');
881 $content = 'text/html' unless $content;
882 $content =~ s/,/;/g;
883  
884 ### end: somes bad requests have bad header .
885 $r->content_type($content);
886  
887 ### begin: I correct on the fly some incomming header like mod_proxy does
888 if ( $response->header('Location') ) {
889 my $h = $response->header('Location');
890 ### In case of multihoming context , sometimes location is not a well know location ,so I must adjust this handly
891 if ($CONFIG{$ID_COLLECTED}->{SOURCEREDIRECTION}) {
892 $h=~ s/$CONFIG{$ID_COLLECTED}->{SOURCEREDIRECTION}/$CONFIG{$ID_COLLECTED}->{TARGETREDIRECTION}/;
893 }
894  
895 #Patch 16/07/2007 pour traitement du port dans le Location des 302
896  
897 my $trait_loc;
898
899 if (( $h =~ /:\d+$/) && ($CONFIG{$ID_COLLECTED}->{BASEPRIV} =~ /:\d+$/ ) ) {
900 $h =~
901 s/$CONFIG{$ID_COLLECTED}->{BASEPRIV}/$CONFIG{$ID_COLLECTED}->{BASEPUB}/
902 unless $flag;
903 $trait_loc = "Port dans Location ET Basepriv \n" ;
904 }elsif ( !( $h =~ /:\d+$/) && ! ($CONFIG{$ID_COLLECTED}->{BASEPRIV} =~ /:\d+$/ ) ) {
905  
906 $h =~ s/$CONFIG{$ID_COLLECTED}->{BASEPRIV}/$CONFIG{$ID_COLLECTED}->{BASEPUB}/
907 unless $flag;
908 $trait_loc = "Aucun Port\n " ;
909 } else {
910
911 (my $privreduct ) = $CONFIG{$ID_COLLECTED}->{BASEPRIV} =~ /^(.+):\d+$/ ;
912 $h =~ s/$privreduct/$CONFIG{$ID_COLLECTED}->{BASEPUB}/
913 unless $flag;
914 $trait_loc = "Port dans Basepriv uniquement \n" ;
915  
916 }
917  
918 #print STDERR "Traitement Location : " . $trait_loc ;
919 #FIn de patch
920  
921 if ($flag) {
922 $h =~ s/:\/\//:\/\/$HOST\//;
923 $h =~ s/http:/https:/g;
924 }
925 $response->header( 'Location' => $h );
926
927
928 }
929  
930 ############ a voir ########################
931 if ( $response->header('Content-Base') ) {
932 my $h = $response->header('Content-Base');
933 $h =~
934 s/$CONFIG{$ID_COLLECTED}->{BASEPRIV}/$CONFIG{$ID_COLLECTED}->{BASEPUB}/
935 unless $flag;
936 ;
937 $h =~ s/:\/\//:\/\/$HOST\// if $flag;
938 ;
939  
940 # $h =~ s/http:\/\//http:\/\/$HOST\//;
941 $response->header( 'Content-Base' => $h );
942 }
943  
944 ### end: I correct on the fly some incomming header like mod_proxy does
945 my $code = $response->code();
946 if ( $code == 500 ) {
947 $r->status(503);
948 return 503;
949  
950 }
951 else {
952 $r->status( $response->code() );
953 }
954 $r->status_line( join " ", $response->code(), $response->message );
955 $response->scan( sub {
956 ( my $cle, my $val ) = @_;
957  
958 if ( $cle =~ /set-cookie/i ) {
959 my $lcookie =
960 Lemonldap::Handlers::Utilities::rewrite_cookie( $val,
961 $CONFIG{$ID_COLLECTED} );
962 $r->headers_out->add( $cle => $lcookie );
963  
964 # $r->headers_out->add($cle => $lcookie[1] ) if $lcookie[1];
965 }
966 else { $r->headers_out->add( $cle => $val ) unless $cle =~ /Client/; }
967  
968 } );
969 if ( $r->header_only ) {
970 return OK;
971 }
972  
973 $content = \$response->content;
974 my $html = $$content;
975 if ( $flag == 1 or $CONFIG{$ID_COLLECTED}->{REWRITEHTML} ) { #### IF MODE ANYWHERE ####
976  
977 ######################################################################
978 # here I 'm modifying the html source for yahoo.fr and google.fr #
979 # I think that I must improve modifications but It's just for demo #
980 # the site target must be KISS keep it Simple and Stupid #
981 ######################################################################
982 $html = &Lemonldap::Handlers::Core::ParseHtml(
983 html => $html,
984 https => $ENV{HTTPS},
985 config => $CONFIG{$ID_COLLECTED},
986 host => $HOST,
987 uri =>$url,
988 target => $host_target
989 );
990  
991 }
992  
993 $r->content_type('text/html') unless $$content;
994 $r->print( $html || $response->error_as_HTML );
995 $log->notice("$CONFIG{$ID_COLLECTED}->{HANDLERID}: $url response sent");
996 return OK;
997  
998 }
999  
1000 #####################
1001 # #
1002 # end proxy_handler #
1003 # lwp engine #
1004 # #
1005 #####################
1006  
1007 ###########################################################
1008 # _lemonldap_internal handler #
1009 # add at your url /_lemonldap_internal #
1010 # eg : http://appli1.demo.net/_lemonldap_internal #
1011 # in order to dump the internal config of apache children #
1012 # add ?id=handler append another config handler on output #
1013 # #
1014 ###########################################################
1015  
1016 sub _lemonldap_internal {
1017 my $r = shift;
1018 my $p = $r->args;
1019 my @parax = split "&", $p;
1020 my @pr;
1021  
1022 foreach (@parax) {
1023 ( my $cle, my $val ) = split "=", $_;
1024 push @pr, $cle;
1025 push @pr, $val;
1026 }
1027 my %param = @pr;
1028  
1029 $r->content_type('text/html');
1030 $r->print(<<END);
1031 <html>
1032 <head><title>lemonldap websso</title></head>
1033 <body>
1034 <h1>Lemonldap websso internal table</h1>
1035 <p>
1036  
1037 END
1038  
1039 foreach ( keys %CONFIG ) {
1040 print "$_<br>\n";
1041 }
1042 print "<hr>\n";
1043 my $tmp = $CONFIG{$ID_COLLECTED};
1044 print "<h3>$ID_COLLECTED on $$</H3>\n";
1045  
1046 foreach ( keys %$tmp ) {
1047 if ( ref $tmp->{$_} ) {
1048 my $t = ref $tmp->{$_};
1049 print "$_ => $t reference<br>\n";
1050 }
1051 else {
1052 print "$_ => $tmp->{$_}<br>\n";
1053 }
1054  
1055 }
1056 my $s = $param{'id'};
1057 if ($s) {
1058 print "<hr>\n";
1059 my $tmp = $CONFIG{$s};
1060 print "<h3>$s on $$ (features)</H3>\n";
1061  
1062 foreach ( keys %$tmp ) {
1063 if ( ref $tmp->{$_} ) {
1064 my $t = ref $tmp->{$_};
1065 print "$_ => $t reference<br>\n";
1066 }
1067 else {
1068 print "$_ => $tmp->{$_}<br>\n";
1069 }
1070  
1071 }
1072  
1073 }
1074  
1075 print "</body>
1076 </html>
1077 ";
1078  
1079 return OK;
1080  
1081 }
1082  
1083 ############################
1084 # #
1085 # end _lemonldap_internal #
1086 # handler #
1087 # #
1088 ############################
1089  
1090 1;
1091  
1092 ###############################
1093 ### fin etape 1
1094 ##############################
1095  
1096 =pod
1097  
1098 =for html <center> <H1> Lemonldap::Handlers::Generic4a2 </H1></center>
1099  
1100  
1101 =head1 NAME
1102  
1103 Lemonldap::Handlers::Generic - Perl extension for Lemonldap sso system
1104  
1105 Lemonldap::Handlers::Generic4a2 - Handler for Apache2 Lemonldap SSO
1106 system
1107
1108 Lemonldap::Handlers::Generic4a2SSL - Handler full SSL Apache2 Lemonldap SSO
1109  
1110  
1111 =head1 SYNOPSIS
1112
1113 In httpd.conf
1114  
1115 .....
1116 perltranshandler Lemonldap::Handlers::Generic4a2
1117 .....
1118
1119  
1120 =head1 DESCRIPTION
1121  
1122 Generic4a2 is the central piece of websso framework .
1123 This module provides several methods but the principal goal of this is the handler function .
1124 It can be combined with mod_proxy or mod_rewrite and all other apache's modules .
1125 It provides also an built-in http proxy with LWP .
1126 see http://lemonldap.sf.net for more infos .
1127
1128  
1129 =head2 Parameters (see also doc folder)
1130  
1131 A minimal configuration must provide infos about :
1132  
1133 =over 1
1134  
1135 =item config
1136  
1137 LemonldapConfig "/foo/bar/file_config.xml"
1138 The filename of the mean XML Config :It's REQUIRED
1139  
1140 =item domain
1141  
1142 LemonldapDomain foo.bar
1143 It fixes the value of domain for the application protected by this handler (see below)
1144  
1145 =item xml section in config
1146
1147 LemonldapHandlerId <xml section>
1148  
1149 It fixes the value of XML section in config
1150  
1151 =back
1152  
1153  
1154 =head2 Example (a KISS example, see also eg folder)
1155
1156 In httpd.conf
1157  
1158 <virtualHost 127.0.0.1:80>
1159 servername authen.demo.net
1160 PerlModule Apache2::compat
1161 PerlModule Bundle::Apache2
1162 PerlModule Lemonldap::Handlers::Generic4a2
1163 perltranshandler Lemonldap::Handlers::Generic4a2
1164 PerlSetVar LemonldapDomain demo.net
1165 PerlSetVar LemonldapConfig /usr/local/apache/conf/application_new.xml
1166 PerlSetVar LemonldapHandlerID myintranet
1167 proxypass /intranet http://lemonldap.sourceforge.net
1168 proxypassreverse /intranet http://lemonldap.sourceforge.net
1169 documentroot /usr/local/apache/htdocs
1170 </virtualhost>
1171  
1172  
1173 In /usr/local/apache/conf/application_new.xml
1174 <lemonconfig>
1175 <domain id="demo.net"
1176 Cookie="lemondemo"
1177 >
1178 <handler
1179 id="myintranet"
1180 DisabledControl="1"
1181 />
1182 </domain>
1183 </lemonconfig>
1184  
1185
1186 Now you can put http://authen.demo.net/intranet/ in your browser and you will see lemonldap's site
1187 AND now you can control who and where goes on your site .
1188
1189 You can pass parameters from httpd.conf with perlsetvar facilities or put them in xml file
1190  
1191 =head2 Functions
1192  
1193 =over 1
1194  
1195 =item handler
1196  
1197 It's the mean function which does all jobs . If the enebledproxy parameter is set to 1 ,this function
1198 will push proxy_handler function reference on the handler's stack . If not it returns DECLINED (mod_proxy will be actived)
1199  
1200 =item proxy_handler
1201  
1202 It's the built-in proxy (LWP) web embedded in lemonldap framework . It is actived by enabledproxy parameter .
1203 Some parameters are about this proxy and its behaviour
1204  
1205 =item _lemonldap_internal
1206  
1207 append this keyword at the end of url and you will can see all config for a specific apache's child
1208  
1209 =item _lemonldap_debug
1210  
1211 append this keyword at the end of url and you will can see all headers send to host.
1212 Available ONLY with built-in proxy
1213  
1214  
1215 =back
1216  
1217  
1218 =head2 Features
1219  
1220 Generic4a2 is build arround perl's modules .
1221  
1222 Those modules are :
1223  
1224 =over 1
1225  
1226 =item Utilities :
1227  
1228 collection of function
1229  
1230 =item Core :
1231
1232 It provides basics services like the cache service, forge header service or authorization service.
1233
1234 Core.pm can use YOUR own services for all this cycle . It's plugger . Lemonldap framework is available
1235 with somes services but you can with Core.pm propose your schemas.
1236 News parameters were added in XML DTD in order to describe the sequence.
1237  
1238 =item MatrixPolicy :
1239
1240 manage authorization process , based on the hash of session (like preceding version)
1241  
1242 =item Memsession :
1243
1244 manage the backend of session (cache level 3)
1245  
1246 =item AuthorizationHeader :
1247
1248 manage the construction of header
1249  
1250 =item RewriteHTML :
1251  
1252 Rewrite on fly html source in order to ajust somes tags like BASE , href or src
1253 Available ONLY with built-in proxy
1254
1255  
1256 =back
1257  
1258 =head4 More features
1259  
1260 =over 1
1261  
1262 =item Authentification
1263
1264 Keep in mind that the handler doesn't know HOW authenticate anybody but only knows WHERE authenticate .
1265 The parameter 'portal' tells it where to send the authentification request.
1266  
1267 =item Caches
1268  
1269 Thre are three levels of cache in lemonldap .
1270  
1271 *First cache (level 1) is a very KISS , it's a memory structure in the program .
1272 *Next cache (level 2) is realised by using berkeleyDB hash
1273 *Last cache (level 3) is realised by using memcached (see Apache::Session::Memorycached on CPAN)
1274  
1275 =back
1276  
1277 =head1 SEE ALSO
1278  
1279 Lemonldap(3), Lemonldap::Portal::Standard
1280  
1281 http://lemonldap.sourceforge.net/
1282  
1283 "Writing Apache Modules with Perl and C" by Lincoln Stein E<amp> Doug
1284 MacEachern - O'REILLY
1285  
1286 =over 1
1287  
1288 =item Eric German, E<lt>germanlinux@yahoo.frE<gt>
1289  
1290 =item Isabelle Serre, E<lt>isabelle.serre@justice.gouv.frE<gt>
1291  
1292 =back
1293  
1294 =head1 COPYRIGHT AND LICENSE
1295  
1296 Copyright (C) 2004 by Eric German E<amp> Isabelle Serre
1297  
1298 Lemonldap originaly written by Eric german who decided to publish him in 2003
1299 under the terms of the GNU General Public License version 2.
1300  
1301 =over 1
1302  
1303 =item This package is under the GNU General Public License, Version 2.
1304  
1305 =item The primary copyright holder is Eric German.
1306  
1307 =item Portions are copyrighted under the same license as Perl itself.
1308  
1309 =item Portions are copyrighted by Doug MacEachern and Lincoln Stein.
1310 This library is under the GNU General Public License, Version 2.
1311  
1312 =item Portage under Apache2 is made with help of : Ali Pouya and
1313 Shervin Ahmadi (MINEFI/DGI)
1314  
1315 =back
1316  
1317 This program is free software; you can redistribute it and/or modify
1318 it under the terms of the GNU General Public License as published by
1319 the Free Software Foundation; version 2 dated June, 1991.
1320  
1321 This program is distributed in the hope that it will be useful,
1322 but WITHOUT ANY WARRANTY; without even the implied warranty of
1323 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1324 GNU General Public License for more details.
1325  
1326 A copy of the GNU General Public License is available in the source tree;
1327 if not, write to the Free Software Foundation, Inc.,
1328 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1329  
1330 =cut