Apache-Session-LDAP-0.2/0000755000175000017500000000000011772234064014257 5ustar xavierxavierApache-Session-LDAP-0.2/lib/0000755000175000017500000000000011772233751015027 5ustar xavierxavierApache-Session-LDAP-0.2/lib/Apache/0000755000175000017500000000000011772233751016210 5ustar xavierxavierApache-Session-LDAP-0.2/lib/Apache/Session/0000755000175000017500000000000011772233751017633 5ustar xavierxavierApache-Session-LDAP-0.2/lib/Apache/Session/Store/0000755000175000017500000000000011772233751020727 5ustar xavierxavierApache-Session-LDAP-0.2/lib/Apache/Session/Store/LDAP.pm0000644000175000017500000001113311772233433022001 0ustar xavierxavierpackage Apache::Session::Store::LDAP; use strict; use vars qw($VERSION); use Net::LDAP; $VERSION = '0.2'; sub new { my $class = shift; return bless {}, $class; } sub insert { my $self = shift; my $session = shift; $self->{args} = $session->{args}; my $msg = $self->ldap->add( "cn=$session->{data}->{_session_id}," . $self->{args}->{ldapConfBase}, attrs => [ objectClass => [ 'top', 'applicationProcess' ], cn => $session->{data}->{_session_id}, description => $session->{serialized}, ], ); $self->logError($msg) if ( $msg->code ); } sub update { my $self = shift; my $session = shift; $self->{args} = $session->{args}; my $msg = $self->ldap->modify( "cn=$session->{data}->{_session_id}," . $self->{args}->{ldapConfBase}, replace => { description => $session->{serialized}, }, ); $self->logError($msg) if ( $msg->code ); } sub materialize { my $self = shift; my $session = shift; $self->{args} = $session->{args}; my $msg = $self->ldap->search( base => "cn=$session->{data}->{_session_id}," . $self->{args}->{ldapConfBase}, filter => '(objectClass=applicationProcess)', scope => 'base', attrs => ['description'], ); $self->logError($msg) if ( $msg->code ); eval { $session->{serialized} = $msg->shift_entry()->get_value('description'); }; if ( !defined $session->{serialized} ) { die "Object does not exist in data store"; } } sub remove { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->ldap->delete( "cn=$session->{data}->{_session_id}," . $self->{args}->{ldapConfBase} ); } sub ldap { my $self = shift; return $self->{ldap} if ( $self->{ldap} ); # Parse servers configuration my $useTls = 0; my $tlsParam; my @servers = (); foreach my $server ( split /[\s,]+/, $self->{args}->{ldapServer} ) { if ( $server =~ m{^ldap\+tls://([^/]+)/?\??(.*)$} ) { $useTls = 1; $server = $1; $tlsParam = $2 || ""; } else { $useTls = 0; } push @servers, $server; } # Connect my $ldap = Net::LDAP->new( \@servers, onerror => undef, ( $self->{args}->{ldapPort} ? ( port => $self->{args}->{ldapPort} ) : () ), ) or die( 'Unable to connect to ' . join( ' ', @servers ) ); # Start TLS if needed if ($useTls) { my %h = split( /[&=]/, $tlsParam ); $h{cafile} = $self->{args}->{caFile} if ( $self->{args}->{caFile} ); $h{capath} = $self->{args}->{caPath} if ( $self->{args}->{caPath} ); my $start_tls = $ldap->start_tls(%h); if ( $start_tls->code ) { $self->logError($start_tls); return; } } # Bind with credentials my $bind = $ldap->bind( $self->{args}->{ldapBindDN}, password => $self->{args}->{ldapBindPassword} ); if ( $bind->code ) { $self->logError($bind); return; } $self->{ldap} = $ldap; return $ldap; } sub logError { my $self = shift; my $ldap_operation = shift; die "LDAP error " . $ldap_operation->code . ": " . $ldap_operation->error; } 1; =pod =head1 NAME Apache::Session::Store::LDAP - Use LDAP to store persistent objects =head1 SYNOPSIS use Apache::Session::Store::LDAP; my $store = new Apache::Session::Store::LDAP; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); =head1 DESCRIPTION This module fulfills the storage interface of Apache::Session. The serialized objects are stored in an LDAP directory file using the Net::LDAP Perl module. =head1 OPTIONS This module requires one argument in the usual Apache::Session style. The keys ldapServer, ldapBase, ldapBindDN, ldapBindPassword are required. The key ldapPort is optional. Example: tie %s, 'Apache::Session::LDAP', undef, { ldapServer => 'localhost', ldapBase => 'dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', }; =head1 AUTHOR Xavier Guimard, Eguimard@E =head1 COPYRIGHT AND LICENSE Copyright (C) 2009, 2012 by Xavier Guimard This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =head1 SEE ALSO L =cut Apache-Session-LDAP-0.2/lib/Apache/Session/LDAP.pm0000644000175000017500000000317711772233463020721 0ustar xavierxavierpackage Apache::Session::LDAP; use strict; use vars qw(@ISA $VERSION); $VERSION = '0.2'; @ISA = qw(Apache::Session); use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Store::LDAP; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Store::LDAP $self; $self->{lock_manager} = new Apache::Session::Lock::Null $self; $self->{generate} = \&Apache::Session::Generate::MD5::generate; $self->{validate} = \&Apache::Session::Generate::MD5::validate; $self->{serialize} = \&Apache::Session::Serialize::Base64::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Base64::unserialize; return $self; } 1; =pod =head1 NAME Apache::Session::LDAP - An implementation of Apache::Session =head1 SYNOPSIS use Apache::Session::LDAP; tie %hash, 'Apache::Session::LDAP', $id, { ldapServer => 'ldap://localhost:389', ldapConfBase => 'dmdName=applications,dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', }; =head1 DESCRIPTION This module is an implementation of Apache::Session. It uses an LDAP directory to store datas. =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE Copyright (C) 2009, 2012 by Xavier Guimard This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. =head1 SEE ALSO L =cut Apache-Session-LDAP-0.2/t/0000755000175000017500000000000011772233751014524 5ustar xavierxavierApache-Session-LDAP-0.2/t/Apache-Session-LDAP.t0000644000175000017500000000075211172403611020221 0ustar xavierxavier# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Apache-Session-LDAP.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; BEGIN { use_ok('Apache::Session::LDAP') }; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. Apache-Session-LDAP-0.2/META.yml0000644000175000017500000000112011772234034015517 0ustar xavierxavier--- #YAML:1.0 name: Apache-Session-LDAP version: 0.2 abstract: An implementation of Apache::Session author: - Xavier Guimard license: perl distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Apache::Session: 0 Net::LDAP: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.57_05 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Apache-Session-LDAP-0.2/MANIFEST0000644000175000017500000000030711172404353015402 0ustar xavierxavierChanges Makefile.PL MANIFEST README t/Apache-Session-LDAP.t lib/Apache/Session/LDAP.pm lib/Apache/Session/Store/LDAP.pm META.yml Module meta-data (added by MakeMaker) Apache-Session-LDAP-0.2/Changes0000644000175000017500000000044711772233671015562 0ustar xavierxavierRevision history for Perl extension Apache::Session::LDAP. 0.01 Sat Apr 18 19:02:01 2009 - original version; created by h2xs 1.23 with options -AXn Apache::Session::LDAP 0.1 Wed Dec 8 16:30:32 2010 - change serialization 0.2 Tue Jun 26 06:15:12 2012 - remove inappropriate comment Apache-Session-LDAP-0.2/README0000644000175000017500000000225311172403611015127 0ustar xavierxavierApache-Session-LDAP version 0.01 ================================ The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed. A README file is required for CPAN modules since CPAN extracts the README file from a module distribution so that people browsing the archive can use it get an idea of the modules uses. It is usually a good idea to provide version information here so that people can decide whether fixes for the module are worth downloading. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: blah blah blah COPYRIGHT AND LICENCE Put the correct copyright and licence information here. Copyright (C) 2009 by Xavier Guimard This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available. Apache-Session-LDAP-0.2/Makefile.PL0000644000175000017500000000121511172425611016222 0ustar xavierxavieruse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Apache::Session::LDAP', VERSION_FROM => 'lib/Apache/Session/LDAP.pm', # finds $VERSION PREREQ_PM => { 'Net::LDAP' => 0, 'Apache::Session' => 0, }, ( $] >= 5.005 ? ## Add these new keywords supported since 5.005 ( ABSTRACT_FROM => 'lib/Apache/Session/LDAP.pm', # retrieve abstract from module AUTHOR => 'Xavier Guimard ' ) : () ), );