Reminder: XDI2 call TOMORROW 2pm ET

17 views
Skip to first unread message

Markus Sabadello

unread,
Oct 1, 2014, 4:32:48 PM10/1/14
to xd...@googlegroups.com
(Sending this one day earlier than usual)

Topic for TOMORROW: Virtual XDI hackathon!
"What is the simplest way to send a message between two graphs?"

If you want to participate, please have your cloud name and secret token (password) ready.
Then choose one of the following 3 groups:

Group A: "Advanced developer":
You will write Java code to create a link contract in your cloud, and later read a message from an "inbox".

Group B: "Intermediate developer":
You will write Java code to write a message to a cloud belonging to someone in Group A.

Group C: "Non-developer"
You will participate by using the XDI2 web tools instead of writing code.

If you choose Group A or B, make sure you have your development environment set up with XDI2 on the build path.

We will use the following EtherPad to share code and XDI data examples:
http://piratepad.nl/xdi2-2-oct-2014

-------------------------------------------------------
Meeting information
-------------------------------------------------------
Topic: XDI2 Project Review
Date: Every Thursday, from Thursday, January 31, 2013 to no end date
Time: 2:00 pm, Eastern Standard Time (New York, GMT-05:00)
Meeting Number: 651 585 318
Meeting Password: 5474

irc://irc.freenode.net:6667/xdi

-------------------------------------------------------
To start or join the online meeting
-------------------------------------------------------
Go to https://neustar.webex.com/neustar/j.php?ED=210912797&UID=504709622&PW=NZjkwZTg0ZGUx&RT=MiMxMQ%3D%3D

-------------------------------------------------------
Audio conference information
-------------------------------------------------------
To receive a call back, provide your phone number when you join the meeting, or call the number below and enter the access code.
Call-in toll-free number (US/Canada): 1-866-469-3239
Call-in toll number (US/Canada): 1-650-429-3300
Toll-free dialing restrictions: http://www.webex.com/pdf/tollfree_restrictions.pdf

Access code:651 585 318

-------------------------------------------------------
For assistance
-------------------------------------------------------
1. Go to https://neustar.webex.com/neustar/mc
2. On the left navigation bar, click "Support".
To add this meeting to your calendar program (for example Microsoft Outlook), click this link:
https://neustar.webex.com/neustar/j.php?ED=210912797&UID=504709622&ICS=MS&LD=1&RD=2&SHA2=AAAAAqcpeQ4CSUsXkTd3y3btMvxBzkw6AunrMKYgLUwtXrpQ&ST=1

To check whether you have the appropriate players installed for UCF (Universal Communications Format) rich media files, go to https://neustar.webex.com/neustar/systemdiagnosis.php.

http://www.webex.com
We've got to start meeting like this(TM)

CCM:+16504293300x651585318#

IMPORTANT NOTICE: This WebEx service includes a feature that allows audio and any documents and other materials exchanged or viewed during the session to be recorded. You should inform all meeting attendees prior to recording if you intend to record the meeting. Please note that any such recordings may be subject to discovery in the event of litigation.

Markus Sabadello

unread,
Oct 2, 2014, 4:16:10 PM10/2/14
to xd...@googlegroups.com
Thanks everyone for staying longer than usual.
Please feel free to send topic requests also for future XDI2 calls!

Warning: Please do not consider what we did today to be ready for a production service.
There are several improvements we would have to make to the scenario first, most importantly policies and signatures, but also a few other details.

Here's a copy of the notes from the pad.

XDI2 call 2nd Oct 2014

Virtual XDI hackathon!
"What is the simplest way to send a message between two graphs?"

Choose one of the following groups:

Group A: "Advanced developer":
You  will write Java code to create a link contract in your cloud, and later  read a message from an "inbox". You are an AUTHORIZING AUTHORITY.

=beech aka =hacker
=andrepm -> =boyle
=markus  -->  =pakkanaughty, =lion, =boyle, =danb

=================================================

Group B: "Intermediate developer":
You will write Java code to write a message to a cloud belonging to someone in Group A. You are a REQUESTING AUTHORITY.

=pakkanaughty
=boyle

=================================================

Group C: "Non-developer"
You will participate by using the XDI2 web tools instead of writing code.

=lion
=danb

=================================================

Group D: "Observers"

=les
=hananya
=hubert

=================================================

CODE FOR GROUP A - FIRST PART THAT CREATES LINK CONTRACT

import java.net.URL;

import xdi2.client.http.XDIHttpClient;
import xdi2.core.Graph;
import xdi2.core.constants.XDILinkContractConstants;
import xdi2.core.features.linkcontracts.instance.GenericLinkContract;
import xdi2.core.features.linkcontracts.instance.RootLinkContract;
import xdi2.core.impl.memory.MemoryGraphFactory;
import xdi2.core.syntax.CloudName;
import xdi2.core.syntax.CloudNumber;
import xdi2.core.syntax.XDIAddress;
import xdi2.core.util.XDIAddressUtil;
import xdi2.discovery.XDIDiscoveryClient;
import xdi2.discovery.XDIDiscoveryResult;
import xdi2.messaging.Message;
import xdi2.messaging.MessageEnvelope;

public class GroupA {

    public static void main(String[] args) throws Exception {

        // let's find the cloud of =markus (AA) and =pakkanaughty (RA)

        CloudName cloudNameAA = CloudName.create("=markus");
        XDIDiscoveryResult resultAA = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT.discoverFromRegistry(cloudNameAA.getXDIAddress(), null);
        CloudNumber cloudNumberAA = resultAA.getCloudNumber();
        URL urlAA = resultAA.getXdiEndpointUrl();

        CloudName cloudNameRA = CloudName.create("=boyle");
        XDIDiscoveryResult resultRA = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT.discoverFromRegistry(cloudNameRA.getXDIAddress(), null);
        CloudNumber cloudNumberRA = resultRA.getCloudNumber();
        URL urlRA = resultRA.getXdiEndpointUrl();

        // prepare link contract to write into my cloud
        // it allows $set operations on [=]!:uuid:1111[<#inbox>]

        Graph tempGraph = MemoryGraphFactory.getInstance().openGraph();
        GenericLinkContract linkContract = GenericLinkContract.findGenericLinkContract(
                tempGraph, 
                cloudNumberAA.getXDIAddress(), 
                cloudNumberRA.getXDIAddress(), 
                XDIAddress.create("#inbox"), 
                true);
        linkContract.setPermissionTargetXDIAddress(
                XDILinkContractConstants.XDI_ADD_SET, 
                XDIAddressUtil.concatXDIAddresses(cloudNumberAA.getXDIAddress(), XDIAddress.create("[<#inbox>]")));

        // normally there would be a policy on the link contract that requires a valid signature
        // but we will leave this out (or do it later), since it is not supported by all CSPs 

        System.out.println("We are sending the following XDI data to my cloud:");
        System.out.println(tempGraph.toString("XDI DISPLAY", null));

        // send the XDI data my cloud

        MessageEnvelope messageEnvelope = new MessageEnvelope();
        Message message = messageEnvelope.createMessage(cloudNumberAA.getXDIAddress());
        message.setToPeerRootXDIArc(cloudNumberAA.getPeerRootXDIArc());
        message.setLinkContract(RootLinkContract.class);
        message.setSecretToken("test11!!");
        message.createSetOperation(tempGraph);

        new XDIHttpClient(urlAA).send(messageEnvelope, null);

        System.out.println("Success");
    }
}


CODE FOR GROUP A - SECOND PART THAT READS INBOX

import java.net.URL;

import xdi2.client.http.XDIHttpClient;
import xdi2.core.Literal;
import xdi2.core.features.linkcontracts.instance.RootLinkContract;
import xdi2.core.syntax.CloudName;
import xdi2.core.syntax.CloudNumber;
import xdi2.core.syntax.XDIAddress;
import xdi2.core.util.XDIAddressUtil;
import xdi2.discovery.XDIDiscoveryClient;
import xdi2.discovery.XDIDiscoveryResult;
import xdi2.messaging.Message;
import xdi2.messaging.MessageEnvelope;
import xdi2.messaging.MessageResult;


public class GroupAPart2 {

    public static void main(String[] args) throws Exception {

        // let's find the cloud of =markus (AA)

        CloudName cloudNameAA = CloudName.create("=markus");
        XDIDiscoveryResult resultAA = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT.discoverFromRegistry(cloudNameAA.getXDIAddress(), null);
        CloudNumber cloudNumberAA = resultAA.getCloudNumber();
        URL urlAA = resultAA.getXdiEndpointUrl();

        // send the XDI data my cloud

        MessageEnvelope messageEnvelope = new MessageEnvelope();
        Message message = messageEnvelope.createMessage(cloudNumberAA.getXDIAddress());
        message.setToPeerRootXDIArc(cloudNumberAA.getPeerRootXDIArc());
        message.setLinkContract(RootLinkContract.class);
        message.setSecretToken("test11!!");
        message.createGetOperation(XDIAddressUtil.concatXDIAddresses(cloudNumberAA.getXDIAddress(), XDIAddress.create("[<#inbox>]")));

        MessageResult messageResult = new XDIHttpClient(urlAA).send(messageEnvelope, null);

        System.out.println(messageResult.getGraph().toString("XDI DISPLAY", null));

        for (Literal literal : messageResult.getGraph().getRootContextNode().getAllLiterals()) {

            System.out.println(literal.getLiteralData());
        }
    }
}

CODE FOR GROUP B

import java.net.URL;

import xdi2.client.http.XDIHttpClient;
import xdi2.core.Graph;
import xdi2.core.features.linkcontracts.instance.GenericLinkContract;
import xdi2.core.features.nodetypes.XdiAttribute;
import xdi2.core.features.nodetypes.XdiCommonRoot;
import xdi2.core.impl.memory.MemoryGraphFactory;
import xdi2.core.syntax.CloudName;
import xdi2.core.syntax.CloudNumber;
import xdi2.core.syntax.XDIAddress;
import xdi2.discovery.XDIDiscoveryClient;
import xdi2.discovery.XDIDiscoveryResult;
import xdi2.messaging.Message;
import xdi2.messaging.MessageEnvelope;


public class GroupB {

    public static void main(String[] args) throws Exception {

        // this is what =pakkanaughty would do now.

        // let's find the cloud of =lion (AA) and =markus (RA)

        CloudName cloudNameAA = CloudName.create("=lion");
        XDIDiscoveryResult resultAA = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT.discoverFromRegistry(cloudNameAA.getXDIAddress(), null);
        CloudNumber cloudNumberAA = resultAA.getCloudNumber();
        URL urlAA = resultAA.getXdiEndpointUrl();

        CloudName cloudNameRA = CloudName.create("=markus");
        XDIDiscoveryResult resultRA = XDIDiscoveryClient.DEFAULT_DISCOVERY_CLIENT.discoverFromRegistry(cloudNameRA.getXDIAddress(), null);
        CloudNumber cloudNumberRA = resultRA.getCloudNumber();
        URL urlRA = resultRA.getXdiEndpointUrl();

        // prepare message for =markus' inbox
        // the message will be somewhere in [=]!:uuid:1111[<#inbox>]<!:uuid:1234>

        Graph tempGraph = MemoryGraphFactory.getInstance().openGraph();
        XdiAttribute inboxMessage = XdiCommonRoot.findCommonRoot(tempGraph)
                .getXdiEntity(cloudNumberAA.getXDIAddress(), true)
                .getXdiAttributeCollection(XDIAddress.create("[<#inbox>]"), true)
                .setXdiMemberUnordered(null);

        inboxMessage.getXdiValue(true).setLiteralString("[This messages has been marked as SPAM] Click <here> to enlarge your cloud now!");

        System.out.println("We are sending the following XDI data to my cloud:");
        System.out.println(tempGraph.toString("XDI DISPLAY", null));

        // send the XDI data my cloud

        MessageEnvelope messageEnvelope = new MessageEnvelope();
        Message message = messageEnvelope.createMessage(cloudNumberRA.getXDIAddress());
        message.setToPeerRootXDIArc(cloudNumberAA.getPeerRootXDIArc());
        message.setLinkContractXDIAddress(
                GenericLinkContract.createGenericLinkContractXDIAddress(
                        cloudNumberAA.getXDIAddress(), 
                        cloudNumberRA.getXDIAddress(), 
                        XDIAddress.create("#inbox")));
        message.createSetOperation(tempGraph);

        // normally we would put a signature on a message,
        // only works with DanubeClouds CSP

        new XDIHttpClient(urlAA).send(messageEnvelope, null);

        System.out.println("Success");
    }
}



Here's the output of Group B's execution.

We are sending the following XDI data to my cloud:
[=]!:uuid:91f28153-f600-ae24-91f2-8153f600ae24[<#inbox>]<!:uuid:813830ce-f9b9-4787-afaf-3cae0635d199>&/&/"Hello this is a message from =pakkanaughty to =markus"

Success

MANUAL PROCESS FOR GROUP A PART 1 (CREATE LINK CONTRACT FOR INBOX)

1. Find out out cloud number of both RA and AA (using XDI Discoverer tool)
2. Find out the XDI endpoint URI of AA (using XDI Discoverer tool)
3. Determine address of ROOT link contract:

(<-- AA cloudnumber -->/<-- AA cloudnumber -->)$do

3. Determine inbox link contract:

(<-- AA cloudnumber -->/<-- RA cloudnumber -->)#inbox$do/$set/<-- AA cloudnumber -->[<#inbox>]

(normally we would have a policy on the link contract to require a valid signature from the RA, but not all CSPs support it)

4. Send XDI message (using XDI Messenger tool):

<-- AA cloudnumber -->[$msg]!1/$is()/(<-- AA cloudnumber -->)
<-- AA cloudnumber -->[$msg]!1/$do/<-- address of ROOT link contract -->
<-- AA cloudnumber -->[$msg]!1<$secret><$token>&/&/"<-- AA password -->"
(<-- AA cloudnumber -->[$msg]!1$do/$set)<-- inbox link contract -->

MANUAL PROCESS FOR GROUP A PART 2 (VIEW INBOX)


1. Find out out cloud number of AA (using XDI Discoverer tool)
2. Find out the XDI endpoint URI of AA (using XDI Discoverer tool)
3. Determine address of ROOT link contract:

(<-- AA cloudnumber -->/<-- AA cloudnumber -->)$do

4. Send XDI message (using XDI Messenger tool):

<-- AA cloudnumber -->[$msg]!1/$is()/(<-- AA cloudnumber -->)
<-- AA cloudnumber -->[$msg]!1/$do/<-- address of ROOT link contract -->
<-- AA cloudnumber -->[$msg]!1<$secret><$token>&/&/"<-- AA password -->""
<-- AA cloudnumber -->[$msg]!1$do/$get/<-- AA cloudnumber  -->[<#inbox>]

MANUAL PROCESS FOR GROUP B (SEND MESSAGE TO INBOX)

1. Find out out cloud number of both RA and AA (using XDI Discoverer tool)
2. Find out the XDI endpoint URI of AA (using XDI Discoverer tool)
3. Determine address of inbox link contract:

(<-- AA cloudnumber -->/<-- RA cloudnumber -->)#inbox$do

4. Send XDI message (using XDI Messenger tool):

<-- RA cloudnumber -->[$msg]!1/$is()/(<-- AA cloudnumber -->)
<-- RA cloudnumber -->[$msg]!1/$do/<-- address of link contract -->
(<-- RA cloudnumber -->[$msg]!1$do/$set)<-- AA cloudnumber -->[<#inbox>]<!:uuid:34562834567384>&/&/"message text here"

normally there would be signature on the message if the link contract policy requires it:

<-- RA cloudnumber -->[$msg]!1<$sig>&/&/"...."

VIEW AND MANAGE LINK CONTRACTS IN THE DASHBOARD:



Reply all
Reply to author
Forward
0 new messages