Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

write README that describes how XML_XRD is to be used

  • Loading branch information...
commit dd0c054f56f634b27a487bc58a8a9d00112b6682 0 parents
@cweiske cweiske authored
Showing with 253 additions and 0 deletions.
  1. +181 −0 README.rst
  2. +15 −0 tests/xrd-1.0-b1.xrd
  3. +57 −0 tests/xrd-1.0-b2.xrd
181 README.rst
@@ -0,0 +1,181 @@
+*******
+XML_XRD
+*******
+
+PHP library to parse `Extensible Resource Descriptor (XRD) Version 1.0` files.
+
+The XRD format supercedes the XRDS format defined in XRI 2.0.
+
+
+========
+Examples
+========
+
+Load from file
+==============
+::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('/path/to/my.xrd');
+
+
+Load from string
+================
+::
+
+ <?php
+ $myxrd = <<<XRD
+ <?xml version="1.0"?>
+ <XRD>
+ ...
+ XRD;
+
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadString($myxrd);
+
+
+Verify subject
+==============
+Check if the XRD file really describes the resource/URL that we requested the
+XRD for::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ if (!$xrd->describes('http://example.org/')) {
+ die('XRD document is not the correct one for http://example.org/');
+ }
+
+The ``<subject>`` and all ``<alias>`` tags are checked.
+
+
+Get all links
+=============
+::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ foreach ($xrd as $link) {
+ echo $link->rel . ': ' . $link->href . "\n";
+ }
+
+
+Get link by relation
+====================
+Returns the first link that has the given ``relation``::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ $idpLink = $xrd->get('lrdd');
+ echo $idpLink->rel . ': ' . $idpLink->href . "\n";
+
+
+Get link by relation + optional type
+====================================
+If no link with the given ``type`` is found, the first link with the correct
+``relation`` and an empty ``type`` will be returned::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ $link = $xrd->get('lrdd', 'application/xrd+xml');
+ echo $link->rel . ': ' . $link->href . "\n";
+
+
+Get link by relation + type
+===========================
+The ``relation`` and the ``type`` both need to match exactly::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ $link = $xrd->get('lrdd', 'application/xrd+xml', false);
+ echo $link->rel . ': ' . $link->href . "\n";
+
+
+Get all links by relation
+=========================
+::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ foreach ($xrd->getAll('lrdd') as $link) {
+ echo $link->rel . ': ' . $link->href . "\n";
+ }
+
+
+Get a single property
+=====================
+::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ if (isset($xrd['http://spec.example.net/type/person'])) {
+ echo $xrd['http://spec.example.net/type/person'] . "\n";
+ }
+
+
+Get all properties
+==================
+::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ foreach ($xrd->getProperties() as $property) {
+ echo $property->type . ': ' . $property->value . "\n",
+ }
+
+
+Get all properties of a type
+============================
+::
+
+ <?php
+ require_once 'XML/XRD.php';
+ $xrd = new XML_XRD();
+ $xrd->loadFile('http://example.org/.well-known/host-meta');
+ foreach ($xrd->getProperties('http://spec.example.net/type/person') as $property) {
+ echo $property->type . ': ' . $property->value . "\n",
+ }
+
+
+====
+TODO
+====
+
++ load from string
++ load from file
++ verify that subject/alias matches
++ get properties
++ get links
+
+ + all links
+ + links with certain properties set
+
+- get expiry time
+- XML signature verification
+- (very optional) XRDS (multiple XRD)?
+
+==========
+References
+==========
+
+- Standard: http://docs.oasis-open.org/xri/xrd/v1.0/xrd-1.0.html
+- http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xri
+- http://code.google.com/p/webfinger/wiki/XrdFiles
15 tests/xrd-1.0-b1.xrd
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <Expires>1970-01-01T00:00:00Z</Expires>
+ <Subject>http://example.com/gpburdell</Subject>
+ <Property type="http://spec.example.net/type/person" xsi:nil="true" />
+ <Link rel="http://spec.example.net/auth/1.0"
+ href="http://services.example.com/auth" />
+ <Link rel="http://spec.example.net/photo/1.0" type="image/jpeg"
+ href="http://photos.example.com/gpburdell.jpg">
+ <Title xml:lang="en">User Photo</Title>
+ <Title xml:lang="de">Benutzerfoto</Title>
+ <Property type="http://spec.example.net/created/1.0">1970-01-01</Property>
+ </Link>
+</XRD>
57 tests/xrd-1.0-b2.xrd
@@ -0,0 +1,57 @@
+<?xml version="1.0"?>
+<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xml:id="foo">
+ <Expires>1970-01-01T00:00:00Z</Expires>
+ <Subject>http://example.com/gpburdell</Subject>
+ <Alias>http://people.example.com/gpburdell</Alias>
+ <Alias>acct:gpburdell@example.com</Alias>
+ <Property type="http://spec.example.net/version">1.0</Property>
+ <Property type="http://spec.example.net/version">2.0</Property>
+ <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <ds:SignedInfo>
+ <ds:CanonicalizationMethod
+ Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ <ds:SignatureMethod
+ Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
+ <ds:Reference URI="#foo">
+ <ds:Transforms>
+ <ds:Transform
+ Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
+ <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
+ <InclusiveNamespaces PrefixList="#default xrd ds xs xsi"
+ xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+ </ds:Transform>
+ </ds:Transforms>
+ <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
+ <ds:DigestValue>yi2N42KYR6b8dl6TCBKjs4duPuo=</ds:DigestValue>
+ </ds:Reference>
+ </ds:SignedInfo>
+ <ds:SignatureValue>
+ NGJ/tVRnK8O7FwTic3nQjrEw1do+SgWE/LKE/Q2bgE+k4b3Go6d9fLZq0/DX8nyr
+ x0nYfpTgxzMUDVUVaDyvnp0MfnmTSJ/yL5bXAV2jW6+NWJH73DXjQoPKn0j1WY2G
+ UoTdgnMiiNzKYY+QhWYogy4QXJOmjOF+6OE+uONKvQU=
+ </ds:SignatureValue>
+ <ds:KeyInfo>
+ <ds:X509Data>
+ <ds:X509Certificate>
+ MIICsDCCAhmgAwIBAgIJAK6eiEXk2FoiMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
+ BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
+ aWRnaXRzIFB0eSBMdGQwHhcNMTAwNTA3MDQ1MDAzWhcNMzgwMTE5MDQ1MDAzWjBF
+ MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50
+ ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
+ gQDVEftG6aMNrBRMu9hHaZUe4ZU5jrbtsaexNlh4OWnIOj9Tyyk2NfI9w1b2hp5f
+ KQf5B9HYeZjowuYKVuc+NQMYgkN7V+YvcJ9ohAjCBZuo9Xcm5CiKeFnz5E6Ad0Fs
+ BPnAHch9kZu2joz+iQOp6Av+A78Gvam9giG9ZT3rIj2LZQIDAQABo4GnMIGkMB0G
+ A1UdDgQWBBR3yN91g2lEACpJ9WaKm3fM+PAPqTB1BgNVHSMEbjBsgBR3yN91g2lE
+ ACpJ9WaKm3fM+PAPqaFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt
+ U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAK6eiEXk
+ 2FoiMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAc3cepBp8h2rwwc+f
+ lFahLmJNVOePhw+uCyO8tLWu7Jcq9todVmeCNyqB9hGm2Rvt5yQ69tRpMxQ7Wmqs
+ O6HbDYzW5APuCPHEtlXoafEq4oWZS8ICPNel68MX5mnXg+XkUOb8cjuY8CwRNtBf
+ Ehs3jFzXUcMITIL1PmE7bb38Hug=
+ </ds:X509Certificate>
+ </ds:X509Data>
+ </ds:KeyInfo>
+ </ds:Signature>
+ <Link rel="http://spec.example.net/auth/1.0"
+ href="http://services.example.com/auth" />
+</XRD>
Please sign in to comment.
Something went wrong with that request. Please try again.