Apache-Session-Browseable-1.1000755001751001751 012536600445 16510 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/Build.PL000444001751001751 100712536600445 20137 0ustar00clementclement000000000000use Module::Build; # See perldoc Module::Build for details of how this works Module::Build->new( module_name => 'Apache::Session::Browseable', license => 'perl', requires => { 'Apache::Session' => 0, }, recommends => { 'DBI' => 0, 'Net::LDAP' => 0.38, }, test_requires => { DBI => 0, 'DBD::SQLite' => 0, }, dist_version => '1.1', autosplit => [qw(lib/Apache/Session/Browseable/_common.pm)], configure_requires => { 'Module::Build' => 0, }, )->create_build_script; Apache-Session-Browseable-1.1/META.json000444001751001751 767212536600445 20302 0ustar00clementclement000000000000{ "abstract" : "Add index and search methods to Apache::Session", "author" : [ "Xavier Guimard, Ex.guimard@free.frE" ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.421", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Apache-Session-Browseable", "prereqs" : { "configure" : { "requires" : { "Module::Build" : "0" } }, "runtime" : { "recommends" : { "DBI" : "0", "Net::LDAP" : "0.38" }, "requires" : { "Apache::Session" : "0" } }, "test" : { "requires" : { "DBD::SQLite" : "0", "DBI" : "0" } } }, "provides" : { "Apache::Session::Browseable::DBI" : { "file" : "lib/Apache/Session/Browseable/DBI.pm", "version" : "1.0" }, "Apache::Session::Browseable::File" : { "file" : "lib/Apache/Session/Browseable/File.pm", "version" : "1.0" }, "Apache::Session::Browseable::Informix" : { "file" : "lib/Apache/Session/Browseable/Informix.pm", "version" : "0.8" }, "Apache::Session::Browseable::LDAP" : { "file" : "lib/Apache/Session/Browseable/LDAP.pm", "version" : "1.1" }, "Apache::Session::Browseable::MySQL" : { "file" : "lib/Apache/Session/Browseable/MySQL.pm", "version" : "0.9" }, "Apache::Session::Browseable::Oracle" : { "file" : "lib/Apache/Session/Browseable/Oracle.pm", "version" : "0.8" }, "Apache::Session::Browseable::Postgres" : { "file" : "lib/Apache/Session/Browseable/Postgres.pm", "version" : "0.8" }, "Apache::Session::Browseable::Redis" : { "file" : "lib/Apache/Session/Browseable/Redis.pm", "version" : "1.0" }, "Apache::Session::Browseable::SQLite" : { "file" : "lib/Apache/Session/Browseable/SQLite.pm", "version" : "1.0" }, "Apache::Session::Browseable::Store::DBI" : { "file" : "lib/Apache/Session/Browseable/Store/DBI.pm", "version" : "1" }, "Apache::Session::Browseable::Store::File" : { "file" : "lib/Apache/Session/Browseable/Store/File.pm", "version" : "0.1" }, "Apache::Session::Browseable::Store::Informix" : { "file" : "lib/Apache/Session/Browseable/Store/Informix.pm", "version" : "0.1" }, "Apache::Session::Browseable::Store::LDAP" : { "file" : "lib/Apache/Session/Browseable/Store/LDAP.pm", "version" : "1.1" }, "Apache::Session::Browseable::Store::MySQL" : { "file" : "lib/Apache/Session/Browseable/Store/MySQL.pm", "version" : "0.1" }, "Apache::Session::Browseable::Store::Oracle" : { "file" : "lib/Apache/Session/Browseable/Store/Oracle.pm", "version" : "0.1" }, "Apache::Session::Browseable::Store::Postgres" : { "file" : "lib/Apache/Session/Browseable/Store/Postgres.pm", "version" : "0.1" }, "Apache::Session::Browseable::Store::Redis" : { "file" : "lib/Apache/Session/Browseable/Store/Redis.pm", "version" : "1.0" }, "Apache::Session::Browseable::Store::SQLite" : { "file" : "lib/Apache/Session/Browseable/Store/SQLite.pm", "version" : "1.0" }, "Apache::Session::Browseable::Store::Sybase" : { "file" : "lib/Apache/Session/Browseable/Store/Sybase.pm", "version" : "0.1" }, "Apache::Session::Browseable::Sybase" : { "file" : "lib/Apache/Session/Browseable/Sybase.pm", "version" : "0.8" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "1.1" } Apache-Session-Browseable-1.1/Changes000444001751001751 272712536600445 20150 0ustar00clementclement000000000000Revision history for Perl extension Apache::Session::Browseable. 0.1 Sat Oct 31 08:10:54 2009 - Initial release 0.2 Sun Nov 1 10:06:51 2009 - Remove 5.10 dependency 0.3 Sun Nov 1 17:12:34 2009 - Add Sybase, Oracle, Informix, File and Postgres 0.4 Mon Aug 16 17:16:12 2010 - Missing "use" 0.5 Mon Dec 6 21:54:23 2010 - Add Redis (Closes LEMONLDAP-244) 0.6 Mon Dec 8 16:43:23 2010 - Add LDAP (Closes LEMONLDAP-243) - Redis parsing returned nothing 0.7 Sun Jun 24 09:07:21 2012 - Add "eval" to avoid errors in unserialize (LDAP) 0.8 Fri Oct 12 06:20:54 2012 - storable must not be always used in DBI 0.9 Thu Feb 28 06:51:51 2013 - Fix Undefined value warning with Redis backend (https://github.com/coudot/apache-session-browseable/issues/1) - Update copyright 1.0 Sat Jul 06 19:57:46 2013 - Add SQLite support - Corrects POD ($args was forgotten) - Add searchOnExpr() sub: - default implementation in _common - optimized implementation in LDAP and DBI - Optimize SQL queries when only indexed files are required - Create _common.pm lib for unoptimized functions - Add basic tests for all libs - Add advanced tests using SQLite backend 1.0.1 Fri Aug 30 06:40:02 2013 - Add Apache::Session in required dependencies (was ommited in 1.0) 1.0.2 Thu Oct 17 20:27:24 2013 - _common::_tabInTab() must return 0 if no fields are required Closes http://jira.ow2.org/browse/LEMONLDAP-627 Apache-Session-Browseable-1.1/LICENSE000444001751001751 5010112536600445 17667 0ustar00clementclement000000000000Terms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --------------------------------------------------------------------------- The General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS --------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Apache-Session-Browseable-1.1/META.yml000444001751001751 546512536600445 20130 0ustar00clementclement000000000000--- abstract: 'Add index and search methods to Apache::Session' author: - 'Xavier Guimard, Ex.guimard@free.frE' build_requires: DBD::SQLite: '0' DBI: '0' configure_requires: Module::Build: '0' dynamic_config: 1 generated_by: 'Module::Build version 0.421, CPAN::Meta::Converter version 2.142060' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Apache-Session-Browseable provides: Apache::Session::Browseable::DBI: file: lib/Apache/Session/Browseable/DBI.pm version: '1.0' Apache::Session::Browseable::File: file: lib/Apache/Session/Browseable/File.pm version: '1.0' Apache::Session::Browseable::Informix: file: lib/Apache/Session/Browseable/Informix.pm version: '0.8' Apache::Session::Browseable::LDAP: file: lib/Apache/Session/Browseable/LDAP.pm version: '1.1' Apache::Session::Browseable::MySQL: file: lib/Apache/Session/Browseable/MySQL.pm version: '0.9' Apache::Session::Browseable::Oracle: file: lib/Apache/Session/Browseable/Oracle.pm version: '0.8' Apache::Session::Browseable::Postgres: file: lib/Apache/Session/Browseable/Postgres.pm version: '0.8' Apache::Session::Browseable::Redis: file: lib/Apache/Session/Browseable/Redis.pm version: '1.0' Apache::Session::Browseable::SQLite: file: lib/Apache/Session/Browseable/SQLite.pm version: '1.0' Apache::Session::Browseable::Store::DBI: file: lib/Apache/Session/Browseable/Store/DBI.pm version: '1' Apache::Session::Browseable::Store::File: file: lib/Apache/Session/Browseable/Store/File.pm version: '0.1' Apache::Session::Browseable::Store::Informix: file: lib/Apache/Session/Browseable/Store/Informix.pm version: '0.1' Apache::Session::Browseable::Store::LDAP: file: lib/Apache/Session/Browseable/Store/LDAP.pm version: '1.1' Apache::Session::Browseable::Store::MySQL: file: lib/Apache/Session/Browseable/Store/MySQL.pm version: '0.1' Apache::Session::Browseable::Store::Oracle: file: lib/Apache/Session/Browseable/Store/Oracle.pm version: '0.1' Apache::Session::Browseable::Store::Postgres: file: lib/Apache/Session/Browseable/Store/Postgres.pm version: '0.1' Apache::Session::Browseable::Store::Redis: file: lib/Apache/Session/Browseable/Store/Redis.pm version: '1.0' Apache::Session::Browseable::Store::SQLite: file: lib/Apache/Session/Browseable/Store/SQLite.pm version: '1.0' Apache::Session::Browseable::Store::Sybase: file: lib/Apache/Session/Browseable/Store/Sybase.pm version: '0.1' Apache::Session::Browseable::Sybase: file: lib/Apache/Session/Browseable/Sybase.pm version: '0.8' recommends: DBI: '0' Net::LDAP: '0.38' requires: Apache::Session: '0' resources: license: http://dev.perl.org/licenses/ version: '1.1' Apache-Session-Browseable-1.1/README000444001751001751 114712536600445 17530 0ustar00clementclement000000000000Apache-Session-Browseable version 1.1 ====================================== This module is an Apache::Session implementation allowing to define index to speed up searches. INSTALLATION To install this module type the following: perl Build.PL ./Build ./Build test ./Build install COPYRIGHT AND LICENCE Copyright (C) 2009-2013 by Xavier Guimard, 2013-2015 by Clement Oudot 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.1 or, at your option, any later version of Perl 5 you may have available. Apache-Session-Browseable-1.1/MANIFEST000444001751001751 252412536600445 20001 0ustar00clementclement000000000000Build.PL Changes lib/Apache/Session/Browseable.pod lib/Apache/Session/Browseable/_common.pm lib/Apache/Session/Browseable/DBI.pm lib/Apache/Session/Browseable/File.pm lib/Apache/Session/Browseable/Informix.pm lib/Apache/Session/Browseable/LDAP.pm lib/Apache/Session/Browseable/MySQL.pm lib/Apache/Session/Browseable/Oracle.pm lib/Apache/Session/Browseable/Postgres.pm lib/Apache/Session/Browseable/Redis.pm lib/Apache/Session/Browseable/SQLite.pm lib/Apache/Session/Browseable/Store/DBI.pm lib/Apache/Session/Browseable/Store/File.pm lib/Apache/Session/Browseable/Store/Informix.pm lib/Apache/Session/Browseable/Store/LDAP.pm lib/Apache/Session/Browseable/Store/MySQL.pm lib/Apache/Session/Browseable/Store/Oracle.pm lib/Apache/Session/Browseable/Store/Postgres.pm lib/Apache/Session/Browseable/Store/Redis.pm lib/Apache/Session/Browseable/Store/SQLite.pm lib/Apache/Session/Browseable/Store/Sybase.pm lib/Apache/Session/Browseable/Sybase.pm LICENSE MANIFEST META.json META.yml Module meta-data (added by MakeMaker) README t/Apache-Session-Browseable-common.t t/Apache-Session-Browseable-DBI.t t/Apache-Session-Browseable-File.t t/Apache-Session-Browseable-LDAP.t t/Apache-Session-Browseable-Redis.t t/Apache-Session-Browseable-SQLite.t t/Apache-Session-Browseable-Store-DBI.t t/Apache-Session-Browseable-Store-MySQL.t t/test-browseable-functions-using-SQLite.t Apache-Session-Browseable-1.1/t000755001751001751 012536600445 16753 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-File.t000444001751001751 14712536600445 25021 0ustar00clementclement000000000000use Test::More; plan tests => 1; $package = 'Apache::Session::Browseable::File'; use_ok($package); Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-LDAP.t000444001751001751 33312536600445 24657 0ustar00clementclement000000000000use Test::More; plan skip_all => "Optional modules (Net::LDAP) not installed" unless eval { require Net::LDAP; }; plan tests => 1; $package = 'Apache::Session::Browseable::Store::LDAP'; use_ok($package); Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-DBI.t000444001751001751 26012536600445 24534 0ustar00clementclement000000000000use Test::More; plan skip_all => "Optional modules (DBI) not installed" unless eval { require DBI; }; plan tests => 1; use_ok('Apache::Session::Browseable::DBI'); Apache-Session-Browseable-1.1/t/test-browseable-functions-using-SQLite.t000444001751001751 776312536600445 26704 0ustar00clementclement000000000000# Complete tests with SQLite use strict; use warnings; use Test::More; use File::Temp qw(mktemp); my $dbfile = mktemp('tmp.db_XXXX'); plan skip_all => "DBD::SQLite is needed for this test" unless eval { require DBI; require DBD::SQLite; 1; }; plan skip_all => "DBD::SQLite error : $@" unless eval { my $dbh; $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "" ) or die $dbh->errstr; $dbh->do( 'CREATE TABLE sessions(id char(32) not null primary key,a_session text,f1 text,f2 text);' ) or die $dbh->errstr; $dbh->do('CREATE INDEX f1_idx ON sessions (f1);') or die $dbh->errstr; $dbh->do('CREATE INDEX f2_idx ON sessions (f2);') or die $dbh->errstr; $dbh->disconnect() or die $dbh->errstr; }; my @list = ( "aa" .. "ay", "aa" .. "ac" ); my $count = @list; plan tests => 27 + 5 * $count; use_ok('Apache::Session::Browseable::SQLite'); my %session; my $args = { DataSource => "dbi:SQLite:$dbfile", Index => "f1 f2", }; foreach (@list) { ok( tie %session, 'Apache::Session::Browseable::SQLite', undef, $args, "Create session $_" ); $session{f1} = "1_$_"; $session{f2} = "2_$_"; $session{f3} = "3_$_"; $session{f4} = "4_$_"; untie %session; } my $res; # 1. Get simply all sessions ok( $res = Apache::Session::Browseable::SQLite->get_key_from_all_sessions($args), 'Get all sessions' ); ok( count($res) == $count, "get_key_from_all_sessions returns $count sessions (" . count($res) . ")" ); # 2. Test searchOn() on an indexed field ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_ad' ) ); ok( count($res) == 1, 'Get 1 "ad" sessions (' . count($res) . ")" ); # 3. Test searchOn() on an unindexed field ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f3', '3_aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f3', '3_ad' ) ); ok( count($res) == 1, 'Get 1 "ad" sessions (' . count($res) . ")" ); # 4. Test searchOnExpr() on an indexed field ok( $res = Apache::Session::Browseable::SQLite->searchOnExpr( $args, 'f1', '*aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); # 5. Test searchOnExpr() on an unindexed field ok( $res = Apache::Session::Browseable::SQLite->searchOnExpr( $args, 'f3', '*aa' ) ); ok( count($res) == 2, 'Get 2 "aa" sessions (' . count($res) . ")" ); # 6. Test get_key_from_all_sessions to request for indexed fields ok( $res = Apache::Session::Browseable::SQLite->get_key_from_all_sessions( $args, [ 'f1', 'f2' ] ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f2} =~ /^2_${t}$/ ); } # 7. Test searchOn to request for indexed fields ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_aa', 'f1', 'f2' ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f2} =~ /^2_${t}$/ ); } # 8. Test get_key_from_all_sessions to request for unindexed fields ok( $res = Apache::Session::Browseable::SQLite->get_key_from_all_sessions( $args, [ 'f1', 'f3' ] ) ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f3} =~ /^3_${t}$/ ); } # 9. Test searchOn to request for unindexed fields ok( $res = Apache::Session::Browseable::SQLite->searchOn( $args, 'f1', '1_aa', 'f1', 'f3' ) ); unlink $dbfile if ( -e $dbfile ); while ( my ( $id, $entry ) = each %$res ) { ok( $entry->{f1} =~ /^1_(\w{2})$/ ); my $t = $1; ok( $entry->{f3} =~ /^3_${t}$/ ); } sub count { my @c = keys %{ $_[0] }; return scalar @c; } 1; Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-Redis.t000444001751001751 31512536600445 25205 0ustar00clementclement000000000000use Test::More; plan skip_all => "Optional modules (Redis) not installed" unless eval { require Redis; }; plan tests => 1; $package = 'Apache::Session::Browseable::Redis'; use_ok($package); Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-common.t000444001751001751 41212536600445 25425 0ustar00clementclement000000000000use Test::More; plan tests => 3; use_ok('Apache::Session::Browseable::_common'); my ( $a, $b ) = ( [qw(0 1 a)], [qw(0 1 a b)] ); ok( Apache::Session::Browseable::_common->_tabInTab( $a, $b ) ); ok( !Apache::Session::Browseable::_common->_tabInTab( $b, $a ) ); Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-SQLite.t000444001751001751 206512536600445 25324 0ustar00clementclement000000000000# First test with SQLite: Basic Apache::Session usage #!/usr/bin/perl use strict; use Test::More; use File::Temp qw(mktemp); my $dbfile = mktemp('tmp.db_XXXX'); plan skip_all => "DBD::SQLite is needed for this test" unless eval { require DBI; require DBD::SQLite; 1; }; plan skip_all => "DBD::SQLite error : $@" unless eval { my $dbh; $dbh = DBI->connect( "dbi:SQLite:dbname=$dbfile", "", "" ) or die $dbh->errstr; $dbh->do( 'CREATE TABLE sessions(id char(32) not null primary key,a_session text);' ) or die $dbh->errstr; $dbh->disconnect() or die $dbh->errstr; }; plan tests => 5; use_ok('Apache::Session::Browseable::SQLite'); my %session; ok( tie %session, 'Apache::Session::Browseable::SQLite', undef, { DataSource => "dbi:SQLite:$dbfile", Index => '' } ); ok( $session{a} = 'foo' ); my $id = $session{_session_id}; untie %session; ok( tie %session, 'Apache::Session::Browseable::SQLite', $id, { DataSource => "dbi:SQLite:$dbfile" } ); ok( $session{a} eq 'foo' ); unlink $dbfile if ( -e $dbfile ); Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-Store-MySQL.t000444001751001751 45012536600445 26176 0ustar00clementclement000000000000use Test::More; plan skip_all => "Optional modules (DBD::mysql, DBI) not installed" unless eval { require DBI; require DBD::mysql; }; plan tests => 2; $package = 'Apache::Session::Browseable::Store::MySQL'; use_ok($package); my $foo = $package->new; isa_ok $foo, $package; Apache-Session-Browseable-1.1/t/Apache-Session-Browseable-Store-DBI.t000444001751001751 26712536600445 25635 0ustar00clementclement000000000000use Test::More; plan skip_all => "Optional modules (DBI) not installed" unless eval { require DBI; }; plan tests => 1; use_ok('Apache::Session::Browseable::Store::DBI'); Apache-Session-Browseable-1.1/lib000755001751001751 012536600445 17256 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/lib/Apache000755001751001751 012536600445 20437 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/lib/Apache/Session000755001751001751 012536600445 22062 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable.pod000444001751001751 541012536600445 25010 0ustar00clementclement000000000000=head1 NAME Apache::Session::Browseable - Add index and search methods to Apache::Session =head1 SYNOPSIS use Apache::Session::Browseable::MySQL; my $args = { DataSource => 'dbi:mysql:sessions', UserName => $db_user, Password => $db_pass, LockDataSource => 'dbi:mysql:sessions', LockUserName => $db_user, LockPassword => $db_pass, # Choose your browseable fileds Index => 'uid mail', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::MySQL', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; # Apache::Session::Browseable add some global class methods # # 1) search on a field (indexed or not) # a. get full sessions my $hash = Apache::Session::Browseable::MySQL->searchOn( $args, 'uid', 'me' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; } # b. get only some fields my $hash = Apache::Session::Browseable::MySQL->searchOn( $args, 'uid', 'me', 'mail', 'uid' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; print " " . $hash->{$id}->{uid} . "\n"; } # c. search with a pattern my $hash = Apache::Session::Browseable::MySQL->searchOnExpr( $args, 'uid', 'm*' ); ... # 2) Parse all sessions # a. get all sessions my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions($args); # b. get some fields from all sessions my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions($args, ['uid','mail']) # c. execute something with datas from each session : # Example : get uid and mail if mail domain is my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions( $args, sub { my ( $session, $id ) = @_; if ( $session->{mail} =~ /mydomain.com$/ ) { return { $session->{uid}, $session->{mail} }; } } ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n"; } =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. =head1 SEE ALSO L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2013 by Xavier Guimard 2013 by Clément Oudot 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.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable000755001751001751 012536600445 24147 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/DBI.pm000444001751001751 1100412536600445 25254 0ustar00clementclement000000000000package Apache::Session::Browseable::DBI; use strict; use DBI; use Apache::Session; use Apache::Session::Browseable::_common; our $VERSION = '1.0'; our @ISA = qw(Apache::Session Apache::Session::Browseable::_common); sub searchOn { my $class = shift; my ( $args, $selectField, $value, @fields ) = @_; # Escape quotes $value =~ s/'/''/g; $selectField =~ s/'/''/g; if ( $class->_fieldIsIndexed( $args, $selectField ) ) { return $class->_query( $args, $selectField, $value, { query => "$selectField=?", values => [$value] }, @fields ); } else { return $class->SUPER::searchOn(@_); } } sub searchOnExpr { my $class = shift; my ( $args, $selectField, $value, @fields ) = @_; # Escape quotes $value =~ s/'/''/g; $selectField =~ s/'/''/g; if ( $class->_fieldIsIndexed( $args, $selectField ) ) { $value =~ s/\*/%/g; return $class->_query( $args, $selectField, $value, { query => "$selectField like ?", values => [$value] }, @fields ); } else { return $class->SUPER::searchOnExpr(@_); } } sub _query { my ( $class, $args, $selectField, $value, $query, @fields ) = @_; my %res = (); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; my $dbh = $class->_classDbh($args); my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; # Case 1: all requested fields are also indexed my $indexed = $class->_tabInTab( \@fields, $index ); my $sth; if ($indexed) { my $fields = join( ',', 'id', map { s/'//g; $_ } @fields ); $sth = $dbh->prepare( "SELECT $fields from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); return $sth->fetchall_hashref('id'); } # Case 1: at least one field isn't indexed, decoding is needed else { $sth = $dbh->prepare( "SELECT id,a_session from $table_name where $query->{query}"); $sth->execute( @{ $query->{values} } ); while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; my $sub = $self->{unserialize}; my $tmp = &$sub( { serialized => $row[1] } ); if (@fields) { $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@fields); } else { $res{ $row[0] } = $tmp; } } } return \%res; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; my $table_name = $args->{TableName} || $Apache::Session::Store::DBI::TableName; my $dbh = $class->_classDbh($args); # Special case if all wanted fields are indexed if ( $data and ref($data) ne 'CODE' ) { $data = [$data] unless ( ref($data) ); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; # Test if one field isn't indexed my $indexed = $class->_tabInTab( $data, $index ); # OK, all fields are indexed if ($indexed) { my $sth = $dbh->prepare_cached( 'SELECT id,' . join( ',', map { s/'/''/g; $_ } @$data ) . " from $table_name" ); $sth->execute; return $sth->fetchall_hashref('id'); } } my $sth = $dbh->prepare_cached("SELECT id,a_session from $table_name"); $sth->execute; my %res; while ( my @row = $sth->fetchrow_array ) { no strict 'refs'; my $self = eval "&${class}::populate();"; my $sub = $self->{unserialize}; my $tmp = &$sub( { serialized => $row[1] } ); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $row[0] ); $res{ $row[0] } = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{ $row[0] }->{$_} = $tmp->{$_} foreach (@$data); } else { $res{ $row[0] } = $tmp; } } return \%res; } sub _classDbh { my $class = shift; my $args = shift; my $datasource = $args->{DataSource} or die "No datasource given !"; my $username = $args->{UserName}; my $password = $args->{Password}; my $dbh = DBI->connect_cached( $datasource, $username, $password, { RaiseError => 1, AutoCommit => 1 } ) || die $DBI::errstr; } 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Oracle.pm000444001751001751 156712536600445 26060 0ustar00clementclement000000000000package Apache::Session::Browseable::Oracle; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Oracle; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; use Apache::Session::Browseable::DBI; our $VERSION = '0.8'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Oracle $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; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Redis.pm000444001751001751 1301212536600445 25725 0ustar00clementclement000000000000package Apache::Session::Browseable::Redis; use strict; use Apache::Session; use Apache::Session::Browseable::Store::Redis; use Apache::Session::Generate::MD5; use Apache::Session::Lock::Null; use Apache::Session::Serialize::Base64; use Apache::Session::Browseable::_common; our $VERSION = '1.0'; our @ISA = qw(Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Redis $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; } sub unserialize { my $session = shift; my $tmp = { serialized => $session }; Apache::Session::Serialize::Base64::unserialize($tmp); return $tmp->{data}; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; # Manage undef encoding $args->{encoding} = undef if ( $args->{encoding} and $args->{encoding} eq "undef" ); my %res = (); my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( grep { $_ eq $selectField } @$index ) { my $redisObj = Redis->new(%$args); # Manage database $redisObj->select( $args->{database} ) if defined $args->{database}; my @keys = $redisObj->smembers("${selectField}_$value"); foreach my $k (@keys) { next unless ($k); my $tmp = $redisObj->get($k); next unless ($tmp); $tmp = unserialize($tmp); if (@fields) { $res{$k}->{$_} = $tmp->{$_} foreach (@fields); } else { $res{$k} = $tmp; } } } else { $class->get_key_from_all_sessions( $args, sub { my $entry = shift; my $id = shift; return undef unless ( defined $entry->{$selectField} and $entry->{$selectField} eq $value ); if (@fields) { $res{$id}->{$_} = $entry->{$_} foreach (@fields); } else { $res{$id} = $entry; } undef; } ); } return \%res; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; my %res; # Manage undef encoding $args->{encoding} = undef if ( $args->{encoding} and $args->{encoding} eq "undef" ); # TODO new Redis object my $redisObj = Redis->new(%$args); # Manage database $redisObj->select( $args->{database} ) if defined $args->{database}; my @keys = $redisObj->keys('*'); foreach my $k (@keys) { next if ( !$k or $k =~ /_/ ); my $v = $redisObj->get($k); my $tmp = unserialize($v); if ( ref($data) eq 'CODE' ) { $tmp = &$data( $tmp, $k ); $res{$k} = $tmp if ( defined($tmp) ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{$k}->{$_} = $tmp->{$_} foreach (@$data); } else { $res{$k} = $tmp; } } return \%res; } 1; __END__ =head1 NAME Apache::Session::Browseable::Redis - Add index and search methods to Apache::Session::Redis =head1 SYNOPSIS use Apache::Session::Browseable::Redis; my $args = { server => '127.0.0.1:6379', # Choose your browseable fileds Index => 'uid mail', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::Redis', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; # Apache::Session::Browseable add some global class methods # # 1) search on a field (indexed or not) my $hash = Apache::Session::Browseable::Redis->searchOn( $args, 'uid', 'me' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; } # 2) Parse all sessions # a. get all sessions my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions(); # b. get some fields from all sessions my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions('uid', 'mail') # c. execute something with datas from each session : # Example : get uid and mail if mail domain is my $hash = Apache::Session::Browseable::Redis->get_key_from_all_sessions( sub { my ( $session, $id ) = @_; if ( $session->{mail} =~ /mydomain.com$/ ) { return { $session->{uid}, $session->{mail} }; } } ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n"; } =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. =head1 SEE ALSO L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE 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.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Postgres.pm000444001751001751 157512536600445 26460 0ustar00clementclement000000000000package Apache::Session::Browseable::Postgres; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Postgres; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; use Apache::Session::Browseable::DBI; our $VERSION = '0.8'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Postgres $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; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Sybase.pm000444001751001751 177212536600445 26077 0ustar00clementclement000000000000package Apache::Session::Browseable::Sybase; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Sybase; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Sybase; use Apache::Session::Browseable::DBI; our $VERSION = '0.8'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); *serialize = \&Apache::Session::Serialize::Sybase::serialize; *unserialize = \&Apache::Session::Serialize::Sybase::unserialize; sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Sybase $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::Sybase::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Sybase::unserialize; return $self; } 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/_common.pm000444001751001751 332512536600445 26274 0ustar00clementclement000000000000package Apache::Session::Browseable::_common; use strict; use AutoLoader 'AUTOLOAD'; our $VERSION = '1.0'; sub _tabInTab { my ( $class, $t1, $t2 ) = @_; # if no fields are required, return 0 return 0 unless(@$t1 and @$t2); foreach my $f (@$t1) { unless ( grep { $_ eq $f } @$t2 ) { return 0; } } return 1; } sub _fieldIsIndexed { my ( $class, $args, $field ) = @_; my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; return ( grep { $_ eq $field } @$index ); } 1; __END__ sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = splice @_; my %res = (); $class->get_key_from_all_sessions( $args, sub { my $entry = shift; my $id = shift; return undef unless ( $entry->{$selectField} eq $value ); if (@fields) { $res{$id}->{$_} = $entry->{$_} foreach (@fields); } else { $res{$id} = $entry; } undef; } ); return \%res; } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = splice @_; $value = quotemeta($value); $value =~ s/\\\*/\.\*/g; $value = qr/^$value$/; my %res = (); $class->get_key_from_all_sessions( $args, sub { my $entry = shift; my $id = shift; return undef unless ( $entry->{$selectField} =~ $value ); if (@fields) { $res{$id}->{$_} = $entry->{$_} foreach (@fields); } else { $res{$id} = $entry; } undef; } ); return \%res; } 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Informix.pm000444001751001751 157512536600445 26445 0ustar00clementclement000000000000package Apache::Session::Browseable::Informix; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::Informix; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; use Apache::Session::Browseable::DBI; our $VERSION = '0.8'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::Informix $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; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/LDAP.pm000444001751001751 1421112536600445 25401 0ustar00clementclement000000000000package Apache::Session::Browseable::LDAP; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::LDAP; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; use Apache::Session::Browseable::_common; use Net::LDAP::Util qw(escape_filter_value); our $VERSION = '1.1'; our @ISA = qw(Apache::Session Apache::Session::Browseable::_common); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::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; } sub unserialize { my $session = shift; my $tmp = { serialized => $session }; Apache::Session::Serialize::Base64::unserialize($tmp); return $tmp->{data}; } sub searchOn { my ( $class, $args, $selectField, $value, @fields ) = @_; my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( grep { $_ eq $selectField } @$index ) { ( $selectField, $value ) = escape_filter_value( $selectField, $value ); return $class->_query( $args, $selectField, $value, @fields ); } else { return $class->SUPER::searchOn( $args, $selectField, $value, @fields ); } } sub searchOnExpr { my ( $class, $args, $selectField, $value, @fields ) = @_; my $index = ref( $args->{Index} ) ? $args->{Index} : [ split /\s+/, $args->{Index} ]; if ( grep { $_ eq $selectField } @$index ) { ( $selectField, $value ) = escape_filter_value( $selectField, $value ); $value =~ s/\\2a/\*/gi; return $class->_query( $args, $selectField, $value, @fields ); } else { return $class->SUPER::searchOn( $args, $selectField, $value, @fields ); } } sub _query { my ( $class, $args, $selectField, $value, @fields ) = @_; $args->{ldapObjectClass} ||= 'applicationProcess'; $args->{ldapAttributeId} ||= 'cn'; $args->{ldapAttributeContent} ||= 'description'; $args->{ldapAttributeIndex} ||= 'ou'; my %res = (); my $ldap = Apache::Session::Browseable::Store::LDAP::ldap( { args => $args } ); my $msg = $ldap->search( base => $args->{ldapConfBase}, filter => "(&(objectClass=" . $args->{ldapObjectClass} . ")(" . $args->{ldapAttributeIndex} . "=${selectField}_$value))", #scope => 'base', attrs => [ $args->{ldapAttributeContent}, $args->{ldapAttributeId} ], ); $ldap->unbind(); if ( $msg->code ) { Apache::Session::Browseable::Store::LDAP->logError($msg); } else { foreach my $entry ( $msg->entries ) { my $id = $entry->get_value( $args->{ldapAttributeId} ) or die; my $tmp = $entry->get_value( $args->{ldapAttributeContent} ); next unless ($tmp); eval { $tmp = unserialize($tmp); }; next if ($@); if (@fields) { $res{$id}->{$_} = $tmp->{$_} foreach (@fields); } else { $res{$id} = $tmp; } } } return \%res; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; $args->{ldapObjectClass} ||= 'applicationProcess'; $args->{ldapAttributeId} ||= 'cn'; $args->{ldapAttributeContent} ||= 'description'; $args->{ldapAttributeIndex} ||= 'ou'; my %res; my $ldap = Apache::Session::Browseable::Store::LDAP::ldap( { args => $args } ); my $msg = $ldap->search( base => $args->{ldapConfBase}, # VERY STRANGE BUG ! With this filter, description isn't base64 encoded !!! #filter => '(objectClass=applicationProcess)', filter => '(&(objectClass=' . $args->{ldapObjectClass} . ')(' . $args->{ldapAttributeIndex} . '=*))', attrs => [ $args->{ldapAttributeId}, $args->{ldapAttributeContent} ], ); $ldap->unbind(); if ( $msg->code ) { Apache::Session::Browseable::Store::LDAP->logError($msg); } else { foreach my $entry ( $msg->entries ) { my $id = $entry->get_value( $args->{ldapAttributeId} ) or die; my $tmp = $entry->get_value( $args->{ldapAttributeContent} ); next unless ($tmp); eval { $tmp = unserialize($tmp); }; next if ($@); if ( ref($data) eq 'CODE' ) { $res{$id} = &$data( $tmp, $id ); } elsif ($data) { $data = [$data] unless ( ref($data) ); $res{$id}->{$_} = $tmp->{$_} foreach (@$data); } else { $res{$id} = $tmp; } } } return \%res; } 1; =pod =head1 NAME Apache::Session::Browseable::LDAP - An implementation of Apache::Session::LDAP =head1 SYNOPSIS use Apache::Session::Browseable::LDAP; tie %hash, 'Apache::Session::Browseable::LDAP', $id, { ldapServer => 'ldap://localhost:389', ldapConfBase => 'dmdName=applications,dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', Index => 'uid ipAddr', ldapObjectClass => 'applicationProcess', ldapAttributeId => 'cn', ldapAttributeContent => 'description', ldapAttributeIndex => 'ou', }; =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 =encoding utf8 Copyright (C) 2009 by Xavier Guimard Copyright (C) 2013, 2015 by Clement Oudot 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-Browseable-1.1/lib/Apache/Session/Browseable/MySQL.pm000444001751001751 633212536600445 25613 0ustar00clementclement000000000000package Apache::Session::Browseable::MySQL; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::MySQL; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Storable; use Apache::Session::Browseable::DBI; our $VERSION = '0.9'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::MySQL $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::Storable::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Storable::unserialize; return $self; } 1; __END__ =head1 NAME Apache::Session::Browseable::MySQL - Add index and search methods to Apache::Session::MySQL =head1 SYNOPSIS use Apache::Session::Browseable::MySQL; my $args = { DataSource => 'dbi:mysql:sessions', UserName => $db_user, Password => $db_pass, LockDataSource => 'dbi:mysql:sessions', LockUserName => $db_user, LockPassword => $db_pass, # Choose your browseable fileds Index => 'uid mail', }; # Use it like Apache::Session my %session; tie %session, 'Apache::Session::Browseable::MySQL', $id, $args; $session{uid} = 'me'; $session{mail} = 'me@me.com'; $session{unindexedField} = 'zz'; untie %session; # Apache::Session::Browseable add some global class methods # # 1) search on a field (indexed or not) my $hash = Apache::Session::Browseable::MySQL->searchOn( $args, 'uid', 'me' ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{mail} . "\n"; } # 2) Parse all sessions # a. get all sessions my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions(); # b. get some fields from all sessions my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions('uid', 'mail') # c. execute something with datas from each session : # Example : get uid and mail if mail domain is my $hash = Apache::Session::Browseable::MySQL->get_key_from_all_sessions( sub { my ( $session, $id ) = @_; if ( $session->{mail} =~ /mydomain.com$/ ) { return { $session->{uid}, $session->{mail} }; } } ); foreach my $id (keys %$hash) { print $id . ":" . $hash->{$id}->{uid} . "=>" . $hash->{$id}->{mail} . "\n"; } =head1 DESCRIPTION Apache::Session::browseable provides some class methods to manipulate all sessions and add the capability to index some fields to make research faster. =head1 SEE ALSO L =head1 AUTHOR Xavier Guimard, Ex.guimard@free.frE =head1 COPYRIGHT AND LICENSE =encoding utf8 Copyright (C) 2009-2013 by Xavier Guimard 2013 by Clément Oudot 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.1 or, at your option, any later version of Perl 5 you may have available. =cut Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/File.pm000444001751001751 355712536600445 25533 0ustar00clementclement000000000000package Apache::Session::Browseable::File; use strict; use Apache::Session; use Apache::Session::Lock::File; use Apache::Session::Browseable::Store::File; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Storable; use Apache::Session::Browseable::_common; use Storable qw(thaw); our $VERSION = '1.0'; our @ISA = qw(Apache::Session Apache::Session::Browseable::_common); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::File $self; $self->{lock_manager} = new Apache::Session::Lock::File $self; $self->{generate} = \&Apache::Session::Generate::MD5::generate; $self->{validate} = \&Apache::Session::Generate::MD5::validate; $self->{serialize} = \&Apache::Session::Serialize::Storable::serialize; $self->{unserialize} = \&Apache::Session::Serialize::Storable::unserialize; return $self; } sub DESTROY { my $self = shift; $self->save; $self->{object_store}->close; $self->release_all_locks; } sub get_key_from_all_sessions { my $class = shift; my $args = shift; my $data = shift; $args->{Directory} ||= $Apache::Session::Store::File::Directory; unless ( opendir DIR, $args->{Directory} ) { die "Cannot open directory $args->{Directory}\n"; } my @t = grep { -f "$args->{Directory}/$_" and /^[A-Za-z0-9@\-]+$/ } readdir(DIR); closedir DIR; my %res; for my $f (@t) { open F, "$args->{Directory}/$f"; my $row = join '', ; if ( ref($data) eq 'CODE' ) { $res{$f} = &$data( thaw($row), $f ); } elsif ($data) { $data = [$data] unless ( ref($data) ); my $tmp = thaw($row); $res{$f}->{$_} = $tmp->{$_} foreach (@$data); } else { $res{$f} = thaw($row); } } return \%res; } 1; __END__ Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/SQLite.pm000444001751001751 555112536600445 26011 0ustar00clementclement000000000000############################################################################# # # Apache::Session::Browseable::SQLite # Apache persistent user sessions in a SQLite database # Copyright(c) 2013 Xavier Guimard # Inspired by Apache::Session::Postgres # (copyright(c) 1998, 1999, 2000 Jeffrey William Baker (jwbaker@acm.org)) # Distribute under the Perl License # ############################################################################ package Apache::Session::Browseable::SQLite; use strict; use Apache::Session; use Apache::Session::Lock::Null; use Apache::Session::Browseable::Store::SQLite; use Apache::Session::Generate::MD5; use Apache::Session::Serialize::Base64; use Apache::Session::Browseable::DBI; our $VERSION = '1.0'; our @ISA = qw(Apache::Session::Browseable::DBI Apache::Session); sub populate { my $self = shift; $self->{object_store} = new Apache::Session::Browseable::Store::SQLite $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::Browseable::SQLite - An implementation of Apache::Session =head1 SYNOPSIS use Apache::Session::Browseable::SQLite; #if you want Apache::Session to open new DB handles: tie %hash, 'Apache::Session::Browseable::SQLite', $id, { DataSource => 'dbi:Pg:dbname=sessions', UserName => $db_user, Password => $db_pass, Commit => 1 }; #or, if your handles are already opened: tie %hash, 'Apache::Session::Browseable::SQLite', $id, { Handle => $dbh, Commit => 1 }; L function are also available =head1 DESCRIPTION This module is an implementation of Apache::Session. It uses the SQLite backing store and no locking. See the example, and the documentation for Apache::Session::Browseable::Store::SQLite for more details. =head1 USAGE The special Apache::Session argument for this module is Commit. You MUST provide the Commit argument, which instructs this module to either commit the transaction when it is finished, or to simply do nothing. This feature is provided so that this module will not have adverse interactions with your local transaction policy, nor your local database handle caching policy. The argument is mandatory in order to make you think about this problem. =head1 AUTHOR This module was written by Xavier Guimard using Apache::Session::Postgres from Jeffrey William Baker as example. =head1 SEE ALSO L Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store000755001751001751 012536600445 25243 5ustar00clementclement000000000000Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/DBI.pm000444001751001751 371712536600445 26344 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::DBI; use strict; use Apache::Session::Store::DBI; our @ISA = qw(Apache::Session::Store::DBI); our $VERSION = 1.0; sub insert { my ( $self, $session ) = @_; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; if ( !defined $self->{insert_sth} ) { $self->{insert_sth} = $self->{dbh}->prepare_cached( "INSERT INTO $self->{table_name} (" . join( ',', 'id', 'a_session', map { s/'/''/g; $_ } @$index ) . ') VALUES (' . join( ',', ('?') x ( 2 + @$index ) ) . ')' ); } $self->{insert_sth}->bind_param( 1, $session->{data}->{_session_id} ); $self->{insert_sth}->bind_param( 2, $session->{serialized} ); my $i = 3; foreach my $f (@$index) { $self->{insert_sth}->bind_param( $i, $session->{data}->{$f} ); $i++; } $self->{insert_sth}->execute; $self->{insert_sth}->finish; } sub update { my $self = shift; my $session = shift; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; if ( !defined $self->{update_sth} ) { $self->{update_sth} = $self->{dbh}->prepare_cached( "UPDATE $self->{table_name} SET " . join( ' = ?, ', 'a_session', @$index ) . ' = ? WHERE id = ?' ); } $self->{update_sth}->bind_param( 1, $session->{serialized} ); my $i = 2; foreach my $f (@$index) { $self->{update_sth}->bind_param( $i, $session->{data}->{$f} ); $i++; } $self->{update_sth}->bind_param( $i, $session->{data}->{_session_id} ); $self->{update_sth}->execute; $self->{update_sth}->finish; } 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/Oracle.pm000444001751001751 41012536600445 27116 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::Oracle; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Oracle; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Oracle); our $VERSION = '0.1'; 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/Redis.pm000444001751001751 427312536600445 27012 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::Redis; use strict; use Redis; our $VERSION = '1.0'; sub new { my ( $class, $session ) = @_; my $self; # Manage undef encoding $session->{args}->{encoding} = undef if ( $session->{args}->{encoding} and $session->{args}->{encoding} eq "undef" ); $self->{cache} = Redis->new( %{ $session->{args} } ); # Manage database $self->{cache}->select( $session->{args}->{database} ) if defined $session->{args}->{database}; bless $self, $class; } sub insert { my ( $self, $session ) = @_; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; $self->{cache}->set( $id, $session->{serialized} ); foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); $self->{cache}->sadd( "${i}_$t", $id ); } } *update = *insert; sub materialize { my ( $self, $session ) = @_; $session->{serialized} = $self->{cache}->get( $session->{data}->{_session_id} ) or die 'Object does not exist in data store.'; } sub remove { my ( $self, $session ) = @_; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); eval { $self->{cache}->srem( "${i}_$t", $id ); }; } $self->{cache}->del($id); } 1; __END__ =pod =head1 NAME Apache::Session::Browseable::Store::Redis - An implementation of Apache::Session::Store =head1 SYNOPSIS use Apache::Session::Browseable::Redis; tie %hash, 'Apache::Session::Browseable::Redis', $id, { # optional: default to localhost server => '127.0.0.1:6379', }; =head1 DESCRIPTION This module is an implementation of Apache::Session::Browseable. It uses the Redis storage system =head1 AUTHOR This module was written by Xavier Guimard =head1 SEE ALSO L, L, L Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/Postgres.pm000444001751001751 41612536600445 27525 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::Postgres; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Postgres; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Postgres); our $VERSION = '0.1'; 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/Sybase.pm000444001751001751 41012536600445 27137 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::Sybase; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Sybase; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Sybase); our $VERSION = '0.1'; 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/Informix.pm000444001751001751 41612536600445 27512 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::Informix; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::Informix; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::Informix); our $VERSION = '0.1'; 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/LDAP.pm000444001751001751 1651712536600445 26510 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::LDAP; use strict; use Net::LDAP; our $VERSION = '1.1'; sub new { my $class = shift; return bless {}, $class; } sub insert { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; my $attrIndex; foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); push @$attrIndex, "${i}_$t"; } my $attrs = [ objectClass => $self->{args}->{ldapObjectClass}, $self->{args}->{ldapAttributeId} => $session->{data}->{_session_id}, $self->{args}->{ldapAttributeContent} => $session->{serialized}, ]; push @$attrs, ( $self->{args}->{ldapAttributeIndex} => $attrIndex ) if ($attrIndex); my $msg = $self->ldap->add( $self->{args}->{ldapAttributeId} . "=$id," . $self->{args}->{ldapConfBase}, attrs => $attrs, ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); } sub update { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; my $index = ref( $session->{args}->{Index} ) ? $session->{args}->{Index} : [ split /\s+/, $session->{args}->{Index} ]; my $id = $session->{data}->{_session_id}; my $attrIndex; foreach my $i (@$index) { my $t; next unless ( $t = $session->{data}->{$i} ); push @$attrIndex, "${i}_$t"; } my $attrs = { $self->{args}->{ldapAttributeContent} => $session->{serialized} }; $attrs->{ $self->{args}->{ldapAttributeIndex} } = $attrIndex if ($attrIndex); my $msg = $self->ldap->modify( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, replace => $attrs, ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); } sub materialize { my $self = shift; my $session = shift; $self->{args} = $session->{args}; $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; my $msg = $self->ldap->search( base => $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase}, filter => '(objectClass=' . $self->{args}->{ldapObjectClass} . ')', scope => 'base', attrs => [ $self->{args}->{ldapAttributeContent} ], ); $self->ldap->unbind() && delete $self->{ldap}; $self->logError($msg) if ( $msg->code ); eval { $session->{serialized} = $msg->shift_entry() ->get_value( $self->{args}->{ldapAttributeContent} ); }; 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->{args}->{ldapObjectClass} ||= 'applicationProcess'; $self->{args}->{ldapAttributeId} ||= 'cn'; $self->{args}->{ldapAttributeContent} ||= 'description'; $self->{args}->{ldapAttributeIndex} ||= 'ou'; $self->ldap->delete( $self->{args}->{ldapAttributeId} . "=" . $session->{data}->{_session_id} . "," . $self->{args}->{ldapConfBase} ); $self->ldap->unbind() && delete $self->{ldap}; } 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::Browseable::Store::LDAP - Use LDAP to store persistent objects =head1 SYNOPSIS use Apache::Session::Browseable::Store::LDAP; my $store = new Apache::Session::Browseable::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, ldapObjectClass, ldapAttributeId, ldapAttributeContent, ldapAttributeIndex are optional. Example: tie %s, 'Apache::Session::Browseable::LDAP', undef, { ldapServer => 'localhost', ldapBase => 'dc=example,dc=com', ldapBindDN => 'cn=admin,dc=example,dc=com', ldapBindPassword => 'pass', Index => 'uid ipAddr', ldapObjectClass => 'applicationProcess', ldapAttributeId => 'cn', ldapAttributeContent => 'description', ldapAttributeIndex => 'ou', }; =head1 AUTHOR Xavier Guimard, Eguimard@E =head1 COPYRIGHT AND LICENSE Copyright (C) 2010 by Xavier Guimard Copyright (C) 2015 by Clement Oudot 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-Browseable-1.1/lib/Apache/Session/Browseable/Store/MySQL.pm000444001751001751 40512536600445 26662 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::MySQL; use strict; use Apache::Session::Browseable::Store::DBI; use Apache::Session::Store::MySQL; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::MySQL); our $VERSION = '0.1'; 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/File.pm000444001751001751 25312536600445 26575 0ustar00clementclement000000000000package Apache::Session::Browseable::Store::File; use strict; use Apache::Session::Store::File; our @ISA = qw(Apache::Session::Store::File); our $VERSION = 0.1; 1; Apache-Session-Browseable-1.1/lib/Apache/Session/Browseable/Store/SQLite.pm000444001751001751 1126312536600445 27122 0ustar00clementclement000000000000############################################################################# # # Apache::Session::Browseable::SQLite # Apache persistent user sessions in a SQLite database # Copyright(c) 2013 Xavier Guimard # Inspired by Apache::Session::Store::Postgres # (copyright(c) 1998, 1999, 2000 Jeffrey William Baker (jwbaker@acm.org)) # Distribute under the Perl License # ############################################################################ package Apache::Session::Browseable::Store::SQLite; use strict; use DBI; use Apache::Session::Store::DBI; use Apache::Session::Browseable::Store::DBI; our @ISA = qw(Apache::Session::Browseable::Store::DBI Apache::Session::Store::DBI); our $VERSION = '1.0'; $Apache::Session::Browseable::Store::SQLite::DataSource = undef; sub connection { my $self = shift; my $session = shift; return if ( defined $self->{dbh} ); $session->{args}->{Commit} = exists( $session->{args}->{Commit} ) ? $session->{args}->{Commit} : 1; $self->{'table_name'} = $session->{args}->{TableName} || $Apache::Session::Store::DBI::TableName; if ( exists $session->{args}->{Handle} ) { $self->{dbh} = $session->{args}->{Handle}; $self->{commit} = $session->{args}->{Commit}; return; } my $datasource = $session->{args}->{DataSource} || $Apache::Session::Store::MySQL::DataSource; $self->{dbh} = DBI->connect( $datasource, '', '', { RaiseError => 1, AutoCommit => 0 } ) || die $DBI::errstr; #If we open the connection, we close the connection $self->{disconnect} = 1; #the programmer has to tell us what commit policy to use $self->{commit} = $session->{args}->{Commit}; } sub materialize { my $self = shift; my $session = shift; $self->connection($session); local $self->{dbh}->{RaiseError} = 1; if ( !defined $self->{materialize_sth} ) { $self->{materialize_sth} = $self->{dbh}->prepare_cached( qq{ SELECT a_session FROM $self->{'table_name'} WHERE id = ?} ); } $self->{materialize_sth}->bind_param( 1, $session->{data}->{_session_id} ); $self->{materialize_sth}->execute; my $results = $self->{materialize_sth}->fetchrow_arrayref; if ( !( defined $results ) ) { $self->{materialize_sth}->finish; die "Object does not exist in the data store"; } $self->{materialize_sth}->finish; $session->{serialized} = $results->[0]; } sub DESTROY { my $self = shift; if ( $self->{commit} ) { $self->{dbh}->commit; } if ( $self->{disconnect} ) { $self->{dbh}->disconnect; } } 1; =pod =head1 NAME Apache::Session::Browseable::Store::SQLite - Store persistent data in a SQLite database =head1 SYNOPSIS use Apache::Session::Browseable::Store::SQLite; my $store = new Apache::Session::Browseable::Store::SQLite; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); =head1 DESCRIPTION Apache::Session::Browseable::Store::SQLite fulfills the storage interface of Apache::Session. Session data is stored in a SQLite database. =head1 SCHEMA To use this module, you will need at least these columns in a table called 'sessions', or another name if you supply the TableName parameter. id char(32) # or however long your session IDs are. a_session text # This has an ~8 KB limit :( To create this schema, you can execute this command using the psql program: CREATE TABLE sessions ( id char(32) not null primary key, a_session text ); If you use some other command, ensure that there is a unique index on the table's id column. =head1 CONFIGURATION The module must know what datasource, username, and password to use when connecting to the database. These values can be set using the options hash (see Apache::Session documentation). The options are: =over 4 =item DataSource =item UserName =item Password =item Handle =item TableName =back Example: tie %hash, 'Apache::Session::Browseable::SQLite', $id, { DataSource => 'dbi:Pg:dbname=database', UserName => 'database_user', Password => 'K00l' }; Instead, you may pass in an already-opened DBI handle to your database. tie %hash, 'Apache::Session::Browseable::SQLite', $id, { Handle => $dbh }; =head1 AUTHOR This modules was written by Jeffrey William Baker A fix for the commit policy was contributed by Michael Schout =head1 SEE ALSO L, L