forked from melvincarvalho/foafme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rdfFragments.php
88 lines (70 loc) · 1.7 KB
/
rdfFragments.php
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
<?
function headerrdf()
{
$rdf = '<rdf:RDF xmlns:cert="http://www.w3.org/ns/auth/cert#"
';
$rdf .= ' xmlns:foaf="http://xmlns.com/foaf/0.1/"
';
$rdf .= ' xmlns:rsa="http://www.w3.org/ns/auth/rsa#"
';
$rdf .= ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
';
return $rdf;
}
function accountrdf($foafuri, $nicknameuri)
{
$rdf = '<foaf:Person rdf:ID="me">
';
$rdf .= ' <foaf:nick>'. $nicknameuri .'</foaf:nick>
';
$rdf .= ' <foaf:homepage rdf:resource="'. $foafuri .'"/>
';
$rdf .= ' <foaf:holdsAccount>
';
$rdf .= ' <foaf:OnlineAccount rdf:about="#acct">
';
$rdf .= ' <foaf:accountServiceHomePage rdf:resource="/cert/"/>
';
$rdf .= ' </foaf:OnlineAccount>
';
$rdf .= ' </foaf:holdsAccount>
';
$rdf .= '</foaf:Person>
';
return $rdf;
}
function certrdf($foafuri=NULL, $exp=NULL, $mod=NULL)
{
$rdf = '<rsa:RSAPublicKey>
';
$foaffile = ($foafuri)?$foafuri:'TYPE YOUR WEBID HERE';
$rdf .= ' <cert:identity rdf:resource="#me"/>
';
$rdf .= ' <rsa:public_exponent cert:decimal="';
$exponent = ($exp)?hexdec($exp):'TYPE THE EXPONENT OF YOUR PUBLIC KEY HERE';
$rdf .= $exponent.'"/>
';
$rdf .= ' <rsa:modulus cert:hex="';
$modulus = ($mod)?$mod:'TYPE THE MODULUS OF YOUR PUBLIC RSA KEY HERE';
$rdf .= $modulus.'"/>
';
$rdf .= '</rsa:RSAPublicKey>
';
return $rdf;
}
function footerrdf()
{
$rdf = '</rdf:RDF>';
return $rdf;
}
function generate_rdf($foafuri, $nicknameuri, $key)
{
$rdf = headerrdf();
$rdf .= accountrdf($foafuri, $nicknameuri);
if ( $nicknameuri && !empty($key) && $key['exponent'] && $key['modulus'] ) {
$rdf .= certrdf($nicknameuri, $key['exponent'], $key['modulus']);
}
$rdf .= footerrdf();
return $rdf;
}
?>