Skip to main content
Jump to: navigation, search

Difference between revisions of "IdAS XDI Mapping"

(Hash I-Numbers for Complex Values)
(Links)
 
(76 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{#eclipseproject:technology.higgins}}
+
{{#eclipseproject:technology.higgins|eclipse_custom_style.css}}  
This page documents the mapping between the [[Higgins Data Model]] (which is implemented by [[IdAS]]) and XDI. XDI ("XRI Data Interchange") is a data model and protocol for sharing, linking, and synchronizing data over the Internet ("structured web") and other networks using Extensible Resource Identifiers (XRIs). It is being developed by the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xdi OASIS XDI Technical Committee].
+
  
The [[IdAS XDI Engine]] exposes an IdAS Context at an XDI endpoint. It processes and applies incoming XDI messages.
+
=== Status ===
 +
* This document needs to be updated to show a representative [[Persona Data Model 2.0]] data structure instead of the "made up" structure shown in the diagram below.
 +
* The endpoints are all broken at present (old parityinc, graceland links)
  
The [[XDI Context Provider]] implements an IdAS Context by sending XDI messages. These message can be sent either to an XDI endpoint exposed by the [[IdAS XDI Engine]] or to a native XDI endpoint.
+
=== Introduction ===
 +
This page documents the mapping between the Higgins [[Context Data Model]] (which is implemented by [[IdAS]]) and XDI. XDI ("XRI Data Interchange") is a data model and protocol for sharing, linking, and synchronizing data over the Internet ("structured web") and other networks using Extensible Resource Identifiers (XRIs). It is being developed by the [http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xdi OASIS XDI Technical Committee].  
  
== Concepts ==
+
The [[Org.eclipse.higgins.as|Attribute Service]] exposes an IdAS Context at an XDI endpoint. It processes and applies incoming XDI messages.
  
Since the Higgins Data Model is based on RDF/OWL, and since XDI is also (conceptually) based on RDF, the basic mapping is straight-forward. However, some attention has to be paid to details.
+
The [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]] implements an IdAS Context by sending XDI messages. These message can be sent either to an XDI endpoint exposed by the [[Org.eclipse.higgins.as|Attribute Service]] or to a native XDI endpoint.  
  
Roughly speaking, a Higgins context can be mapped to an XDI graph using the following rules:
+
== Mapping  ==
* An [[Entity]] maps to an XDI subject
+
* An [[Attribute]] maps to an XDI predicate
+
* Simple Values map to an XDI inner graph containing one subject per value
+
* Complex Values without an Entity ID map to an XDI inner graph containing one subject per value
+
* Complex Values with an Entity ID map to XDI references
+
* A Higgins [[Correlation]] maps to the special $is XDI predicate
+
* An rdf:type predicate maps to the special $is$a XDI predicate
+
  
=== Hash I-Numbers for Simple Values ===
+
=== Concepts  ===
  
On several occasions in this mapping, it is necessary to refer to individual Simple Values of a multi-valued Attribute. Since Simple Values in Higgins IdAS do not have persistent identifiers, a mechanism called "Hash I-Number" (HIN) is used. A HIN is an i-number that is deterministically calculated from a value, therefore acting as an index of that value in the multi-valued Attribute.  
+
Since the Higgins Data Model is based on RDF/OWL, and XDI is also based on RDF, the basic mapping is straightforward. However, some attention has to be paid to details.  
  
This pseudocode can be used to calculate a HIN for a Simple Value:
+
A Higgins [[Context]] can be mapped to an XDI graph using the following rules:  
  
<pre>
+
*An [[Entity]] maps to an XDI subject. The XDI subject's XRI is the Entity ID cast to an XRI.
FUNCTION makeSimpleHin(simpleValue)
+
*An [[Attribute]] maps to an XDI predicate. The XDI predicate's XRI is the Attribute ID cast to an XRI.
 +
*In general, each Value of an [[Attribute]] maps to an XDI subject inside an XDI inner graph. The XDI subject's XRI is a HIN (Hash I-Number) calculated from the Value.
 +
**If the Value is a Simple Value, then the XDI subject in the XDI inner graph has a single XDI predicate with an XDI literal. The XDI predicate's XRI is the the special $value XDI predicate.
 +
**If the Value is a Complex Value, then the rules for mapping the Attributes of that Complex Value apply recursively, i.e. each Attribute of the Complex Value maps to an XDI predicate.
 +
*Special case 1: If an [[Attribute]] contains only a single Simple Value, then that [[Attribute]] does not need an inner graph. Instead the Value maps directly to an XDI literal on the XDI predicate that represents the [[Attribute]].
 +
*Special case 2: If an [[Attribute]] is an [[Entity Relation]], then that [[Attribute]] does not need an inner graph. Instead the Values map directly to XDI references on the XDI predicate that represents the [[Attribute]].
 +
*An [[Entity Correlation]] maps to an XDI statement with the special $is XDI predicate
 +
*The type of an [[Entity]] maps to an XDI statement with the special $is$a XDI predicate
 +
*The type of a Value maps to an XDI statement with the special $is$a XDI predicate
  
   String hin = "$value$hash$md5" + "!" + hex(md5(simpleValue.string));
+
=== Example  ===
 +
 
 +
Example Context diagram:
 +
 
 +
[[Image:IdAS XDI.png]]
 +
 
 +
Example Context description:
 +
 
 +
*The Context has three Entities '''=paul''', '''=sergey''' and '''=drummond'''.
 +
*'''=paul''' has an Attribute '''+name''', which has a single Simple Value&nbsp;:'''"Paul T."'''.
 +
*'''=paul''' has an Entity Relation '''+friend''' to '''=sergey''' and '''=drummond'''.
 +
*'''=paul''' has an Attribute '''+phone''', which has two Values:
 +
**The first Value is a Simple Value: '''"+1 (617) 513 7924"'''.
 +
**The second Value is a Simple Value: '''"+1 (781) 559 0153"'''.
 +
*'''=paul''' has an Attribute '''+address''', which has three Values:
 +
**The first Value is a Simple Value: '''"56 Kearney Rd, Needham, Massachusetts 02494, USA"'''.
 +
**The second Value is a Complex Value. It has four Attributes '''+street''', '''+city''', '''+state''' and '''+zip'''.
 +
***The first Attribute has a single Simple Value: '''"56 Kearney Rd"'''.
 +
***The second Attribute has a single Simple Value: '''"Needham"'''.
 +
***The third Attribute has a single Simple Value: '''"MA"'''.
 +
***The fourth Attribute has a single Simple Value: '''"02494"'''.
 +
**The third Value is a Complex Value. It has two Attributes '''+line''' and '''+country'''.
 +
***The first Attribute has two Values.
 +
****The first Value is a Simple Value: '''"56 Kearney Rd"'''.
 +
****The second Value is a Simple Value: '''"Needham, Massachusetts 2494"'''.
 +
***The second Attribute has a single Simple Value: '''"USA"'''.
 +
 
 +
Example Context in XDI:
 +
<pre>=paul    &lt;-- An Entity --&gt;
 +
  +name    &lt;-- A "Special Case 1" Attribute --&gt;
 +
      "Paul T."    &lt;-- A single Simple Value --&gt;
 +
  +friend    &lt;-- A "Special Case 2" Attribute --&gt;
 +
      =sergey    &lt;-- An Entity Relation Value --&gt;
 +
      =drummond    &lt;-- An Entity Relation Value --&gt;
 +
  +phone    &lt;-- An Attribute with two Values --&gt;
 +
      /
 +
        $value$hash$sha$256!e5754ab606a4f0d6a3570d2c37c1f75643b9eefccf8e66e27ec77499bea8ae1d    &lt;-- First Value of +phone: A Simple Value --&gt;
 +
            $value
 +
              "+1 (617) 513 7924"
 +
        $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca    &lt;-- Second Value of +phone: A Simple Value --&gt;
 +
            $value
 +
              "+1 (781) 559 0153"
 +
  +address    &lt;-- An Attribute with three Values --&gt;
 +
      /
 +
        $value$hash$sha$256!07e8c548c164ea1df063e85d13a5faa04ee2e3129b571ace4360c557ba506a9c    &lt;-- First Value of +address: A Simple Value --&gt;
 +
            $value
 +
              "56 Kearney Rd, Needham, Massachusetts 02494, USA"
 +
        $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715    &lt;-- Second Value of +address: A Complex Value with four Attributes --&gt;
 +
            +street    &lt;-- A "Special Case 1" Attribute --&gt;
 +
              "56 Kearney Rd"    &lt;-- A single Simple Value --&gt;
 +
            +city    &lt;-- A "Special Case 1" Attribute --&gt;
 +
              "Needham"    &lt;-- A single Simple Value --&gt;
 +
            +state    &lt;-- A "Special Case 1" Attribute --&gt;
 +
              "MA"    &lt;-- A single Simple Value --&gt;
 +
            +zip    &lt;-- A "Special Case 1" Attribute --&gt;
 +
              "02494"    &lt;-- A single Simple Value --&gt;
 +
        $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324    &lt;-- Third Value of +address: A Complex Value with two Attributes --&gt;
 +
            +line    &lt;-- An Attribute with two values --&gt;
 +
              /
 +
                  $value$hash$sha$256!4e8ae563672c68cb1533ae16993a693033f1a9032e43893c3464956b8ec2109c    &lt;-- First Value of +line: A Simple Value --&gt;
 +
                    $value
 +
                        "56 Kearney Rd"
 +
                  $value$hash$sha$256!d27ef0bac9a6830121ebc30cd911fa9672a28fa8e8bd5d63ae3ade11af519d32    &lt;-- Second Value of +line: A Simple Value --&gt;
 +
                    $value
 +
                        "Needham, Massachusetts 02494"
 +
            +country    &lt;-- A "Special Case 1" Attribute --&gt;
 +
              "USA"    &lt;-- A single Simple Value --&gt;
 +
=sergey    &lt;-- An Entity --&gt;
 +
=drummond    &lt;-- An Entity --&gt;
 +
</pre>
 +
=== Hash I-Numbers for Simple Values  ===
 +
 
 +
On several occasions in this mapping, it is necessary to refer to individual Simple Values of a multi-valued Attribute. Since Simple Values in Higgins IdAS do not have persistent identifiers, a mechanism called "Hash I-Number" (HIN) is used. A HIN is an i-number that is deterministically calculated from a value, therefore acting as an index of that Value in an XDI inner graph.
 +
 
 +
This pseudocode can be used to calculate a HIN for a Simple Value:
 +
<pre>FUNCTION makeSimpleValueHin(simpleValue)
 +
 
 +
   String hin = "$value$hash$sha$256" + "!" + hex(sha256(simpleValue.lexical));
 
   RETURN hin;
 
   RETURN hin;
 
END
 
END
</pre>
+
</pre>  
 
+
Examples:  
Examples:
+
* "Sergey" becomes '''$value$hash$md5!ec57c08aec4b3c72a528e878f74685a7'''
+
* "Markus" becomes '''$value$hash$md5!181ff5eb6d184d261d6b28480110e599'''
+
* "markus.sabadello@gmail.com" becomes '''$value$hash$md5!194454ebac24196430b1af7b34818b9f'''
+
* "msabadello@parityinc.net" becomes '''$value$hash$md5!1aa08be613b3114ad3130a3826301825'''
+
* "markus@changedemail.com" '''$value$hash$md5!db92995b5fb9eaa3b986afbaaf1bf8a1'''
+
* "markus@newemail.com" becomes '''$value$hash$md5!8f1e543796229f56f8e55dd73a9ac09a'''
+
  
=== Hash I-Numbers for Complex Values ===
+
*"Sergey" becomes '''$value$hash$sha$256!f3357799ddcf994ae4d759e37d58c29938419f5af9681ae65a6f0f1677b213b7'''
 +
*"Markus" becomes '''$value$hash$sha$256!f00b1896cf1c0569b9bdcfdde4ed948a266bae9707b3567240211efc8ffc06a0'''
 +
*"+1 (617) 513 7924" becomes '''$value$hash$sha$256!e5754ab606a4f0d6a3570d2c37c1f75643b9eefccf8e66e27ec77499bea8ae1d'''
 +
*"+1 (781) 559 0153" becomes '''$value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca'''
  
Hash I-Numbers are also used to refer to individual Complex Values of a multi-valued Attribute. Like with Simple Values, HINs for Complex Values are also calculated from the value and can then be used as an index of that value in the multi-valued Attribute.
+
=== Hash I-Numbers for Complex Values ===
  
This pseudocode can be used to calculate a HIN for a Complex Value:
+
Hash I-Numbers are also used to refer to individual Complex Values. Like with Simple Values, HINs for Complex Values are calculated from the Value and can then be used as an index of that Value in an XDI inner graph.
  
<pre>
+
This pseudocode can be used to calculate a HIN for a Complex Value:
FUNCTION makeComplexHin(complexValue):
+
<pre>FUNCTION makeComplexValueHin(complexValue):
  
   String hin = "$value$hash$md5" + "!" + hex(md5(makeComplexString(complexValue)));
+
   String hin = "$value$hash$sha$256" + "!" + hex(sha256(makeComplexString(complexValue)));
 
   RETURN hin;
 
   RETURN hin;
 
END
 
END
  
FUNCTION makeComplexString(complexValue):
+
FUNCTION makeComplexValueString(complexValue):
  
 
   String buffer = "";
 
   String buffer = "";
   Set attributeIdStrings;  # a set of strings representing the attribute ids of this complex value
+
   Set attributeIds;  # a set of strings representing the attribute ids of this complex value
  
 
   FOR EACH attribute IN complexValue.attributes
 
   FOR EACH attribute IN complexValue.attributes
  
     attibuteIdStrings.push(attribute.attributeId)
+
     attibuteIds.push(attrIdToXri(attribute.attributeId))
 
   END
 
   END
  
   FOR EACH attributeId IN sort(attributeIdStrings)
+
   FOR EACH attributeId IN sort(attributeIds)
  
 
     buffer += attributeId + ' ';
 
     buffer += attributeId + ' ';
 
     Set simpleValuesStrings;  # a set of strings representing the simple values of this complex value
 
     Set simpleValuesStrings;  # a set of strings representing the simple values of this complex value
 
     Set complexValuesStrings;  # a set of strings representing the complex values of this complex value
 
     Set complexValuesStrings;  # a set of strings representing the complex values of this complex value
 +
 +
    Attribute attribute = complexValue.getAttribute(attributeId)
  
 
     FOR EACH value IN attribute.values
 
     FOR EACH value IN attribute.values
  
 
       IF value.isSimple THEN
 
       IF value.isSimple THEN
         simpleValuesStrings.push('"' + value.string '"' + ' ')
+
         simpleValuesStrings.push('"' + value.lexical + '"' + ' ')
 
       ELSE IF value.isComplex THEN
 
       ELSE IF value.isComplex THEN
         complexValuesStrings.push(makeString(value) + ' ')
+
         complexValuesStrings.push(makeComplexValueString(value) + ' ')
 
       END IF
 
       END IF
 
     END FOR
 
     END FOR
Line 85: Line 163:
 
   RETURN buffer;
 
   RETURN buffer;
 
END
 
END
</pre>
+
</pre>  
 +
Examples:
  
Example: =john has a multi-valued attribute (+postalAddress), which has four values. One of the values is simple, the other three are complex.
+
*For the second Value of '''+address''',  
<pre>
+
**the result of the makeComplexValueString() function is '''+city{space}"Needham"{space}+state{space}"MA"{space}+street{space}"56 Kearney Rd"{space}+zip{space}"02494"{space}'''
=john
+
**the result of the makeComplexValueHin() function is '''$value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715'''
  +postalAddress
+
      /
+
        $value$hash$md5!b4d9a5f38ce519a8729e6bbdc1a6534d <-- a simple value -->
+
            +postalAddress
+
              "56 Kearney Rd, Needham, Massachusetts 02494, USA"
+
        $value$hash$md5!e81bac14f8e5325069f073d041fcea91 <-- a complex value with 1. one single-valued attribute with a simple values and 2. another single-valued attribute with a simple value -->
+
            +city
+
              "city1"
+
            +street
+
              "street1"
+
        $value$hash$md5!2927f4236679e036f538d3e9192f0aa5 <-- a complex value with 1. one multi-valued attribute with three simple values -->
+
            +line
+
              /
+
                  $value$hash$md5!a01ee22ed620d62bbc7b7fddc601d476
+
                    +line
+
                        "56 Kearney Rd"
+
                  $value$hash$md5!8e2963142c6d04c390d2d16a5eca677b
+
                    +line
+
                        "Needham, Massachusetts 02494"
+
                  $value$hash$md5!f75d91cdd36b85cc4a8dfeca4f24fa14
+
                    +line
+
                        "USA"
+
        $value$hash$md5!42b760f5b62b7e9744405a5c6861e133 <-- a complex value with 1. one single-valued attribute with a simple value and 2. one single-valued attribute with a complex value -->
+
            +city
+
              "Needham"
+
            +street
+
              /
+
                  $value$hash$md5!3fe088f4ec17188cd7002e1f36a55495
+
                    +streetnumber
+
                        "56"
+
                    +streetname
+
                        "Kearney Rd"
+
</pre>
+
  
* For the first value (simple value),
+
*For the third Value of '''+address''',  
** the result of the makeSimpleHin() function is '''$value$hash$md5!b4d9a5f38ce519a8729e6bbdc1a6534d'''
+
**the result of the makeComplexString() function is '''+country{space}"USA"{space}+line{space}"56 Kearney Rd"{space}"Needham, Massachusetts 02494"{space}'''  
* For the second value (complex value),  
+
**the result of the makeComplexHin() function is '''$value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324'''
** the result of the makeComplexString() function is '''+city "city1" +street "street1" '''
+
** the result of the makeComplexHin() function is '''$value$hash$md5!e81bac14f8e5325069f073d041fcea91'''
+
* For the third value (complex value),
+
** the result of the makeComplexString() function is '''+line "56 Kearney Rd" "Needham, Massachusetts 02494" "USA" '''
+
** the result of the makeComplexHin() function is '''$value$hash$md5!2927f4236679e036f538d3e9192f0aa5'''
+
* For the fourth value (complex value),
+
** the result of the makeComplexString() function is '''+city "Needham" +street +streetname "Kearney Rd" +streetnumber "56"  ''',
+
** the result of the makeComplexHin() function is '''$value$hash$md5!42b760f5b62b7e9744405a5c6861e133'''
+
  
Note that this mechanism is only used for Complex Values without an Entity ID.
+
== Test endpoints  ==
  
== Mappings ==
+
The following XDI endpoints are available for testing:
  
Using IdAS, a Higgins context can be opened, and operations can be performed on it. The equivalent in XDI is XDI messages (which contain XDI operations).
+
=== IdAS Attribute Service  ===
  
All XDI examples are in the X3 Simple serialization format. See [http://wiki.oasis-open.org/xdi/X3Format X3Format] for more information about X3 serialization formats.
+
*http://graceland.parityinc.net/xdi-idas/context-inmem: Attribute Service exposing a '''higgins.idas.cp.inmem''' Context. ''Note:'' The inmem CP does not support listing all Entities.
 +
*http://graceland.parityinc.net/xdi-idas/context-xmlfile: Attribute Service exposing a '''higgins.idas.cp.xmlfile''' Context.
 +
*http://graceland.parityinc.net/xdi-idas/context-ldap: Attribute Service exposing a '''higgins.idas.cp.jndi''' Context. ''Note:'' The Context is Parity's LDAP server at ldap://graceland.parityinc.net:389.
 +
*http://graceland.parityinc.net/xdi-idas/context-rdf: Attribute Service exposing a '''higgins.idas.cp.rdf''' Context. ''Note:'' The Context is the RDF document at http://graceland.parityinc.net/~msabadello/rdf/test.rdf. This CP is read-only.
  
=== Entities ===
+
=== Native XDI Endpoints  ===
  
==== List all Entities in the Context ====
+
*http://graceland.parityinc.net/xdi-endpoint/mem-graph-hin: '''Native XDI endpoint''' with HIN support enabled. Backed by an in-memory store.
 +
*http://graceland.parityinc.net/xdi-endpoint/bdb-graph-hin: '''Native XDI endpoint''' with HIN support enabled. Backed by a Berkely DB store.
  
[[IdAS]] calls:
+
== Operations  ==
  
<pre>
+
Using IdAS, a Higgins context can be opened, and operations can be performed on it. The equivalent in XDI is XDI messages (which contain XDI operations).
Iterator<Entity> entities = context.getEntities(null);
+
</pre>
+
  
Message sent by the [[XDI Context Provider]] to <url>:
+
All XDI examples are in the X3 Simple serialization format. See [http://wiki.oasis-open.org/xdi/X3Format X3Format] for more information about X3 serialization formats.
  
<pre>
+
=== Entities  ===
=sender
+
$get
+
</pre>
+
  
Reply from the XDI endpoint:
+
==== List all Entities  ====
  
<pre>
+
This example gets all Entities in the Context.  
=markus <-- one entity in the context -->
+
+(http://www.example.com/name)
+
/
+
$!da649486d19f8cc02350447179637cba604eff46
+
+(http://www.example.com/name)
+
"Markus"
+
+(http://www.example.com/location)
+
/
+
$!8b6cea61d247482e9e7f1e7efb1db432a69bbcb2
+
+(http://www.example.com/location)
+
"Vienna"
+
+(http://www.example.com/email)
+
/
+
$!546de0b559ddcdb45983fd901f8d665ecc795e6e
+
+(http://www.example.com/email)
+
"markus.sabadello@gmail.com"
+
$!710e4214a22c1840fc7a829b1c3fd32375e9efca
+
+(http://www.example.com/email)
+
"msabadello@parityinc.net"
+
=sergey <-- another entity in the context -->
+
+(http://www.example.com/name)
+
/
+
$!11cac773045ffc189fa2e3ed232843d363d019c6
+
+(http://www.example.com/name)
+
"Sergey"
+
</pre>
+
  
==== Get one Entity from the Context ====
+
[[IdAS]] calls:  
 
+
<pre>Iterator&lt;Entity&gt; entities = context.getEntities(null);
[[IdAS]] calls:
+
</pre>  
 
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:  
<pre>
+
<pre>=sender
IEntity entity = context.getEntity("=markus");
+
</pre>
+
 
+
Message sent by the [[XDI Context Provider]] to <url>:
+
 
+
<pre>
+
=sender
+
 
$get
 
$get
/
+
</pre>
=markus
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint:
</pre>
+
<pre>=paul
 +
=sergey
 +
=drummond
 +
</pre>  
 +
==== Get one Entity from the Context  ====
  
Reply from the XDI endpoint:
+
This example gets the Entity '''=paul''' in the Context.
  
<pre>
+
[[IdAS]] calls:
=markus
+
<pre>IEntity entity = context.getEntity("=paul");
+(http://www.example.com/name)
+
</pre>
/
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
$!da649486d19f8cc02350447179637cba604eff46
+
<pre>=sender
+(http://www.example.com/name)
+
  $get$a$xsd$boolean
"Markus"
+
      /
+(http://www.example.com/location)
+
        =paul
/
+
</pre>
$!8b6cea61d247482e9e7f1e7efb1db432a69bbcb2
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint:
+(http://www.example.com/location)
+
<pre>$true
"Vienna"
+
</pre>  
+(http://www.example.com/email)
+
==== Remove an Entity from the Context  ====
/
+
$!546de0b559ddcdb45983fd901f8d665ecc795e6e
+
+(http://www.example.com/email)
+
"markus.sabadello@gmail.com"
+
$!710e4214a22c1840fc7a829b1c3fd32375e9efca
+
+(http://www.example.com/email)
+
"msabadello@parityinc.net"
+
</pre>
+
  
==== Remove an Entity from the Context ====
+
This example removes Entity '''=paul''' from the Context.
  
[[IdAS]] calls:
+
[[IdAS]] calls:  
 
+
<pre>IEntity entity = context.getEntity("=paul");
<pre>
+
IEntity entity = context.getEntity("=markus");
+
 
entity.remove();
 
entity.remove();
</pre>
+
context.applyUpdates();
 +
</pre>  
 +
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $del
 +
      /
 +
        =paul
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
Message sent by the [[XDI Context Provider]] to <url>:
+
=== Attributes  ===
  
<pre>
+
==== List all Attributes from an Entity  ====
=sender
+
$del
+
/
+
=markus
+
</pre>
+
  
Reply from the XDI endpoint: (none)
+
This example gets all Attributes of the Entity '''=paul'''.
  
=== Attributes ===
+
[[IdAS]] calls:
 +
<pre>IEntity entity = context.getEntity("=paul");
 +
Iterator&lt;IAttribute&gt; attributes = entity.getAttributes();
 +
</pre>
 +
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $get
 +
      /
 +
        =paul
 +
</pre>
 +
*After sending the message, the XDI CP remembers the HINs of the individual values, in order to be able to refer to them later
  
==== Get one Attribute from an Entity ====
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint:
 +
<pre>=paul
 +
  +name
 +
  +friend
 +
  +phone
 +
  +address
 +
</pre>
 +
==== Get one Attribute from an Entity ====
  
[[IdAS]] calls:
+
This example gets the Attribute '''+phone''' of the Entity '''=paul'''.
  
<pre>
+
[[IdAS]] calls:
IEntity entity = context.getEntity("=markus");
+
<pre>IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute("http://www.example.com/name");
+
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
</pre>
+
</pre>  
 +
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $get$a$xsd$boolean
 +
      /
 +
        =paul
 +
            +phone
 +
</pre>
 +
*After sending the message, the XDI CP remembers the HINs of the individual values, in order to be able to refer to them later
  
Message sent by the [[XDI Context Provider]] to <url>:
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint:
 +
<pre>$true
 +
</pre>
 +
==== Remove an Attribute from an Entity  ====
  
<pre>
+
This example removes the Attribute '''+phone''' from the Entity '''=paul'''.  
=sender
+
$get
+
/
+
=markus
+
+(http://www.example.com/name)
+
</pre>
+
  
Reply from the XDI endpoint:
+
[[IdAS]] calls:
 +
<pre>IEntity entity = context.getEntity("=paul");
 +
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
 +
attribute.remove();
 +
context.applyUpdates();
 +
</pre>
 +
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $del
 +
      /
 +
        =paul
 +
            +phone
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
<pre>
+
=== Values  ===
=markus
+
+(http://www.example.com/name)
+
/
+
$!da649486d19f8cc02350447179637cba604eff46
+
+(http://www.example.com/name)
+
"Markus"
+
</pre>
+
  
==== Remove an Attribute from an Entity ====
+
==== List all Values from an Attribute ====
  
[[IdAS]] calls:
+
This example gets all Values of the Attribute '''+phone''' on the Entity '''=paul'''.
  
<pre>
+
[[IdAS]] calls:
IEntity entity = context.getEntity("=markus");
+
<pre>IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/name"));
+
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
attribute.remove();
+
Iterator&lt;IAttributeValue&gt; values = attribute.getValues();
</pre>
+
</pre>  
 +
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $get
 +
      /
 +
        =paul
 +
            +phone
 +
</pre>
 +
*After sending the message, the XDI CP remembers the HINs of the individual values, in order to be able to refer to them later
  
Message sent by the [[XDI Context Provider]] to <url>:
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint:
 +
<pre>=paul
 +
  +phone
 +
      /
 +
        $value$hash$sha$256!e5754ab606a4f0d6a3570d2c37c1f75643b9eefccf8e66e27ec77499bea8ae1d    &lt;-- First Value of +phone: A Simple Value --&gt;
 +
            $value
 +
              "+1 (617) 513 7924"
 +
        $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca    &lt;-- Second Value of +phone: A Simple Value --&gt;
 +
            $value
 +
              "+1 (781) 559 0153"
 +
</pre>
 +
<br>
  
<pre>
+
=== Simple Values  ===
=sender
+
$del
+
/
+
=markus
+
+(http://www.example.com/name)
+
</pre>
+
  
Reply from the XDI endpoint: (none)
+
==== Remove a Simple Value from an Attribute  ====
  
=== Simple Values ===
+
This example removes the Simple Value '''+1 (781) 559 0153''' from the Attribute '''+phone''' on the Entity '''=paul'''.
  
==== Remove a Simple Value from an Attribute ====
+
[[IdAS]] calls:  
 
+
<pre>IEntity entity = context.getEntity("=paul");
[[IdAS]] calls:
+
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
 
+
ISimpleAttrValue value = (ISimpleAttrValue) attribute.getValues().next().next(); // value is "+1 (781) 559 0153"
<pre>
+
IEntity entity = context.getEntity("=markus");
+
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/email"));
+
IAttributeValue value = attribute.getValues().next().next(); // value is "msabadello@parityinc.net"
+
 
value.remove();
 
value.remove();
</pre>
+
context.applyUpdates();
 +
</pre>  
 +
*Before sending the message, the XDI CP calculates the HIN of the value (if it does not know it already)
  
Message sent by the [[XDI Context Provider]] to <url>:
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $del
 +
      /
 +
        =paul
 +
            +phone
 +
              /
 +
                  $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca &lt;-- HIN of +1 (781) 559 0153 --&gt;
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
<pre>
+
==== Modify a Simple Value of an Attribute  ====
=sender
+
$del
+
/
+
=markus
+
+(http://www.example.com/email)
+
/
+
$!710e4214a22c1840fc7a829b1c3fd32375e9efca <-- HIN of msabadello@parityinc.net -->
+
</pre>
+
  
Reply from the XDI endpoint: (none)
+
This example changes the Simple Value '''+1 (781) 559 0153''' to '''+1 234 56789''' on the Attribute '''+phone''' on the Entity '''=paul'''.
  
==== Change a Simple Value of an Attribute ====
+
[[IdAS]] calls:
 +
<pre>IEntity entity = context.getEntity("=paul");
 +
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
 +
ISimpleAttrValue value = (ISimpleAttrValue) attribute.getValues().next().next(); // value is "+1 (781) 559 0153"
 +
value.setData("+1 234 56789");
 +
context.applyUpdates();
 +
</pre>
 +
*Before sending the message, the XDI CP calculates the HIN of the value (if it does not know it already)
 +
*After sending the message, the XDI CP re-calculates the HIN of the value, in order to be able to refer to it later
  
[[IdAS]] calls:
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:  
 +
<pre>=sender
 +
  $mod
 +
      /
 +
        =paul
 +
            +phone
 +
              /
 +
                  $value$hash$sha$256!$!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca &lt;-- HIN of +1 (781) 559 0153 --&gt;
 +
                    $value
 +
                        "+1 234 56789"
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
<pre>
+
==== Add a Simple Value to an Attribute  ====
IEntity entity = context.getEntity("=markus");
+
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/email"));
+
Iterator<IAttributeValue> values = (Iterator<IAttributeValue>) attribute.getValues();
+
IAttributeValue value = values.next(); // current value is "markus.sabadello@gmail.com"
+
((ITypedValue) value).setData("markus@changedemail.com");
+
</pre>
+
  
Message sent by the [[XDI Context Provider]] to <url>:
+
This example adds the Simple Value '''+1 987 65432''' to the Attribute '''+phone''' on the Entity '''=paul'''.
  
<pre>
+
[[IdAS]] calls:
=sender
+
<pre>IEntity entity = context.getEntity("=paul");
$del
+
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
/
+
ISimpleAttrValue value = attribute.addSimpleValue(ITypedValue.STRING_TYPE_URI, "+1 987 65432");
=markus
+
context.applyUpdates();
+(http://www.example.com/email)
+
</pre>  
/
+
*Before sending the message, the XDI CP calculates the HIN of the value
$!546de0b559ddcdb45983fd901f8d665ecc795e6e <-- HIN of markus.sabadello@gmail.com -->
+
$add
+
/
+
=markus
+
+(http://www.example.com/email)
+
/
+
$!6ea54708b267b24988beca6adc34c4e79ed0a0b5 <-- HIN of markus@changedemail.com -->
+
+(http://www.example.com/email)
+
"markus@changedemail.com"
+
</pre>
+
  
Reply from the XDI endpoint: (none)
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $add
 +
      /
 +
        =paul
 +
            +phone
 +
              /
 +
                  $value$hash$sha$256!bb4d1ce368e89f0f5c4bfb867cd4b0437eadfa7aa559f9b49bf359bc5903a282 &lt;-- HIN of +1 987 65432 --&gt;
 +
                    $value
 +
                        "+1 987 65432"
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)  
  
==== Add a Simple Value to an Attribute ====
+
=== Complex Values  ===
  
[[IdAS]] calls:
+
==== Remove a Complex Value from an Attribute  ====
  
<pre>
+
This example removes a Complex Value from the Attribute '''+address''' on the Entity '''=paul'''.  
IEntity entity = context.getEntity("=markus");
+
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/email"));
+
attribute.addSimpleValue(new URI(""), "markus@newemail.com");
+
</pre>
+
  
Message sent by the [[XDI Context Provider]] to <url>:
+
[[IdAS]] calls:
 +
<pre>IEntity entity = context.getEntity("=paul");
 +
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
 +
ISimpleAttrValue value = (ISimpleAttrValue) attribute.getValues().next().next(); // second value
 +
value.remove();
 +
context.applyUpdates();
 +
</pre>
 +
*Before sending the message, the XDI CP calculates the HIN of the value (if it does not know it already)
  
<pre>
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
=sender
+
<pre>=sender
$add
+
  $del
/
+
      /
=markus
+
        =paul
+(http://www.example.com/email)
+
            +address
/
+
              /
$!690e082dc615d636abdaae2b066bdbf7e2b70057 <-- HIN of markus@newemail.com -->
+
                  $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715 &lt;-- HIN of a complex value --&gt;
+(http://www.example.com/email)
+
</pre>  
"markus@newemail.com"
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)  
</pre>
+
  
Reply from the XDI endpoint: (none)
+
==== Add a Complex Value to an Attribute (Example 1) ====
  
=== Complex Values ===
+
This example adds a Complex Value to the Attribute '''+address''' on the Entity '''=paul'''. The Complex Value has four Attributes.
  
==== Remove a Complex Value from an Attribute ====
+
[[IdAS]] calls:
 +
<pre>IEntity entity = context.getEntity("=paul");
 +
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
 +
IComplexAttrValue value = attribute.addComplexValue(URI.create(BasicComplexValue.ATTR_VALUE_TYPE_URI_STR)));
 +
IAttribute subAttributeCity = value.addAttribute(URI.create("xri://+city"));
 +
IAttribute subAttributeState = value.addAttribute(URI.create("xri://+state"));
 +
IAttribute subAttributeStreet = value.addAttribute(URI.create("xri://+street"));
 +
IAttribute subAttributeZip = value.addAttribute(URI.create("xri://+zip"));
 +
subAttributeCity.addSimpleValue(ITypedValue.STRING_TYPE_URI, "Needham");
 +
subAttributeState.addSimpleValue(ITypedValue.STRING_TYPE_URI, "MA");
 +
subAttributeStreet.addSimpleValue(ITypedValue.STRING_TYPE_URI, "56 Kearney Rd");
 +
subAttributeZip.addSimpleValue(ITypedValue.STRING_TYPE_URI, "02494");
 +
context.applyUpdates();
 +
</pre>
 +
*Before sending the message, the XDI CP calculates the HIN of the values, in order to be able to refer to them later
  
[[IdAS]] calls:
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:  
 +
<pre>=sender
 +
  $add
 +
      /
 +
        =paul
 +
            +address
 +
              /
 +
                  $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715
 +
                    +city
 +
                        "Needham"
 +
                    +street
 +
                        "56 Kearney Rd"
 +
                    +state
 +
                        "MA"
 +
                    +zip
 +
                        "02494"
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
<pre>
+
==== Add a Complex Value to an Attribute (Example 2) ====
IEntity entity = context.getEntity("=markus");
+
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/friend"));
+
IAttributeValue value = attribute.getValues().next(); // value is "=sergey"
+
value.remove();
+
</pre>
+
  
Message sent by the [[XDI Context Provider]] to <url>:
+
This example adds a Complex Value to the Attribute '''+address''' on the Entity '''=paul'''. The Complex Value has two Attributes.
  
<pre>
+
[[IdAS]] calls:
=sender
+
<pre>IEntity entity = context.getEntity("=paul");
$del
+
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
/
+
IComplexAttrValue value = attribute.addComplexValue(URI.create(BasicComplexValue.ATTR_VALUE_TYPE_URI_STR)));
=markus
+
IAttribute subAttributeLine = value.addAttribute(URI.create("xri://+line"));
+(http://www.example.com/friend)
+
IAttribute subAttributeCountry = value.addAttribute(URI.create("xri://+country"));
=sergey
+
subAttributeLine.addSimpleValue(ITypedValue.STRING_TYPE_URI, "Needham, Massachusetts 02494");
</pre>
+
subAttributeLine.addSimpleValue(ITypedValue.STRING_TYPE_URI, "56 Kearney Rd");
 +
subAttributeCountr.addSimpleValue(ITypedValue.STRING_TYPE_URI, "USA");
 +
context.applyUpdates();
 +
</pre>  
 +
*Before sending the message, the XDI CP calculates the HIN of the values, in order to be able to refer to them later
  
Reply from the XDI endpoint: (none)
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $add
 +
      /
 +
        =paul
 +
            +address
 +
              /
 +
                  $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324
 +
                    +line
 +
                        /
 +
                          $value$hash$sha$256!d27ef0bac9a6830121ebc30cd911fa9672a28fa8e8bd5d63ae3ade11af519d32
 +
                              $value
 +
                                "Needham, Massachusetts 02494"
 +
                          $value$hash$sha$256!4e8ae563672c68cb1533ae16993a693033f1a9032e43893c3464956b8ec2109c
 +
                              $value
 +
                                "56 Kearney Rd"
 +
                    +country
 +
                        "USA"
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)  
  
==== Add a Complex Value to an Attribute ====
+
==== Modify a Simple Value of a Complex Value (Example 1)  ====
  
[[IdAS]] calls:
+
This example changes the Simple Value '''MA''' to '''Massachusetts''' on the Attribute '''+state''' on the second Value of the Attribute '''+address''' on the Entity '''=paul'''.
  
<pre>
+
[[IdAS]] calls:
IEntity entity = context.getEntity("=markus");
+
<pre>IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/friend"));
+
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
attribute.addComplexValue(new URI(""));
+
IComplexAttrValue value = (IComplexAttrValue) attribute.getValues().next().next(); // second value of +address
/* ... */
+
IAttribute subAttribute = value.getAttribute(URI.create("xri://+state"));
</pre>
+
ISimpleAttrValue subValue = (ISimpleAttrValue) subAttribute.getValues().next(); // value is "MA"
 +
value.setData("Massachusetts");
 +
context.applyUpdates();
 +
</pre>  
 +
*Before sending the message, the XDI CP calculates the HIN of the values (if it does not know them already)
 +
*After sending the message, the XDI CP re-calculates the HIN of the values, in order to be able to refer to them later
  
Message sent by the [[XDI Context Provider]] to <url>:
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:
 +
<pre>=sender
 +
  $mod
 +
      /
 +
        =paul
 +
            +address
 +
              /
 +
                  $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715 &lt;-- HIN of second value of +address --&gt;
 +
                    +state
 +
                        "Massachusetts"
 +
</pre>
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
<pre>
+
==== Modify a Simple Value of a Complex Value (Example 2) ====
=sender
+
$add
+
/
+
=markus
+
+(http://www.example.com/friend)
+
=sergey
+
</pre>
+
  
Reply from the XDI endpoint: (none)
+
This example changes the Simple Value '''Needham, Massachusetts 02494''' to '''Needham, MA 02494''' on the Attribute '''+line''' on the third Value of the Attribute '''+address''' on the Entity '''=paul'''.
  
=== Miscellaneous ===
+
[[IdAS]] calls:
 +
<pre>IEntity entity = context.getEntity("=paul");
 +
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
 +
IComplexAttrValue value = (IComplexAttrValue) attribute.getValues().next().next().next(); // third value of +address
 +
IAttribute subAttribute = value.getAttribute(URI.create("xri://+line"));
 +
ISimpleAttrValue subValue = (ISimpleAttrValue) subAttribute.getValues().next(); // value is "Needham, Massachusetts 02494"
 +
value.setData("Needham, MA 02494");
 +
context.applyUpdates();
 +
</pre>
 +
*Before sending the message, the XDI CP calculates the HIN of the values (if it does not know them already)
 +
*After sending the message, the XDI CP re-calculates the HIN of the values, in order to be able to refer to them later
  
==== Get the schema of the Context ====
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:  
 
+
<pre>=sender
[[IdAS]] calls:
+
  $mod
 
+
      /
<pre>
+
        =paul
String schema = IContext.getSchema();
+
            +address
</pre>
+
              /
 +
                  $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324 &lt;-- HIN of third value of +address --&gt;
 +
                    +line
 +
                        /
 +
                          $value$hash$sha$256!d27ef0bac9a6830121ebc30cd911fa9672a28fa8e8bd5d63ae3ade11af519d32 &lt;-- HIN of Needham, Massachusetts 02494 --&gt;
 +
                              $value
 +
                                "Needham, MA 02494"
 +
</pre>  
 +
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint: (none)
  
Schema support in IdAS maps to XDI dictionary statements.
+
== Miscellaneous  ==
  
'''TODO'''
+
=== Get the schema of the Context  ===
  
==== Get Context Relations and Context Correlations ====
+
[[IdAS]] calls:
 +
<pre>String schema = IContext.getSchema();
 +
</pre>
 +
Schema support in IdAS maps to XDI dictionary statements.
  
[[IdAS]] calls:
+
'''TODO'''
  
<pre>
+
=== Get Context Relations and Context Correlations  ===
IContext.getRelationships()
+
</pre>
+
  
'''TODO'''
+
[[IdAS]] calls:
 +
<pre>IContext.getRelationships()
 +
</pre>
 +
'''TODO'''  
  
==== Authentication ====
+
=== Authentication ===
  
The Higgins authentication materials needed to open an XDI context are:
+
The Higgins authentication materials needed to open an XDI context are:  
* A Sender XRI (i-name or i-number)
+
* A Private Key which is used to sign all messages
+
  
Example:
+
*A Sender XRI (i-name or i-number)
 +
*A Private Key which is used to sign all messages
  
<pre>
+
Example:
=sender
+
<pre>=sender
 
$get
 
$get
 
/
 
/
=markus
+
=paul
+(http://www.example.com/name)
+
+address
 
$sig$rsa
 
$sig$rsa
 
"bCbYq6EN26N1hdJTtrjvHw05X+MtNzyFKuyPMoEX/nHxzotTAlGDfHqGuUGMgWIrAtFBkre+bbrUA07gjb6do8kr5OsmOKYvfEi/rxnbEhlEPfISEP5/SWJ8auc+W8E6TOPK2bBTxTrt4+5JGIE4TjiP1IZe9l85rqOmeAY5TLZkFzxGanD01Jf4EbB8qDdNjVsQSZgW0zcqyAdi7/quqTLesxLM9m340doFdHhJxW0cdVLS5CjBU67TR1uDSMEfMpqQhEp8qfQaD/0dUif5Wr5/q+L8nz9BsBQ9tzfFhUSATYMaL1whNNWHEpoO/OGKQPADv/PJbsbN7T3dwyjlBA=="
 
"bCbYq6EN26N1hdJTtrjvHw05X+MtNzyFKuyPMoEX/nHxzotTAlGDfHqGuUGMgWIrAtFBkre+bbrUA07gjb6do8kr5OsmOKYvfEi/rxnbEhlEPfISEP5/SWJ8auc+W8E6TOPK2bBTxTrt4+5JGIE4TjiP1IZe9l85rqOmeAY5TLZkFzxGanD01Jf4EbB8qDdNjVsQSZgW0zcqyAdi7/quqTLesxLM9m340doFdHhJxW0cdVLS5CjBU67TR1uDSMEfMpqQhEp8qfQaD/0dUif5Wr5/q+L8nz9BsBQ9tzfFhUSATYMaL1whNNWHEpoO/OGKQPADv/PJbsbN7T3dwyjlBA=="
</pre>
+
</pre>  
 +
=== Access control  ===
  
==== Access control ====
+
Access control in IdAS maps to XDI link contracts.
  
Access control in IdAS maps to XDI link contracts.
+
'''TODO'''
  
'''TODO'''
+
=== Notifications  ===
  
==== Notifications ====
+
Notification support in IdAS maps to XDI links contracts.
  
Notification support in IdAS maps to XDI links contracts.
+
'''TODO'''
  
'''TODO'''
+
=== Filters  ===
  
==== Filters ====
+
Filter support in IdAS maps to XDI queries.
  
Filter support in IdAS maps to XDI queries.
+
On the OASIS XDI TC there was a proposal for an XDI query language. The idea is simple: You send a $get and replace everything you don't know with $$. So if you want to have all attributes with a name attribute that has a value of "Sergey", you would do:
  
On the OASIS XDI TC there was a proposal for an XDI query language. The idea is simple: You send a $get and replace everything you don't know with $$. So if you want to have all attributes with a name attribute that has a value of "Sergey", you would do:
+
Message sent by the [[Org.eclipse.higgins.idas.cp.xdi|XDI CP]]:  
 
+
<pre>=sender
Message sent by the [[XDI Context Provider]] to <url>:  
+
 
+
<pre>
+
=sender
+
 
     $get
 
     $get
 
         /
 
         /
             $$  <-- we don't know the subject -->
+
             $$  &lt;-- we don't know the subject --&gt;
 
                 +(http://www.example.com/name)
 
                 +(http://www.example.com/name)
 
                     /
 
                     /
 
                         $$
 
                         $$
                             +(http://www.example.com/name)
+
                             $value
 
                                 "Sergey"
 
                                 "Sergey"
</pre>
+
</pre>  
 
+
Reply from the [[Org.eclipse.higgins.as|Attribute Service]] / native XDI endpoint:  
Reply from the XDI endpoint:
+
<pre>=sergey    &lt;-- that's what matched the $$ --&gt;
 
+
<pre>
+
=sergey    <-- that's what matched the $$ -->
+
 
     +(http://www.example.com/name)
 
     +(http://www.example.com/name)
 
         /
 
         /
 
             $!11cac773045ffc189fa2e3ed232843d363d019c6
 
             $!11cac773045ffc189fa2e3ed232843d363d019c6
                 +(http://www.example.com/name)
+
                 $value
 
                     "Sergey"
 
                     "Sergey"
</pre>
+
</pre>  
 
+
This can be tested with the [http://graceland.parityinc.net/xdi-querier/XDIQuerier XDI Querier].  
This can be tested with the [http://graceland.parityinc.net/xdi-querier/XDIQuerier XDI Querier].
+
  
== Links ==
+
== Links ==
  
* [http://eclipse.org/higgins Higgins Home]
+
*[http://www.oasis-open.org/committees/download.php/27004/xdi-rdf-model-v8.pdf The XDI RDF Model] is the current OASIS TC proposal for an RDF-based data model and addressing format for XDI. This document includes the proposed XDI RDF schema and a number of examples of XDI documents. (Note that it does not yet include the proposed XDI messaging format, which uses XDI documents as message envelopes for other XDI documents.)  
* [http://www.oasis-open.org/committees/download.php/27004/xdi-rdf-model-v8.pdf The XDI RDF Model] is the current OASIS TC proposal for an RDF-based data model and addressing format for XDI. This document includes the proposed XDI RDF schema and a number of examples of XDI documents. (Note that it does not yet include the proposed XDI messaging format, which uses XDI documents as message envelopes for other XDI documents.)
+
*[http://wiki.oasis-open.org/xdi/ OASIS XDI TC Wiki]  
* [http://wiki.oasis-open.org/xdi/ OASIS XDI TC Wiki]
+
*[http://en.wikipedia.org/wiki/XDI Wikipedia page on XDI]
* [http://en.wikipedia.org/wiki/XDI Wikipedia page on XDI]
+

Latest revision as of 20:24, 9 August 2010

{{#eclipseproject:technology.higgins|eclipse_custom_style.css}}

Status

  • This document needs to be updated to show a representative Persona Data Model 2.0 data structure instead of the "made up" structure shown in the diagram below.
  • The endpoints are all broken at present (old parityinc, graceland links)

Introduction

This page documents the mapping between the Higgins Context Data Model (which is implemented by IdAS) and XDI. XDI ("XRI Data Interchange") is a data model and protocol for sharing, linking, and synchronizing data over the Internet ("structured web") and other networks using Extensible Resource Identifiers (XRIs). It is being developed by the OASIS XDI Technical Committee.

The Attribute Service exposes an IdAS Context at an XDI endpoint. It processes and applies incoming XDI messages.

The XDI CP implements an IdAS Context by sending XDI messages. These message can be sent either to an XDI endpoint exposed by the Attribute Service or to a native XDI endpoint.

Mapping

Concepts

Since the Higgins Data Model is based on RDF/OWL, and XDI is also based on RDF, the basic mapping is straightforward. However, some attention has to be paid to details.

A Higgins Context can be mapped to an XDI graph using the following rules:

  • An Entity maps to an XDI subject. The XDI subject's XRI is the Entity ID cast to an XRI.
  • An Attribute maps to an XDI predicate. The XDI predicate's XRI is the Attribute ID cast to an XRI.
  • In general, each Value of an Attribute maps to an XDI subject inside an XDI inner graph. The XDI subject's XRI is a HIN (Hash I-Number) calculated from the Value.
    • If the Value is a Simple Value, then the XDI subject in the XDI inner graph has a single XDI predicate with an XDI literal. The XDI predicate's XRI is the the special $value XDI predicate.
    • If the Value is a Complex Value, then the rules for mapping the Attributes of that Complex Value apply recursively, i.e. each Attribute of the Complex Value maps to an XDI predicate.
  • Special case 1: If an Attribute contains only a single Simple Value, then that Attribute does not need an inner graph. Instead the Value maps directly to an XDI literal on the XDI predicate that represents the Attribute.
  • Special case 2: If an Attribute is an Entity Relation, then that Attribute does not need an inner graph. Instead the Values map directly to XDI references on the XDI predicate that represents the Attribute.
  • An Entity Correlation maps to an XDI statement with the special $is XDI predicate
  • The type of an Entity maps to an XDI statement with the special $is$a XDI predicate
  • The type of a Value maps to an XDI statement with the special $is$a XDI predicate

Example

Example Context diagram:

IdAS XDI.png

Example Context description:

  • The Context has three Entities =paul, =sergey and =drummond.
  • =paul has an Attribute +name, which has a single Simple Value :"Paul T.".
  • =paul has an Entity Relation +friend to =sergey and =drummond.
  • =paul has an Attribute +phone, which has two Values:
    • The first Value is a Simple Value: "+1 (617) 513 7924".
    • The second Value is a Simple Value: "+1 (781) 559 0153".
  • =paul has an Attribute +address, which has three Values:
    • The first Value is a Simple Value: "56 Kearney Rd, Needham, Massachusetts 02494, USA".
    • The second Value is a Complex Value. It has four Attributes +street, +city, +state and +zip.
      • The first Attribute has a single Simple Value: "56 Kearney Rd".
      • The second Attribute has a single Simple Value: "Needham".
      • The third Attribute has a single Simple Value: "MA".
      • The fourth Attribute has a single Simple Value: "02494".
    • The third Value is a Complex Value. It has two Attributes +line and +country.
      • The first Attribute has two Values.
        • The first Value is a Simple Value: "56 Kearney Rd".
        • The second Value is a Simple Value: "Needham, Massachusetts 2494".
      • The second Attribute has a single Simple Value: "USA".

Example Context in XDI:

=paul     <-- An Entity -->
   +name     <-- A "Special Case 1" Attribute -->
      "Paul T."     <-- A single Simple Value -->
   +friend     <-- A "Special Case 2" Attribute -->
      =sergey     <-- An Entity Relation Value -->
      =drummond     <-- An Entity Relation Value -->
   +phone     <-- An Attribute with two Values -->
      /
         $value$hash$sha$256!e5754ab606a4f0d6a3570d2c37c1f75643b9eefccf8e66e27ec77499bea8ae1d     <-- First Value of +phone: A Simple Value -->
            $value
               "+1 (617) 513 7924"
         $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca     <-- Second Value of +phone: A Simple Value -->
            $value
               "+1 (781) 559 0153"
   +address     <-- An Attribute with three Values -->
      /
         $value$hash$sha$256!07e8c548c164ea1df063e85d13a5faa04ee2e3129b571ace4360c557ba506a9c     <-- First Value of +address: A Simple Value -->
            $value
               "56 Kearney Rd, Needham, Massachusetts 02494, USA"
         $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715     <-- Second Value of +address: A Complex Value with four Attributes -->
            +street     <-- A "Special Case 1" Attribute -->
               "56 Kearney Rd"     <-- A single Simple Value -->
            +city     <-- A "Special Case 1" Attribute -->
               "Needham"     <-- A single Simple Value -->
            +state     <-- A "Special Case 1" Attribute -->
               "MA"     <-- A single Simple Value -->
            +zip     <-- A "Special Case 1" Attribute -->
               "02494"     <-- A single Simple Value -->
         $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324     <-- Third Value of +address: A Complex Value with two Attributes -->
            +line     <-- An Attribute with two values -->
               /
                  $value$hash$sha$256!4e8ae563672c68cb1533ae16993a693033f1a9032e43893c3464956b8ec2109c     <-- First Value of +line: A Simple Value -->
                     $value
                        "56 Kearney Rd"
                  $value$hash$sha$256!d27ef0bac9a6830121ebc30cd911fa9672a28fa8e8bd5d63ae3ade11af519d32     <-- Second Value of +line: A Simple Value -->
                     $value
                        "Needham, Massachusetts 02494"
            +country     <-- A "Special Case 1" Attribute -->
               "USA"     <-- A single Simple Value -->
=sergey     <-- An Entity -->
=drummond     <-- An Entity -->

Hash I-Numbers for Simple Values

On several occasions in this mapping, it is necessary to refer to individual Simple Values of a multi-valued Attribute. Since Simple Values in Higgins IdAS do not have persistent identifiers, a mechanism called "Hash I-Number" (HIN) is used. A HIN is an i-number that is deterministically calculated from a value, therefore acting as an index of that Value in an XDI inner graph.

This pseudocode can be used to calculate a HIN for a Simple Value:

FUNCTION makeSimpleValueHin(simpleValue)

  String hin = "$value$hash$sha$256" + "!" + hex(sha256(simpleValue.lexical));
  RETURN hin;
END

Examples:

  • "Sergey" becomes $value$hash$sha$256!f3357799ddcf994ae4d759e37d58c29938419f5af9681ae65a6f0f1677b213b7
  • "Markus" becomes $value$hash$sha$256!f00b1896cf1c0569b9bdcfdde4ed948a266bae9707b3567240211efc8ffc06a0
  • "+1 (617) 513 7924" becomes $value$hash$sha$256!e5754ab606a4f0d6a3570d2c37c1f75643b9eefccf8e66e27ec77499bea8ae1d
  • "+1 (781) 559 0153" becomes $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca

Hash I-Numbers for Complex Values

Hash I-Numbers are also used to refer to individual Complex Values. Like with Simple Values, HINs for Complex Values are calculated from the Value and can then be used as an index of that Value in an XDI inner graph.

This pseudocode can be used to calculate a HIN for a Complex Value:

FUNCTION makeComplexValueHin(complexValue):

  String hin = "$value$hash$sha$256" + "!" + hex(sha256(makeComplexString(complexValue)));
  RETURN hin;
END

FUNCTION makeComplexValueString(complexValue):

  String buffer = "";
  Set attributeIds;  # a set of strings representing the attribute ids of this complex value

  FOR EACH attribute IN complexValue.attributes

    attibuteIds.push(attrIdToXri(attribute.attributeId))
  END

  FOR EACH attributeId IN sort(attributeIds)

    buffer += attributeId + ' ';
    Set simpleValuesStrings;  # a set of strings representing the simple values of this complex value
    Set complexValuesStrings;  # a set of strings representing the complex values of this complex value

    Attribute attribute = complexValue.getAttribute(attributeId)

    FOR EACH value IN attribute.values

      IF value.isSimple THEN
        simpleValuesStrings.push('"' + value.lexical + '"' + ' ')
      ELSE IF value.isComplex THEN
        complexValuesStrings.push(makeComplexValueString(value) + ' ')
      END IF
    END FOR

    buffer += concat(sort(simpleValuesStrings));
    buffer += concat(sort(complexValuesStrings));
  END FOR

  RETURN buffer;
END

Examples:

  • For the second Value of +address,
    • the result of the makeComplexValueString() function is +city{space}"Needham"{space}+state{space}"MA"{space}+street{space}"56 Kearney Rd"{space}+zip{space}"02494"{space}
    • the result of the makeComplexValueHin() function is $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715
  • For the third Value of +address,
    • the result of the makeComplexString() function is +country{space}"USA"{space}+line{space}"56 Kearney Rd"{space}"Needham, Massachusetts 02494"{space}
    • the result of the makeComplexHin() function is $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324

Test endpoints

The following XDI endpoints are available for testing:

IdAS Attribute Service

Native XDI Endpoints

Operations

Using IdAS, a Higgins context can be opened, and operations can be performed on it. The equivalent in XDI is XDI messages (which contain XDI operations).

All XDI examples are in the X3 Simple serialization format. See X3Format for more information about X3 serialization formats.

Entities

List all Entities

This example gets all Entities in the Context.

IdAS calls:

Iterator<Entity> entities = context.getEntities(null);

Message sent by the XDI CP:

=sender
	$get

Reply from the Attribute Service / native XDI endpoint:

=paul
=sergey
=drummond

Get one Entity from the Context

This example gets the Entity =paul in the Context.

IdAS calls:

IEntity entity = context.getEntity("=paul");

Message sent by the XDI CP:

=sender
   $get$a$xsd$boolean
      /
         =paul

Reply from the Attribute Service / native XDI endpoint:

$true

Remove an Entity from the Context

This example removes Entity =paul from the Context.

IdAS calls:

IEntity entity = context.getEntity("=paul");
entity.remove();
context.applyUpdates();

Message sent by the XDI CP:

=sender
   $del
      /
         =paul

Reply from the Attribute Service / native XDI endpoint: (none)

Attributes

List all Attributes from an Entity

This example gets all Attributes of the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
Iterator<IAttribute> attributes = entity.getAttributes();

Message sent by the XDI CP:

=sender
   $get
      /
         =paul
  • After sending the message, the XDI CP remembers the HINs of the individual values, in order to be able to refer to them later

Reply from the Attribute Service / native XDI endpoint:

=paul
   +name
   +friend
   +phone
   +address

Get one Attribute from an Entity

This example gets the Attribute +phone of the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));

Message sent by the XDI CP:

=sender
   $get$a$xsd$boolean
      /
         =paul
            +phone
  • After sending the message, the XDI CP remembers the HINs of the individual values, in order to be able to refer to them later

Reply from the Attribute Service / native XDI endpoint:

$true

Remove an Attribute from an Entity

This example removes the Attribute +phone from the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
attribute.remove();
context.applyUpdates();

Message sent by the XDI CP:

=sender
   $del
      /
         =paul
            +phone

Reply from the Attribute Service / native XDI endpoint: (none)

Values

List all Values from an Attribute

This example gets all Values of the Attribute +phone on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
Iterator<IAttributeValue> values = attribute.getValues();

Message sent by the XDI CP:

=sender
   $get
      /
         =paul
            +phone
  • After sending the message, the XDI CP remembers the HINs of the individual values, in order to be able to refer to them later

Reply from the Attribute Service / native XDI endpoint:

=paul
   +phone
      /
         $value$hash$sha$256!e5754ab606a4f0d6a3570d2c37c1f75643b9eefccf8e66e27ec77499bea8ae1d     <-- First Value of +phone: A Simple Value -->
            $value
               "+1 (617) 513 7924"
         $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca     <-- Second Value of +phone: A Simple Value -->
            $value
               "+1 (781) 559 0153"


Simple Values

Remove a Simple Value from an Attribute

This example removes the Simple Value +1 (781) 559 0153 from the Attribute +phone on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
ISimpleAttrValue value = (ISimpleAttrValue) attribute.getValues().next().next();	// value is "+1 (781) 559 0153"
value.remove();
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the value (if it does not know it already)

Message sent by the XDI CP:

=sender
   $del
      /
         =paul
            +phone
               /
                  $value$hash$sha$256!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca	<-- HIN of +1 (781) 559 0153 -->

Reply from the Attribute Service / native XDI endpoint: (none)

Modify a Simple Value of an Attribute

This example changes the Simple Value +1 (781) 559 0153 to +1 234 56789 on the Attribute +phone on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
ISimpleAttrValue value = (ISimpleAttrValue) attribute.getValues().next().next();	// value is "+1 (781) 559 0153"
value.setData("+1 234 56789");
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the value (if it does not know it already)
  • After sending the message, the XDI CP re-calculates the HIN of the value, in order to be able to refer to it later

Message sent by the XDI CP:

=sender
   $mod
      /
         =paul
            +phone
               /
                  $value$hash$sha$256!$!b25629ef86f5f6347f90b31225f95872982bc336ebd34c38e6533e0889bf13ca	<-- HIN of +1 (781) 559 0153 -->
                     $value
                        "+1 234 56789"

Reply from the Attribute Service / native XDI endpoint: (none)

Add a Simple Value to an Attribute

This example adds the Simple Value +1 987 65432 to the Attribute +phone on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+phone"));
ISimpleAttrValue value = attribute.addSimpleValue(ITypedValue.STRING_TYPE_URI, "+1 987 65432");
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the value

Message sent by the XDI CP:

=sender
   $add
      /
         =paul
            +phone
               /
                  $value$hash$sha$256!bb4d1ce368e89f0f5c4bfb867cd4b0437eadfa7aa559f9b49bf359bc5903a282	<-- HIN of +1 987 65432 -->
                     $value
                        "+1 987 65432"

Reply from the Attribute Service / native XDI endpoint: (none)

Complex Values

Remove a Complex Value from an Attribute

This example removes a Complex Value from the Attribute +address on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
ISimpleAttrValue value = (ISimpleAttrValue) attribute.getValues().next().next();	// second value
value.remove();
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the value (if it does not know it already)

Message sent by the XDI CP:

=sender
   $del
      /
         =paul
            +address
               /
                  $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715	<-- HIN of a complex value -->

Reply from the Attribute Service / native XDI endpoint: (none)

Add a Complex Value to an Attribute (Example 1)

This example adds a Complex Value to the Attribute +address on the Entity =paul. The Complex Value has four Attributes.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
IComplexAttrValue value = attribute.addComplexValue(URI.create(BasicComplexValue.ATTR_VALUE_TYPE_URI_STR)));
IAttribute subAttributeCity = value.addAttribute(URI.create("xri://+city"));
IAttribute subAttributeState = value.addAttribute(URI.create("xri://+state"));
IAttribute subAttributeStreet = value.addAttribute(URI.create("xri://+street"));
IAttribute subAttributeZip = value.addAttribute(URI.create("xri://+zip"));
subAttributeCity.addSimpleValue(ITypedValue.STRING_TYPE_URI, "Needham");
subAttributeState.addSimpleValue(ITypedValue.STRING_TYPE_URI, "MA");
subAttributeStreet.addSimpleValue(ITypedValue.STRING_TYPE_URI, "56 Kearney Rd");
subAttributeZip.addSimpleValue(ITypedValue.STRING_TYPE_URI, "02494");
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the values, in order to be able to refer to them later

Message sent by the XDI CP:

=sender
   $add
      /
         =paul
            +address
               /
                  $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715
                     +city
                        "Needham"
                     +street
                        "56 Kearney Rd"
                     +state
                        "MA"
                     +zip
                        "02494"

Reply from the Attribute Service / native XDI endpoint: (none)

Add a Complex Value to an Attribute (Example 2)

This example adds a Complex Value to the Attribute +address on the Entity =paul. The Complex Value has two Attributes.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
IComplexAttrValue value = attribute.addComplexValue(URI.create(BasicComplexValue.ATTR_VALUE_TYPE_URI_STR)));
IAttribute subAttributeLine = value.addAttribute(URI.create("xri://+line"));
IAttribute subAttributeCountry = value.addAttribute(URI.create("xri://+country"));
subAttributeLine.addSimpleValue(ITypedValue.STRING_TYPE_URI, "Needham, Massachusetts 02494");
subAttributeLine.addSimpleValue(ITypedValue.STRING_TYPE_URI, "56 Kearney Rd");
subAttributeCountr.addSimpleValue(ITypedValue.STRING_TYPE_URI, "USA");
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the values, in order to be able to refer to them later

Message sent by the XDI CP:

=sender
   $add
      /
         =paul
            +address
               /
                  $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324
                     +line 
                        /
                           $value$hash$sha$256!d27ef0bac9a6830121ebc30cd911fa9672a28fa8e8bd5d63ae3ade11af519d32
                              $value
                                 "Needham, Massachusetts 02494"
                           $value$hash$sha$256!4e8ae563672c68cb1533ae16993a693033f1a9032e43893c3464956b8ec2109c
                              $value
                                 "56 Kearney Rd"
                     +country
                        "USA"

Reply from the Attribute Service / native XDI endpoint: (none)

Modify a Simple Value of a Complex Value (Example 1)

This example changes the Simple Value MA to Massachusetts on the Attribute +state on the second Value of the Attribute +address on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
IComplexAttrValue value = (IComplexAttrValue) attribute.getValues().next().next();	// second value of +address
IAttribute subAttribute = value.getAttribute(URI.create("xri://+state"));
ISimpleAttrValue subValue = (ISimpleAttrValue) subAttribute.getValues().next();		// value is "MA"
value.setData("Massachusetts");
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the values (if it does not know them already)
  • After sending the message, the XDI CP re-calculates the HIN of the values, in order to be able to refer to them later

Message sent by the XDI CP:

=sender
   $mod
      /
         =paul
            +address
               /
                  $value$hash$sha$256!854d3dfca2b7388c160d301ddcad24084280c7d7bf3e2faac607b1c21917a715	<-- HIN of second value of +address -->
                     +state
                        "Massachusetts"

Reply from the Attribute Service / native XDI endpoint: (none)

Modify a Simple Value of a Complex Value (Example 2)

This example changes the Simple Value Needham, Massachusetts 02494 to Needham, MA 02494 on the Attribute +line on the third Value of the Attribute +address on the Entity =paul.

IdAS calls:

IEntity entity = context.getEntity("=paul");
IAttribute attribute = entity.getAttribute(URI.create("xri://+address"));
IComplexAttrValue value = (IComplexAttrValue) attribute.getValues().next().next().next();	// third value of +address
IAttribute subAttribute = value.getAttribute(URI.create("xri://+line"));
ISimpleAttrValue subValue = (ISimpleAttrValue) subAttribute.getValues().next();		// value is "Needham, Massachusetts 02494"
value.setData("Needham, MA 02494");
context.applyUpdates();
  • Before sending the message, the XDI CP calculates the HIN of the values (if it does not know them already)
  • After sending the message, the XDI CP re-calculates the HIN of the values, in order to be able to refer to them later

Message sent by the XDI CP:

=sender
   $mod
      /
         =paul
            +address
               /
                  $value$hash$sha$256!da4bb94a2779f74e4995fbb8a83965df2dfb9c91c63ba3a561206c33feb9d324	<-- HIN of third value of +address -->
                     +line
                        /
                           $value$hash$sha$256!d27ef0bac9a6830121ebc30cd911fa9672a28fa8e8bd5d63ae3ade11af519d32 <-- HIN of Needham, Massachusetts 02494 -->
                              $value
                                 "Needham, MA 02494"

Reply from the Attribute Service / native XDI endpoint: (none)

Miscellaneous

Get the schema of the Context

IdAS calls:

String schema = IContext.getSchema();

Schema support in IdAS maps to XDI dictionary statements.

TODO

Get Context Relations and Context Correlations

IdAS calls:

IContext.getRelationships() 

TODO

Authentication

The Higgins authentication materials needed to open an XDI context are:

  • A Sender XRI (i-name or i-number)
  • A Private Key which is used to sign all messages

Example:

=sender
	$get
		/
			=paul
				+address
	$sig$rsa
		"bCbYq6EN26N1hdJTtrjvHw05X+MtNzyFKuyPMoEX/nHxzotTAlGDfHqGuUGMgWIrAtFBkre+bbrUA07gjb6do8kr5OsmOKYvfEi/rxnbEhlEPfISEP5/SWJ8auc+W8E6TOPK2bBTxTrt4+5JGIE4TjiP1IZe9l85rqOmeAY5TLZkFzxGanD01Jf4EbB8qDdNjVsQSZgW0zcqyAdi7/quqTLesxLM9m340doFdHhJxW0cdVLS5CjBU67TR1uDSMEfMpqQhEp8qfQaD/0dUif5Wr5/q+L8nz9BsBQ9tzfFhUSATYMaL1whNNWHEpoO/OGKQPADv/PJbsbN7T3dwyjlBA=="

Access control

Access control in IdAS maps to XDI link contracts.

TODO

Notifications

Notification support in IdAS maps to XDI links contracts.

TODO

Filters

Filter support in IdAS maps to XDI queries.

On the OASIS XDI TC there was a proposal for an XDI query language. The idea is simple: You send a $get and replace everything you don't know with $$. So if you want to have all attributes with a name attribute that has a value of "Sergey", you would do:

Message sent by the XDI CP:

=sender
    $get
        /
            $$  <-- we don't know the subject -->
                +(http://www.example.com/name)
                    /
                        $$
                            $value
                                "Sergey"

Reply from the Attribute Service / native XDI endpoint:

=sergey    <-- that's what matched the $$ -->
    +(http://www.example.com/name)
        /
            $!11cac773045ffc189fa2e3ed232843d363d019c6
                $value
                    "Sergey"

This can be tested with the XDI Querier.

Links

  • The XDI RDF Model is the current OASIS TC proposal for an RDF-based data model and addressing format for XDI. This document includes the proposed XDI RDF schema and a number of examples of XDI documents. (Note that it does not yet include the proposed XDI messaging format, which uses XDI documents as message envelopes for other XDI documents.)
  • OASIS XDI TC Wiki
  • Wikipedia page on XDI

Back to the top