Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "IdAS XDI Mapping"

(Hash I-Numbers for Simple Values)
(Hash I-Numbers for Simple Values)
Line 34: Line 34:
  
 
Examples:
 
Examples:
* "Sergey" becomes '''$!ec57c08aec4b3c72a528e878f74685a7'''
+
* "Sergey" becomes '''$value$hash$md5!ec57c08aec4b3c72a528e878f74685a7'''
* "Markus" becomes '''$!181ff5eb6d184d261d6b28480110e599'''
+
* "Markus" becomes '''$value$hash$md5!181ff5eb6d184d261d6b28480110e599'''
* "markus.sabadello@gmail.com" becomes '''$!194454ebac24196430b1af7b34818b9f'''
+
* "markus.sabadello@gmail.com" becomes '''$value$hash$md5!194454ebac24196430b1af7b34818b9f'''
* "msabadello@parityinc.net" becomes '''$!1aa08be613b3114ad3130a3826301825'''
+
* "msabadello@parityinc.net" becomes '''$value$hash$md5!1aa08be613b3114ad3130a3826301825'''
* "markus@changedemail.com" '''$!db92995b5fb9eaa3b986afbaaf1bf8a1'''
+
* "markus@changedemail.com" '''$value$hash$md5!db92995b5fb9eaa3b986afbaaf1bf8a1'''
* "markus@newemail.com" becomes '''$!8f1e543796229f56f8e55dd73a9ac09a'''
+
* "markus@newemail.com" becomes '''$value$hash$md5!8f1e543796229f56f8e55dd73a9ac09a'''
  
 
=== Hash I-Numbers for Complex Values ===
 
=== Hash I-Numbers for Complex Values ===

Revision as of 20:06, 20 August 2008

{{#eclipseproject:technology.higgins}} 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 OASIS XDI Technical Committee.

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

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.

Concepts

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.

Roughly speaking, a Higgins context can be mapped to an XDI graph using the following rules:

  • 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 Relation maps to an XDI predicate
  • A Higgins Correlation maps to the special $is XDI predicate

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 the multi-valued Attribute.

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

FUNCTION makeSimpleHin(simpleValue)

  String hin = "$value$hash$md5" + "!" + hex(md5(simpleValue.string));
  RETURN hin;
END

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

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.

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

FUNCTION makeComplexHin(complexValue):

  String hin = "$value$hash$md5" + "!" + hex(md5(makeString(complexValue)));
  RETURN hin;
END

FUNCTION makeComplexString(complexValue):

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

  FOR EACH attribute IN complexValue.attributes

    attibuteIdStrings.push(attribute.attributeId)
  END

  FOR EACH attributeId IN sort(attributeIdStrings)

    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

    FOR EACH value IN attribute.values

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

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

  RETURN buffer;
END

Example: =john has a multi-valued attribute (+postalAddress), which has four values. One of the values is simple, the other three are complex.

=john
  +postalAddress
    /
      $value$hash$md5!1237453 <-- a simple value -->
        +postalAddress
          "56 Kearney Rd, Needham, Massachusetts 02494, USA"
      $value$hash$md5!937249 <-- 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!937249 <-- a complex value with 1. one multi-valued attribute with three simple values -->
        +line
          /
            $value$hash$md5!348927
              +line
                "56 Kearney Rd"
            $value$hash$md5!348927
              +line
                "Needham, Massachusetts 02494"
            $value$hash$md5!348927
              +line
                "USA"
      $value$hash$md5!3492384 <-- 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"
  • For the first value (simple value), the result of the makeSimpleHin() function is $value$hash$md5!b4d9a5f38ce519a8729e6bbdc1a6534d
  • For the second value (complex value), the result of the makeComplexString() function is +city "city1" +street "street1" , and the result of the makeComplexHin() function is $value$hash$md5!e81bac14f8e5325069f073d041fcea91
  • For the third value (complex value), the result of the makeComplexString() function is "56 Kearney Rd" "Needham, Massachusetts 02494" "USA" , and the result of the makeComplexHin() function is $value$hash$md5!548e76e394d4c04d234bc44d3aafcd98
  • For the fourth value (complex value), the result of the makeComplexString() function is +city "Needham" +street +streetname "Kearney Rd" +streetnumber "56" , and 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.

Mappings

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 in the Context

IdAS calls:

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

Message sent by the XDI Context Provider to <url>:

=sender
	$get

Reply from the XDI endpoint:

=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"

Get one Entity from the Context

IdAS calls:

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

Message sent by the XDI Context Provider to <url>:

=sender
	$get
		/
			=markus

Reply from the XDI endpoint:

=markus
	+(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"

Remove an Entity from the Context

IdAS calls:

IEntity entity = context.getEntity("=markus");
entity.remove();

Message sent by the XDI Context Provider to <url>:

=sender
	$del
		/
			=markus

Reply from the XDI endpoint: (none)

Attributes

Get one Attribute from an Entity

IdAS calls:

IEntity entity = context.getEntity("=markus");
IAttribute attribute = entity.getAttribute("http://www.example.com/name");

Message sent by the XDI Context Provider to <url>:

=sender
	$get
		/
			=markus
				+(http://www.example.com/name)

Reply from the XDI endpoint:

=markus
	+(http://www.example.com/name)
		/
			$!da649486d19f8cc02350447179637cba604eff46
				+(http://www.example.com/name)
					"Markus"

Remove an Attribute from an Entity

IdAS calls:

IEntity entity = context.getEntity("=markus");
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/name"));
attribute.remove();

Message sent by the XDI Context Provider to <url>:

=sender
	$del
		/
			=markus
				+(http://www.example.com/name)

Reply from the XDI endpoint: (none)

Simple Values

Remove a Simple Value from an Attribute

IdAS calls:

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();

Message sent by the XDI Context Provider to <url>:

=sender
	$del
		/
			=markus
				+(http://www.example.com/email)
					/
						$!710e4214a22c1840fc7a829b1c3fd32375e9efca	<-- HIN of msabadello@parityinc.net -->

Reply from the XDI endpoint: (none)

Change a Simple Value of an Attribute

IdAS calls:

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");

Message sent by the XDI Context Provider to <url>:

=sender
	$del
		/
			=markus
				+(http://www.example.com/email)
					/
						$!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"

Reply from the XDI endpoint: (none)

Add a Simple Value to an Attribute

IdAS calls:

IEntity entity = context.getEntity("=markus");
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/email"));
attribute.addSimpleValue(new URI(""), "markus@newemail.com");

Message sent by the XDI Context Provider to <url>:

=sender
	$add
		/
			=markus
				+(http://www.example.com/email)
					/
						$!690e082dc615d636abdaae2b066bdbf7e2b70057	<-- HIN of markus@newemail.com -->
							+(http://www.example.com/email)
								"markus@newemail.com"

Reply from the XDI endpoint: (none)

Complex Values

Remove a Complex Value from an Attribute

IdAS calls:

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();

Message sent by the XDI Context Provider to <url>:

=sender
	$del
		/
			=markus
				+(http://www.example.com/friend)
					=sergey

Reply from the XDI endpoint: (none)

Add a Complex Value to an Attribute

IdAS calls:

IEntity entity = context.getEntity("=markus");
IAttribute attribute = entity.getAttribute(new URI("http://www.example.com/friend"));
attribute.addComplexValue(new URI(""));
/* ... */

Message sent by the XDI Context Provider to <url>:

=sender
	$add
		/
			=markus
				+(http://www.example.com/friend)
					=sergey

Reply from the 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
		/
			=markus
				+(http://www.example.com/name)
	$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 Context Provider to <url>:

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

Reply from the XDI endpoint:

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

This can be tested with the XDI Querier.

Links

  • Higgins Home
  • 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

Copyright © Eclipse Foundation, Inc. All Rights Reserved.