Change Session::ID to no longer need a session. Instead, you pass it a seed for salting the hash generation.

This commit is contained in:
Colin Kuskie 2010-11-19 08:53:22 -08:00
parent 68638c2ae8
commit d02472cfa6
2 changed files with 8 additions and 9 deletions

View file

@ -492,7 +492,7 @@ Returns a reference to the WebGUI::Session::Id object.
sub id { sub id {
my $self = shift; my $self = shift;
unless ($self->{_id}) { unless ($self->{_id}) {
$self->{_id} = WebGUI::Session::Id->new($self); $self->{_id} = WebGUI::Session::Id->new($self->config->getFilename);
} }
return $self->{_id}; return $self->{_id};
} }

View file

@ -89,7 +89,7 @@ This function generates a global unique id.
sub generate { sub generate {
my $self = shift; my $self = shift;
my($s,$us)=gettimeofday(); 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); my $id = Digest::MD5::md5_base64($v);
$id =~ tr{+/}{_-}; $id =~ tr{+/}{_-};
return $id; return $id;
@ -109,23 +109,22 @@ A reference to the current session.
sub new { sub new {
my $class = shift; my $class = shift;
my $session = shift; my $seed = shift;
my $self = bless { _session => $session }, $class; my $self = bless { _seed => $seed }, $class;
weaken $self->{_session};
return $self; 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 =cut
sub session { sub seed {
my $self = shift; my $self = shift;
return $self->{_session}; return $self->{_seed};
} }