From d02472cfa6ea398f0959f7cb633f17e50de4d426 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Fri, 19 Nov 2010 08:53:22 -0800 Subject: [PATCH] Change Session::ID to no longer need a session. Instead, you pass it a seed for salting the hash generation. --- lib/WebGUI/Session.pm | 2 +- lib/WebGUI/Session/Id.pm | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index 940a87043..de414696c 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -492,7 +492,7 @@ Returns a reference to the WebGUI::Session::Id object. sub id { my $self = shift; unless ($self->{_id}) { - $self->{_id} = WebGUI::Session::Id->new($self); + $self->{_id} = WebGUI::Session::Id->new($self->config->getFilename); } return $self->{_id}; } diff --git a/lib/WebGUI/Session/Id.pm b/lib/WebGUI/Session/Id.pm index ccc82e73b..6a12be990 100644 --- a/lib/WebGUI/Session/Id.pm +++ b/lib/WebGUI/Session/Id.pm @@ -89,7 +89,7 @@ This function generates a global unique id. sub generate { my $self = shift; my($s,$us)=gettimeofday(); - my($v)=sprintf("%09d%06d%10d%06d%255s",rand(999999999),$us,$s,$$,$self->session->config->getFilename); + my($v)=sprintf("%09d%06d%10d%06d%255s",rand(999999999),$us,$s,$$,$self->seed); my $id = Digest::MD5::md5_base64($v); $id =~ tr{+/}{_-}; return $id; @@ -109,23 +109,22 @@ A reference to the current session. sub new { my $class = shift; - my $session = shift; - my $self = bless { _session => $session }, $class; - weaken $self->{_session}; + my $seed = shift; + my $self = bless { _seed => $seed }, $class; return $self; } #------------------------------------------------------------------- -=head2 session ( ) +=head2 seed ( ) -Returns a reference to the current session. +Returns the seed that be used for salting the data sent to MD5. =cut -sub session { +sub seed { my $self = shift; - return $self->{_session}; + return $self->{_seed}; }