This file is indexed.

/usr/share/perl5/WWW/Finger/Fingerpoint.pm is in libwww-finger-perl 0.105-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
package WWW::Finger::Fingerpoint;

use 5.010;
use common::sense;
use utf8;

use Carp 0;
use Digest::SHA 0 qw[sha1_hex];
use HTTP::Link::Parser 0.102 qw[:standard];
use LWP::UserAgent 0;
use RDF::Query::Client 0.106;
use RDF::Trine 0.135;
use URI 0;

use parent qw[WWW::Finger];

BEGIN {
	$WWW::Finger::Fingerpoint::AUTHORITY = 'cpan:TOBYINK';
	$WWW::Finger::Fingerpoint::VERSION   = '0.105';
}

use constant rel_fingerpoint => 'http://ontologi.es/sparql#fingerpoint';

sub speed { 90 }

sub new
{
	my $class = shift;
	my $ident = shift or croak "Need to supply an e-mail address\n";
	my $self  = bless {}, $class;
		
	$ident = "mailto:$ident"
		unless $ident =~ /^[a-z0-9\.\-\+]+:/i;
	$ident = URI->new($ident);
	return undef
		unless $ident->scheme eq 'mailto';
	
	$self->{'ident'} = $ident;
	my ($user, $host) = split /\@/, $ident->to;
	
	my $ua = LWP::UserAgent->new;
	$ua->timeout(10);
	$ua->env_proxy;
	
	my $httphost = "http://$host/";
	my $response = $ua->head($httphost);
	return undef
		unless $response->is_success;
	
	my $linkdata = HTTP::Link::Parser::parse_links_to_rdfjson($response);
	my $sparql   = $linkdata->{ $httphost }->{ (rel_fingerpoint) }->[0]->{'value'};

	unless (defined $sparql)
	{
		$response = $ua->get($httphost,
			'Accept' => 'application/xhtml+xml;q=1.0, text/html;q=0.9, */*;q=0.1');
		return undef
			unless $response->is_success;
		if ($response->header('content-type') =~ m`^(text/html|application/xhtml+xml|application/xml|text/xml)`i)
		{
			$sparql = URI->new_abs($1, URI->new($httphost))
				if $response->content =~ m`<[Ll][Ii][Nn][Kk]\s+[Rr][Ee][Ll]="[^"]*http://ontologi\.es/sparql#fingerpoint[^"]*"\s+[Hh][Rr][Ee][Ff]="([^"]+)"\s*/?>`;
		}
	}

	return undef
		unless defined $sparql && length $sparql;
	
	$self->{'endpoint'} = $sparql;
	
	my $sha1 = sha1_hex($ident);
	my $sparql_query = "PREFIX foaf: <http://xmlns.com/foaf/0.1/>
	PREFIX wot: <http://xmlns.com/wot/0.1/>
	SELECT DISTINCT *
	WHERE {
		{
			{ ?person foaf:mbox <$ident> . }
			UNION
			{ ?person foaf:mbox_sha1sum \"$sha1\" . }
			UNION
			{ ?person foaf:account <$ident> . }
			UNION
			{ ?person foaf:holdsAccount <$ident> . }
		}
		OPTIONAL { ?person foaf:name ?name . }
		OPTIONAL { ?person foaf:nick ?nick . }
		OPTIONAL { ?person foaf:homepage ?homepage . }
		OPTIONAL { ?person foaf:mbox ?mbox . }
		OPTIONAL { ?person foaf:weblog ?weblog . }
		OPTIONAL { ?person foaf:img ?image . }
		OPTIONAL { ?k wot:pubkeyAddress ?key ; wot:identity ?person . }
	}";
	my @fields = qw(name homepage mbox weblog image key);
	
	my $query  = RDF::Query::Client->new($sparql_query);
	my $result = $query->execute($self->endpoint, {QueryMethod=>'POST'});
	my $webid;

	BINDING: while (my $binding = $result->next)
	{
		$webid = $binding->{'person'}->uri
			if  $binding->{'person'}
			and $binding->{'person'}->is_resource
			and !defined $webid;
			
		FIELD: foreach my $field (@fields)
		{
			next FIELD unless $binding->{$field};
			
			if ($binding->{$field}->is_resource)
				{ $self->{'data'}->{$field}->{ $binding->{$field}->uri } = 1; }
			elsif ($binding->{$field}->is_literal)
				{ $self->{'data'}->{$field}->{ $binding->{$field}->literal_value } = 1; }
		}
	}
	
	foreach my $field (@fields)
	{
		$self->{'data'}->{$field} = [ keys %{ $self->{'data'}->{$field} } ];
	}
	
	$self->{'webid'} = $webid;
	
	return $self;
}

sub graph
{
	my $self = shift;
	
	unless (defined $self->{'graph'})
	{
		my $ident = $self->{'ident'}.'';
		my $sha1 = sha1_hex($ident);
		my $model = RDF::Trine::Model->new( RDF::Trine::Store->temporary_store );
		my $query  = RDF::Query::Client->new("
			PREFIX foaf: <http://xmlns.com/foaf/0.1/>
			DESCRIBE ?person
			WHERE
			{
				{ ?person foaf:mbox <$ident> . }
				UNION
				{ ?person foaf:mbox_sha1sum \"$sha1\" . }
				UNION
				{ ?person foaf:account <$ident> . }
				UNION
				{ ?person foaf:holdsAccount <$ident> . }
			}");
		my $result = $query->execute($self->endpoint, {QueryMethod=>'POST'});
		if ($result)
		{
			while (my $st = $result->next)
			{
				$model->add_statement($st);
			}
			$self->{'graph'} = $model;
		}		
	}
	
	return $self->{'graph'};
}

sub get
{
	my ($self, @params) = @_;
	return WWW::Finger::_GenericRDF::_simple_sparql(
		$self,
		{use_endpoint=>1},
		map { HTTP::Link::Parser::relationship_uri($_) } @params );
}

sub endpoint
{
	my $self = shift;
	return $self->{'endpoint'};
}

sub webid
{
	my $self = shift;
	return $self->{'webid'};
}

sub _data
{
	my $self = shift;
	my $k    = shift;
	if (wantarray)
	{
		return @{ $self->{'data'}->{$k} }
			if defined $self->{'data'}->{$k};
	}
	else
	{
		return $self->{'data'}->{$k}->[0]
			if defined $self->{'data'}->{$k}->[0];
	}
	return undef;
}

sub name
{
	my $self = shift;
	return $self->_data('name');
}

sub nick
{
	my $self = shift;
	return $self->_data('nick');
}

sub mbox
{
	my $self = shift;
	return $self->_data('mbox');
}

sub image
{
	my $self = shift;
	return $self->_data('image');
}

sub homepage
{
	my $self = shift;
	return $self->_data('homepage');
}

sub weblog
{
	my $self = shift;
	return $self->_data('weblog');
}

sub key
{
	my $self = shift;
	return $self->_data('key');
}

1;

__END__

=head1 NAME

WWW::Finger::Fingerpoint - Investigate E-mail Addresses using Fingerpoint

=head1 SYNOPSIS

  ## Using WWW::Finger
  
  use WWW::Finger;
  
  my $finger = WWW::Finger->new("joe@example.com");
  
  if ($finger)
  {
    if ($finger->isa('WWW::Finger::Fingerpoint'))
    {
      print "WWW::Finger used WWW::Fingerpoint\n";
    }
    print $finger->name . "\n";  # print person's name.
 }

  ## Using WWW::Finger::Fingerpoint directly
  
  use RDF::Query::Client;
  use WWW::Finger::Fingerpoint;
  
  my $fingerpoint = WWW::Finger::Fingerpoint->new("joe@example.com");
  
  if ($fingerpoint->webid)
  {
    my $sparql  = sprintf(
      "SELECT * WHERE {<%s> <http://xmlns.com/foaf/0.1/homepage> ?page.}",
      $fingerpoint->webid);
    my $query   = RDF::Query::Client->new($sparql);
    my $results = $query->execute($fingerpoint->endpoint);
	 while (my $row = $results->next)
    {
      print "Found page: " . $row->{'page'}->uri . "\n";
    }
  }
  
=head1 DESCRIPTION

As well as the standard WWW::Finger methods, WWW::Finger::Fingerpoint provides this
additional method:

=over

=item C<< get($p1, $p2, ...) >>

$p1, $p2 and are RDF predicate URIs. Returns a list of values which are non-bnode
objects of triples where the predicate URI is one of the parameters and the 
subject URI is the person/agent fingered.

  # Returns phone numbers...
  $finger->get('http://xmlns.com/foaf/0.1/phone',
               'http://rdf.data-vocabulary.org/#tel');

=back

=head1 SEE ALSO

L<WWW::Finger>.

L<RDF::Query::Client>, L<RDF::Trine>.

L<http://buzzword.org.uk/2009/fingerpoint/spec>.

L<http://www.perlrdf.org/>.

=head1 AUTHOR

Toby Inkster, E<lt>tobyink@cpan.orgE<gt>

=head1 COPYRIGHT AND LICENCE

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.

=head1 DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

=cut