{"action":"created","comment":{"url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/comments/29653016","id":29653016,"diff_hunk":"@@ -0,0 +1,388 @@\n+package io.vertx.ext.httpservicefactory;\n+\n+import io.vertx.core.AsyncResult;\n+import io.vertx.core.DeploymentOptions;\n+import io.vertx.core.Future;\n+import io.vertx.core.Handler;\n+import io.vertx.core.Vertx;\n+import io.vertx.core.buffer.Buffer;\n+import io.vertx.core.file.AsyncFile;\n+import io.vertx.core.file.OpenOptions;\n+import io.vertx.core.http.HttpClient;\n+import io.vertx.core.http.HttpClientOptions;\n+import io.vertx.core.http.HttpClientRequest;\n+import io.vertx.core.json.JsonObject;\n+import io.vertx.core.streams.Pump;\n+import io.vertx.core.streams.WriteStream;\n+import io.vertx.service.ServiceVerticleFactory;\n+import org.bouncycastle.openpgp.PGPPublicKey;\n+import org.bouncycastle.openpgp.PGPSignature;\n+\n+import java.io.File;\n+import java.io.FileInputStream;\n+import java.net.URI;\n+import java.net.URL;\n+import java.net.URLClassLoader;\n+import java.net.URLEncoder;\n+import java.nio.file.Files;\n+import java.util.Base64;\n+import java.util.Collections;\n+import java.util.function.Function;\n+import java.util.jar.Attributes;\n+import java.util.jar.JarFile;\n+import java.util.jar.Manifest;\n+\n+/**\n+ * @author <a href=\"mailto:julien@julienviet.com\">Julien Viet</a>\n+ */\n+public class HttpServiceFactory extends ServiceVerticleFactory {\n+\n+  public static final String CACHE_DIR_PROPERTY = \"vertx.httpServiceFactory.cacheDir\";\n+  public static final String HTTP_CLIENT_OPTIONS_PROPERTY = \"vertx.httpServiceFactory.httpClientOptions\";\n+  public static final String HTTPS_CLIENT_OPTIONS_PROPERTY = \"vertx.httpServiceFactory.httpsClientOptions\";\n+  public static final String AUTH_USERNAME_PROPERTY = \"vertx.httpServiceFactory.authUsername\";\n+  public static final String AUTH_PASSWORD_PROPERTY = \"vertx.httpServiceFactory.authPassword\";\n+  public static final String KEYSERVER_URI_TEMPLATE = \"vertx.httpServiceFactory.keyserverURITemplate\";\n+  public static final String VALIDATION_POLICY = \"vertx.httpServiceFactory.validationPolicy\";\n+\n+  private static final String FILE_SEP = System.getProperty(\"file.separator\");\n+  private static final String FILE_CACHE_DIR = \".vertx\" + FILE_SEP + \"vertx-http-service-factory\";\n+\n+  private Vertx vertx;\n+  private File cacheDir;\n+  private String username;\n+  private String password;\n+  private String keyserverURITemplate;\n+  private ValidationPolicy validationPolicy;\n+  private HttpClientOptions options;\n+\n+  @Override\n+  public void init(Vertx vertx) {\n+    String path = System.getProperty(CACHE_DIR_PROPERTY, FILE_CACHE_DIR);\n+    cacheDir = new File(path);\n+    cacheDir.mkdirs();\n+    options = configOptions();\n+    validationPolicy = ValidationPolicy.valueOf(System.getProperty(VALIDATION_POLICY).toUpperCase());\n+    username = System.getProperty(AUTH_USERNAME_PROPERTY);\n+    password = System.getProperty(AUTH_PASSWORD_PROPERTY);\n+    keyserverURITemplate = System.getProperty(KEYSERVER_URI_TEMPLATE, \"http://pool.sks-keyservers.net:11371/pks/lookup?op=get&options=mr&search=0x%016X\");\n+    this.vertx = vertx;\n+  }\n+\n+  protected HttpClientOptions createHttpClientOptions(String scheme) {\n+    if (\"https\".equals(scheme)) {\n+      String optionsJson = System.getProperty(HTTPS_CLIENT_OPTIONS_PROPERTY);\n+      HttpClientOptions options;\n+      if (optionsJson != null) {\n+        options = new HttpClientOptions(new JsonObject(optionsJson));\n+      } else {\n+        options = createHttpClientOptions(\"http\").setTrustAll(true);\n+      }\n+      options.setSsl(true);\n+      return options;\n+    } else {\n+      String optionsJson = System.getProperty(HTTP_CLIENT_OPTIONS_PROPERTY);\n+      return optionsJson != null ? new HttpClientOptions(new JsonObject(optionsJson)) : new HttpClientOptions();\n+    }\n+  }\n+\n+  protected HttpClientOptions configOptions() {\n+    return createHttpClientOptions(prefix());\n+  }\n+\n+  @Override\n+  public String prefix() {\n+    return \"http\";\n+  }\n+\n+  @Override\n+  public void resolve(String identifier, DeploymentOptions deploymentOptions, ClassLoader classLoader, Future<String> resolution) {\n+\n+    int pos = identifier.lastIndexOf(\"::\");","path":"src/main/java/io/vertx/ext/httpservicefactory/HttpServiceFactory.java","position":101,"original_position":101,"commit_id":"d5dcf8e7461c9da26e705ba2d9152f4f37be51fd","original_commit_id":"d5dcf8e7461c9da26e705ba2d9152f4f37be51fd","user":{"login":"vietj","id":225674,"avatar_url":"https://avatars.githubusercontent.com/u/225674?v=3","gravatar_id":"","url":"https://api.github.com/users/vietj","html_url":"https://github.com/vietj","followers_url":"https://api.github.com/users/vietj/followers","following_url":"https://api.github.com/users/vietj/following{/other_user}","gists_url":"https://api.github.com/users/vietj/gists{/gist_id}","starred_url":"https://api.github.com/users/vietj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vietj/subscriptions","organizations_url":"https://api.github.com/users/vietj/orgs","repos_url":"https://api.github.com/users/vietj/repos","events_url":"https://api.github.com/users/vietj/events{/privacy}","received_events_url":"https://api.github.com/users/vietj/received_events","type":"User","site_admin":false},"body":"good point.","created_at":"2015-05-05T09:09:24Z","updated_at":"2015-05-05T09:09:24Z","html_url":"https://github.com/vert-x3/vertx-http-service-factory/pull/1#discussion_r29653016","pull_request_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/comments/29653016"},"html":{"href":"https://github.com/vert-x3/vertx-http-service-factory/pull/1#discussion_r29653016"},"pull_request":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1","id":34621163,"html_url":"https://github.com/vert-x3/vertx-http-service-factory/pull/1","diff_url":"https://github.com/vert-x3/vertx-http-service-factory/pull/1.diff","patch_url":"https://github.com/vert-x3/vertx-http-service-factory/pull/1.patch","issue_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/1","number":1,"state":"open","locked":false,"title":"Initial implementation","user":{"login":"vietj","id":225674,"avatar_url":"https://avatars.githubusercontent.com/u/225674?v=3","gravatar_id":"","url":"https://api.github.com/users/vietj","html_url":"https://github.com/vietj","followers_url":"https://api.github.com/users/vietj/followers","following_url":"https://api.github.com/users/vietj/following{/other_user}","gists_url":"https://api.github.com/users/vietj/gists{/gist_id}","starred_url":"https://api.github.com/users/vietj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vietj/subscriptions","organizations_url":"https://api.github.com/users/vietj/orgs","repos_url":"https://api.github.com/users/vietj/repos","events_url":"https://api.github.com/users/vietj/events{/privacy}","received_events_url":"https://api.github.com/users/vietj/received_events","type":"User","site_admin":false},"body":"please @purplefox review","created_at":"2015-05-04T08:10:22Z","updated_at":"2015-05-05T09:09:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"360c3a859e1599afff1ae53cc740e78e795d0427","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1/commits","review_comments_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1/comments","review_comment_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/1/comments","statuses_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/statuses/d5dcf8e7461c9da26e705ba2d9152f4f37be51fd","head":{"label":"vert-x3:initial-work","ref":"initial-work","sha":"d5dcf8e7461c9da26e705ba2d9152f4f37be51fd","user":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"repo":{"id":34790639,"name":"vertx-http-service-factory","full_name":"vert-x3/vertx-http-service-factory","owner":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vert-x3/vertx-http-service-factory","description":"","fork":false,"url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory","forks_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/forks","keys_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/teams","hooks_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/hooks","issue_events_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/events{/number}","events_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/events","assignees_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/assignees{/user}","branches_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/branches{/branch}","tags_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/tags","blobs_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/refs{/sha}","trees_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/statuses/{sha}","languages_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/languages","stargazers_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/stargazers","contributors_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/contributors","subscribers_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/subscribers","subscription_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/subscription","commits_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/commits{/sha}","git_commits_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/commits{/sha}","comments_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/comments{/number}","issue_comment_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/comments{/number}","contents_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/contents/{+path}","compare_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/merges","archive_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/downloads","issues_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues{/number}","pulls_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls{/number}","milestones_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/milestones{/number}","notifications_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/labels{/name}","releases_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/releases{/id}","created_at":"2015-04-29T11:43:27Z","updated_at":"2015-05-04T08:06:22Z","pushed_at":"2015-05-04T08:10:22Z","git_url":"git://github.com/vert-x3/vertx-http-service-factory.git","ssh_url":"git@github.com:vert-x3/vertx-http-service-factory.git","clone_url":"https://github.com/vert-x3/vertx-http-service-factory.git","svn_url":"https://github.com/vert-x3/vertx-http-service-factory","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"initial-work"}},"base":{"label":"vert-x3:master","ref":"master","sha":"3308ef78ed5ed2876798fd4b20a57a30782e0d3e","user":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"repo":{"id":34790639,"name":"vertx-http-service-factory","full_name":"vert-x3/vertx-http-service-factory","owner":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vert-x3/vertx-http-service-factory","description":"","fork":false,"url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory","forks_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/forks","keys_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/teams","hooks_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/hooks","issue_events_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/events{/number}","events_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/events","assignees_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/assignees{/user}","branches_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/branches{/branch}","tags_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/tags","blobs_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/refs{/sha}","trees_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/statuses/{sha}","languages_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/languages","stargazers_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/stargazers","contributors_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/contributors","subscribers_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/subscribers","subscription_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/subscription","commits_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/commits{/sha}","git_commits_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/git/commits{/sha}","comments_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/comments{/number}","issue_comment_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/comments{/number}","contents_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/contents/{+path}","compare_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/merges","archive_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/downloads","issues_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues{/number}","pulls_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls{/number}","milestones_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/milestones{/number}","notifications_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/labels{/name}","releases_url":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/releases{/id}","created_at":"2015-04-29T11:43:27Z","updated_at":"2015-05-04T08:06:22Z","pushed_at":"2015-05-04T08:10:22Z","git_url":"git://github.com/vert-x3/vertx-http-service-factory.git","ssh_url":"git@github.com:vert-x3/vertx-http-service-factory.git","clone_url":"https://github.com/vert-x3/vertx-http-service-factory.git","svn_url":"https://github.com/vert-x3/vertx-http-service-factory","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"initial-work"}},"_links":{"self":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1"},"html":{"href":"https://github.com/vert-x3/vertx-http-service-factory/pull/1"},"issue":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/1"},"comments":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/vert-x3/vertx-http-service-factory/statuses/d5dcf8e7461c9da26e705ba2d9152f4f37be51fd"}}}}