Lemonldap::Config::Parameters - Backend of configuration for lemonldap SSO system
#!/usr/bin/perl use Lemonldap::Config::Parameters; use Data::Dumper; my $nconfig= Lemonldap::Config::Parameters->new( file =>'applications.xml', cache => '/tmp/CONF' ); my $conf= $nconfig->getAllConfig; my $cg=$nconfig->getDomain('appli.cp'); my $ligne= $cg; print Dumper( $ligne); my $e = $cg->{templates_options} ; my $opt= "templates_dir"; my $va = $cg->{$opt}; my $ligne= $nconfig->formateLineHash($e,$opt,$va) ;
or by API :
Lemonldap::Config::Parameters::f_delete('/tmp/CONF');
or by command line
perl -e "use Lemonldap::Config::Parameters; Lemonldap::Config::Parameters::f_delete('/tmp/CONF');"
perl Makefile.PL make make test make install
Lemonldap is a WEB SSO framework system under GPL.
Login page , handlers must retrieve their configs in an unique file eg :"applications.xml".
This file has a XML structrure. The parsing phase may be heavy, so lemonldap can cache the result of parsing in berkeleyDB file. For activing the cache you must have in the config :
<cache id="/tmp/CONF"> </cache>
with : name='/tmp/CONF' it will be the file name used for berkeley file.
The berkelay cache will be reloaded at every file modification You can force the reload off file by the command line bellow:
perl -e "use Lemonldap::Config::Parameters; Lemonldap::Config::Parameters::f_reload('/tmp/CONF');"
or
perl -e "use Lemonldap::Config::Parameters; Lemonldap::Config::Parameters::f_delete('CONF');"
IMPORTANT : the user's ID who runs those scripts MUST be the same of the berkeleyDB file's owner !!
WITHOUT CACHE SPECIFICATION , LEMONLDAP DOESN'T USE CACHE ! It will read and parse config file each time.
or new(file =>'/foo/my_xml_file.xml'); # without berkeleyDB cache
Return the reference of hash storing whole the config.
Return the reference of hash of config for domain If the config file has only one domain , domain may bo omit .
eg : for the xml config file : <domain name="foo.bar" cookie=".foo.bar" path ="/" templates_dir="/opt/apache/portail/templates" templates_options = "ABSOLUTE => '1', INCLUDE_PATH => 'templates_dir'" login ="http://cportail.foo.bar/portail/accueil.pl" menu= "http://cportail.foo.bar/portail/application.pl" ldap_server ="cpldap.foo.bar" ldap_port="389" DnManager= "cn=Directory Manager" passwordManager="secret" branch_people="ou=mefi,dc=foo,dc=bar" session="memcached" > </domain>
my $cg = $nconfig->getDomain(); DB<2> x $cg 0 HASH(0x89b108c) 'DnManager' => 'cn=Directory Manager' 'branch_people' => 'ou=mefi,dc=foo,dc=bar' 'cookie' => '.foo.bar' 'ldap_port' => 389 'ldap_server' => 'cpldap.foo.bar' 'login' => 'http://cportail.foo.bar/portail/accueil.pl' 'menu' => 'http://cportail.foo.bar/portail/application.pl' 'passwordManager' => 'secret' 'path' => '/' 'session' => 'memcached' 'templates_dir' => '/opt/apache/portail/templates' 'templates_options' => 'ABSOLUTE => \'1\', INCLUDE_PATH => \'templates_dir\'
or formateLineHash(string:line,string:motif,string:key);
Return a anonyme reference on hash and may replace the motif in the value of key by the value of another key :
eg
my $e = $cg->{templates_options} ; my $opt= "templates_dir"; my $va = $cg->{$opt}; my $ligne= $nconfig->formateLineHash($e,$opt,$va) ;
gives : D1 x $ligne 0 HASH(0x848b778) 'ABSOLUTE' => 1 'INCLUDE_PATH' => '/opt/apache/portail/templates'
$ligne can be use directly like option for somes instructions
Return a anonyme reference on array and may replace the motif in the element by the value of another key :
the return value can be use directly like option for somes instructions
Find and return a reference of chapter finds in xml file , a section can be specified.
Delete the cache and the restore segment
The next acces on cache will need to read file before .
Dump of the config
Don't use this ,I 'll rewrite all SOAP facility <location /conf_lemonldap> Options +execcgi SetHandler perl-script PerlHandler Apache::SOAP PerlSetVar dispatch_to 'SOAPserver' </location>
Important : You MUST place SOAPserver.pm under the apache's directory : eg : /usr/local/apache/
<cache id="config1" ConfigIpcKey="CONF" ConfigTtl ="10000000" LastModified='1' Method="SOAP" SoapUri="http://www.portable.appli.cp/SOAPserver" SoapProxy="http://www.portable.appli.cp/conf_lemonldap" SoapAgent="['http://localhost/cgi-bin/refresh.cgi','http://www.portable.appli.cp/perl/refresh.cgi']" >
with :SoapUri and SoapProxy : see SOAP::Lite documentation SoapAgent : the list of agents CGI on lemonldap server who must to be call in the case of modification
After that agent receive notification , they do a soap request upon the administration server for reload the lastnew config . If it's fail , slave lemonldap uses a local file XML which is the lastest copy of file config .
An agent lemonldap MAY to be in same server that the SOAP manager. So SOAP manager uses 'conf' instead 'CONF' for the IPC glue . It 'll be two IPC segments 'CONF' and 'conf' 'CONF' for agent 'conf' for SOAP server ,but don't worry it's an internal process , stay to use 'CONF' .
Lemonldap(3), Lemonldap::Portal::Standard
http://lemonldap.sourceforge.net/
"Writing Apache Modules with Perl and C" by Lincoln Stein & Doug MacEachern - O'REILLY
See the examples directory
Copyright (C) 2004 by Eric German
Lemonldap originaly written by Eric german who decided to publish him in 2003 under the terms of the GNU General Public License version 2.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 dated June, 1991. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GNU General Public License is available in the source tree; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
To install Lemonldap::Config::Parameters, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lemonldap::Config::Parameters
CPAN shell
perl -MCPAN -e shell install Lemonldap::Config::Parameters
For more information on module installation, please visit the detailed CPAN module installation guide.