X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=msva;h=785c061ce067efa9a6003ecb72afb58edf8790fb;hb=1a36d59ec2955809bac31fd5f6a959bdbc3b1b46;hp=5217624760a78cbfbcc8ebdbdd9ecd8b61677a75;hpb=f3da65498d78530715ea507e6e751eb27c04b62a;p=monkeysphere-validation-agent.git diff --git a/msva b/msva index 5217624..785c061 100755 --- a/msva +++ b/msva @@ -25,14 +25,17 @@ use strict; my $path = $cgi->path_info(); my $handler = $dispatch{$path}; - # FIXME: ensure that this is a POST if (ref($handler) eq "CODE") { + # FIXME: ensure that this actually is a POST printf STDERR ("Got POST %s\n", $path); + my ($status, $object) = $handler->($cgi); - printf("HTTP/1.0 %s\r\nContent-Type: application/json\r\n\r\n%s", $status, to_json ($object)); + my $ret = to_json($object); + printf STDERR ("returning: %s\n", $ret); + printf("HTTP/1.0 %s\r\nContent-Type: application/json\r\n\r\n%s", $status, $ret); } else { - printf("HTTP/1.0 400 Bad Request -- not handled by Monkeysphere validation agent\r\nContent-Type: text/plain\r\n\r\nBad Request -- the path:\r\n %s\r\nis not handled by the MonkeySphere validation agent.\r\nPlease try one of the following paths instead:\r\n\r\n%s\r\n", $path, ' * '.join("\r\n * ", keys %dispatch) ); + printf("HTTP/1.0 404 Not Found -- not handled by Monkeysphere validation agent\r\nContent-Type: text/plain\r\n\r\nHTTP/1.0 404 Not Found -- the path:\r\n %s\r\nis not handled by the MonkeySphere validation agent.\r\nPlease try one of the following paths instead:\r\n\r\n%s\r\n", $path, ' * '.join("\r\n * ", keys %dispatch) ); } } @@ -40,14 +43,16 @@ use strict; my $cgi = shift; # CGI.pm object return if !ref $cgi; - # FIXME: these should be opening up a json blob instead of using CGI params. - my $uid = $cgi->param('uid'); - my $pkc = $cgi->param('pkc'); - my $context = $cgi->param('context'); + # open a json blob instead of using CGI params. + my $data = from_json($cgi->param('POSTDATA')); + + use Data::Dumper; + print STDERR Dumper($data); + + my $uid = $data->{context}.'://'.$data->{uid}; - my $ret = { foo => 'bar' }; - # my $status = '404 no match found for the public key in this certificate'; - # or: + my $ret = { valid => JSON::true, + message => sprintf('tried to validate "%s" through the OpenPGP Web of Trust', $uid) }; my $status = '200 match found, authentication details to follow'; return $status, $ret;