itm / testbed-runtime

WISEBED Wireless Sensor Network Testbed Infrastructure Software
https://github.com/itm/testbed-runtime/wiki
15 stars 11 forks source link

Modify REST API to work in federated environments #328

Closed danbim closed 11 years ago

danbim commented 11 years ago

Currently, the REST API implementation uses only the first secret reservation key passed to it in the getInstance method. This will only work for a non-federated environment. As we want to use the REST API implementation as is for the federator we must modify the API and its implementation. In the future the secret reservation key list is passed in as a URL parameter to every method and the getInstance() method will be removed. This URL parameter is a base64-encoded serialized version of the secret reservation key list.

Example: a JavaScript client retrieved his reservation from the RsResource so he has a list of secret reservation keys:

var srks = [
  {urnPrefix: "urn:wisebed:uzl1:", secretReservationKey: "secret1"},
  {urnPrefix: "urn:wisebed:uzl2:", secretReservationKey: "secret2"},
  {urnPrefix: "urn:wisebed:uzl3:", secretReservationKey: "secret3"}
];

The REST APIs resources can be reached by attaching a base64-encoded serialized version of that:

var resetRequestUrl = "http://wisebed.itm.uni-luebeck.de/rest/v1.0/experiments/" + base64_encode(JSON.stringify(srks)) + "/reset";
$.ajax(...)

This way the testbed backend can base64-decode and deserialize the list of secret reservation keys and retrieve the reservation from the reservation system if not done yet before. Implementation can be fully stateless. This works in both federated and non-federated environments.