1 package Maasha::BGB::Session;
3 # Copyright (C) 2009 Martin A. Hansen.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 # http://www.gnu.org/copyleft/gpl.html
22 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
25 # Routines for session handling of the Biopieces Browser.
28 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
38 use vars qw( @ISA @EXPORT );
40 @ISA = qw( Exporter );
43 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
48 # Martin A. Hansen, December 2009.
50 # Create a new session id which is md5 hashed.
56 $sid = Digest::MD5::md5_hex( Maasha::Common::get_sessionid() );
64 # Martin A. Hansen, December 2009.
66 # Parses a tab seperated session file and returns the data
67 # as a hash with user as key, and the rest of the columns as
70 my ( $file, # session file
75 my ( $fh, $line, $user, $password, $sid, $time, %session );
77 $fh = Maasha::Filesys::file_read_open( $file );
79 while ( $line = <$fh> )
83 ( $user, $password, $sid, $time ) = split /\t/, $line;
86 PASSWORD => $password,
94 return wantarray ? %session : \%session;
100 # Martin A. Hansen, December 2009.
102 # Stores a session hash to file.
104 my ( $file, # file to store in.
105 $session, # session to store.
112 $fh = Maasha::Filesys::file_write_open( $file );
114 foreach $user ( keys %{ $session } )
119 $session->{ $user }->{ 'PASSWORD' },
120 $session->{ $user }->{ 'SESSION_ID' },
121 $session->{ $user }->{ 'TIME' }
129 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<