[system] / trunk / webwork-modperl / lib / WeBWorK / Upload.pm Repository:
ViewVC logotype

Annotation of /trunk/webwork-modperl/lib/WeBWorK/Upload.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 455 - (view) (download) (as text)

1 : sh002i 455 ################################################################################
2 :     # WeBWorK mod_perl (c) 1995-2002 WeBWorK Team, Univeristy of Rochester
3 :     # $Id$
4 :     ################################################################################
5 : malsyned 420
6 : sh002i 455 package WeBWorK::Upload;
7 : malsyned 420
8 : sh002i 455 =head1 NAME
9 :    
10 :     WeBWorK::Upload - everything we need to be confident about an upload.
11 :    
12 :     =cut
13 :    
14 :     use Data::UUID;
15 :     use MD5 qw();
16 : malsyned 420 use WeBWorK::Constants qw(SECRET);
17 :    
18 : sh002i 455 # This package allows a file to be reliably cached on disk and replaced with
19 :     # a string that universally and unforgeably represents that file, and then
20 :     # retrieved later given that string.
21 : malsyned 420
22 :     sub store_upload {}
23 :    
24 :     sub retrieve_upload {}
25 :    
26 :     sub new {
27 :     unless (SECRET) {
28 :     die "A secret has not been set in WeBWorK::Constants for this server.";
29 :     }
30 :     my $invocant = shift;
31 :     my $class = ref($invocant) || invocant;
32 :     my $self = {
33 :     basedir => shift; # The directory into which to place the spool file
34 :     uploadObject => shift; # The Apache::Upload object to deal with
35 :     };
36 :    
37 :     my $ug = Data::UUID->new; # UUID Generator/Handler
38 :     my $uuid = $ug->generate; # Unique identifier for this file, guaranteed to be unique until 3400AD
39 :     my $uuid_as_string = $ug->to_string($uuid);
40 :     my $mac = MD5->hexhash(SECRET . MD5->hexhash(SECRET . $uuid_as_string); # Message Authentication Check. As long as SECRET stays secret,
41 :    
42 :    
43 :     $self->{
44 :     $self->{MAC} = MD5->hexhash(SECRET . MD4->hexhash(SECRET . $self{UUID}-> # Message Authentication Check - An unforgeable checksum
45 :     };
46 :     }
47 :    
48 :     1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9