Commits

Toby Inkster committed 07f2da0 Draft

remove RDF-TrineShortcuts dep; add deprecation notice; bump version

Comments (0)

Files changed (2)

examples/testing.pl

 HTRS2zGtz4CPPbA9Y4YYg/aP9NeLGw4dLcP+j5FhpkCkLMUVqDxKyBmcjkQVPz8=
 -----END CERTIFICATE-----';
 
-my $auth = CGI::Auth::FOAF_SSL->new($foaf_ssl_webid);
+my $auth = CGI::Auth::FOAF_SSL->new($cert);
 p $auth;
 
 #print $auth->account->identity . "\n";

lib/CGI/Auth/FOAF_SSL.pm

 use Math::BigInt 0 try => 'GMP';
 use MIME::Base64 0 qw[];
 use Object::ID 0;
-use RDF::TrineShortcuts 0.100;
+use RDF::TrineX::Functions -shortcuts;
 use Scalar::Util 0 qw[blessed];
 
 # use Data::Printer 0;
 	VALIDATION_PEM     => 1,
 	VALIDATION_DATES   => 2,
 	VALIDATION_WEBID   => 3,
-	};
+};
 	
 our $VERSION;
 our $ua_string;
 	$SESSION = {};
 }
 
+sub rdf_query
+{
+	my ($sparql, $model) = @_;
+	my $class   = (blessed($model) and $model->isa('RDF::Trine::Model'))
+		? 'RDF::Query'
+		: 'RDF::Query::Client';
+	my $query   = $class->new($sparql);
+	my $results = $query->execute($model);
+	
+	unless ($results)
+	{
+		warn "$sparql";
+		warn "$model";
+		warn $query->error;
+		return;
+	}
+
+	if ($results->is_boolean)
+		{ return $results->get_boolean }
+	if ($results->is_bindings)
+		{ return $results }
+	if ($results->is_graph)
+		{ my $m = rdf_parse(); $m->add_hashref($results->as_hashref); return $m }
+	
+	return;
+}
+
 sub new
 {
 	my ($class, $pem, @params) = @_;
 	$ua->default_headers->push_header('Accept' => "application/rdf+xml, text/turtle, application/x-turtle, application/xhtml+xml;q=0.9, text/html;q=0.9, */*;q=0.1");
 	my $response = $ua->get($uri);
 	return unless $response->is_success && length $response->content;
-	my $model = rdf_parse($response);
+	my $model = rdf_parse(
+		$response->decoded_content,
+		type  => scalar($response->content_type),
+		base  => ($response->base || $uri),
+	);
 	
 	$self->session->param($uri, rdf_string($model, 'ntriples'));
 	$self->session->flush;
     print "<p>Greetings stranger!</p>\n";
   }
 
+=head1 DEPRECATION
+
+CGI::Auth::FOAF_SSL was the original WebID module for Perl, but it is
+now deprecated in favour of L<Web::ID>.
+
+L<Web::ID> has a cleaner interface and is less CGI-specific. It should
+work equally well in other HTTPS contexts. It has L<Plack> middleware
+(but its core does not rely on Plack). Use it.
+
 =head1 DESCRIPTION
 
 FOAF+SSL (a.k.a. WebID) is a simple authentication scheme described
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2009-2011 by Toby Inkster
+Copyright (C) 2009-2012 by Toby Inkster
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.