/*
* Copyright 2015-2016 INESC-ID
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

var client = vertx.createHttpClient({});

var JavaRequest = {

  get: function(url, callback) {
    client.getAbs(url, function (response) {
      response.bodyHandler(function(totalBuffer) {
        var body = totalBuffer.toString("UTF-8");
        callback(null, JSON.parse(body), response.statusCode());
      });
    })
    .exceptionHandler(function(e) {
      print("[REGISTRY-CONNECTOR] Error: " + e);
      callback(e, null, null);
    })
    .end();
  },

  put: function(url, data, callback) {
    var finalData = JSON.stringify(data);

    client.putAbs(url)
    .putHeader("content-type", "application/json")
    .putHeader("content-length", "" + finalData.length())
    .handler(function(response) {
      response.bodyHandler(function(totalBuffer) {
        var body = totalBuffer.toString("UTF-8");
        callback(null, JSON.parse(body), response.statusCode());
      });
    })
    .exceptionHandler(function(e) {
      print("[REGISTRY-CONNECTOR] Error: " + e);
      callback(e, null, null);
    })
    .write(finalData)
    .end();
  },

  del: function(url, callback) {
    client.deleteAbs(url, function(response) {
      response.bodyHandler(function(totalBuffer) {
        var body = totalBuffer.toString("UTF-8");
        callback(null, JSON.parse(body), response.statusCode());
      });
    })
    .exceptionHandler(function(e) {
      print("[REGISTRY-CONNECTOR] Error: " + e);
      callback(e, null, null);
    })
    .end();
  }

};

module.exports = JavaRequest;

@@ -577,16 +577,466 @@
 .%0A*%0A*/%0A%0A
+var trustStoreBuffer = vertx.fileSystem().readFileBlocking(%22ca-bundle.pem%22);%0Avar clientKeyBuffer = vertx.fileSystem().readFileBlocking(%22connector.key.pem%22);%0Avar clientCertBuffer = vertx.fileSystem().readFileBlocking(%22connector.cert.pem%22);%0A%0A%0Avar options  = %7B%0A  %22ssl%22: true,%0A  %22pemTrustOptions%22: %7B%0A    %22certValues%22: %5B%0A      trustStoreBuffer%0A    %5D%0A  %7D,%0A  %22pemKeyCertOptions%22: %7B%0A    %22keyValue%22: clientKeyBuffer,%0A    %22certValue%22: clientCertBuffer%0A  %7D%0A%7D;%0A%0A
 var clie
@@ -1067,14 +1067,20 @@
 ent(
-%7B%7D
+options
 );%0A%0A
+%0A
 var 

Add support for mutual authentication TLS in Java.