| 1 | package Lemonldap::Handlers::LogoutCAS; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Lemonldap::Config::Parameters; | ||
| 7 | use Apache2::Const qw(DONE FORBIDDEN OK SERVER_ERROR REDIRECT); | ||
| 8 | use Apache2::ServerUtil (); | ||
| 9 | use Apache2::Log(); | ||
| 10 | use Apache2::ServerRec(); | ||
| 11 | use CGI ':cgi-lib'; | ||
| 12 | use CGI::Cookie; | ||
| 13 | my $html; | ||
| 14 | |||
| 15 | sub handler { | ||
| 16 | my $r = shift; | ||
| 17 | my $log = $r->log; | ||
| 18 | my $MyApplicationXmlFile = $r->dir_config('ConfigFile'); | ||
| 19 | my $MyDomain = lc( $r->dir_config('Domain') ); | ||
| 20 | |||
| 21 | my $Parameters = | ||
| 22 | Lemonldap::Config::Parameters->new( file => $MyApplicationXmlFile, ); | ||
| 23 | my $Conf_Domain = $Parameters->getDomain($MyDomain); | ||
| 24 | |||
| 25 | my $Cookie_Name = $Conf_Domain->{Cookie}; | ||
| 26 | my $page_html = $Conf_Domain->{LogoutCASPage}; | ||
| 27 | |||
| 28 | ########################################################################## | ||
| 29 | my $pathlemon = "/"; | ||
| 30 | my $pathCookie = "/cas"; | ||
| 31 | my $dotdomain = "." . $MyDomain; | ||
| 32 | |||
| 33 | $log->info( "Set-Cookie: -name => $Cookie_Name -value => -domain => " | ||
| 34 | . ".$dotdomain -path => $pathCookie" ); | ||
| 35 | my $CASCookie = CGI::cookie( | ||
| 36 | -name => "CASTGC", | ||
| 37 | -value => 0, | ||
| 38 | -domain => $dotdomain, | ||
| 39 | -path => $pathCookie, | ||
| 40 | ); | ||
| 41 | |||
| 42 | my $LemonCookie = CGI::cookie( | ||
| 43 | -name => $Cookie_Name, | ||
| 44 | -value => 0, | ||
| 45 | -domain => $dotdomain, | ||
| 46 | -path => $pathlemon, | ||
| 47 | ); | ||
| 48 | ############################################## | ||
| 49 | if ( !$html ) { | ||
| 50 | my $file; | ||
| 51 | open( $file, "<$page_html" ); | ||
| 52 | local $/; | ||
| 53 | $/ = ''; | ||
| 54 | $html = <$file>; | ||
| 55 | close $file; | ||
| 56 | } | ||
| 57 | $r->content_type('text/html'); | ||
| 58 | |||
| 59 | # my $linecookie= "CASTGC=0;domain=$dotdomain;path=/cas/ ; $cookiename=0; | ||
| 60 | # $r->headers_out->{'Set-Cookie'}= [$LemonCookie,$CASCookie] ; | ||
| 61 | $r->headers_out->add( 'Set-Cookie' => $CASCookie ); | ||
| 62 | $r->headers_out->add( 'Set-Cookie' => $LemonCookie ); | ||
| 63 | $html =~ s/%user%//g; | ||
| 64 | $html =~ s/%secret%//g; | ||
| 65 | $html =~ s/%message%//g; | ||
| 66 | $html =~ s/%urldc%//g; | ||
| 67 | $html =~ s/%urlc%//g; | ||
| 68 | $html =~ s/%it%//g; | ||
| 69 | |||
| 70 | $r->print; | ||
| 71 | $r->print($html); | ||
| 72 | return OK; | ||
| 73 | |||
| 74 | } | ||
| 75 | 1; |