{"action":"created","comment":{"url":"https://api.github.com/repos/sonatype/goodies/pulls/comments/40135948","id":40135948,"diff_hunk":"@@ -0,0 +1,248 @@\n+/*\n+ * Copyright (c) 2010-present Sonatype, Inc. All rights reserved.\n+ *\n+ * This program is licensed to you under the Apache License Version 2.0,\n+ * and you may not use this file except in compliance with the Apache License Version 2.0.\n+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the Apache License Version 2.0 is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.\n+ */\n+package org.sonatype.goodies.httpfixture.server.jetty.behaviour;\n+\n+import java.io.ByteArrayOutputStream;\n+import java.io.IOException;\n+import java.security.InvalidKeyException;\n+import java.security.NoSuchAlgorithmException;\n+import java.util.Arrays;\n+import java.util.Map;\n+\n+import javax.crypto.Cipher;\n+import javax.crypto.NoSuchPaddingException;\n+import javax.crypto.spec.SecretKeySpec;\n+import javax.servlet.http.HttpServletRequest;\n+import javax.servlet.http.HttpServletResponse;\n+\n+import org.eclipse.jetty.util.B64Code;\n+\n+// FIXME: Incomplete, last step is not validated\n+\n+public class NTLMAuth\n+    extends BehaviourSupport\n+{\n+  private boolean authorized;\n+\n+  private int state;\n+\n+  public boolean execute(HttpServletRequest request, HttpServletResponse response, Map<Object, Object> ctx)\n+      throws Exception\n+  {\n+    String authHeader = request.getHeader(\"Authorization\");\n+    switch (state) {\n+      case 1:\n+        if (authHeader != null && authHeader.startsWith(\"NTLM\")) {\n+          log.debug(\"received type 1: {}\", authHeader);\n+          answerType1(authHeader, response);\n+          state = 2;\n+          return false;\n+        }\n+        break;\n+      case 2:\n+        if (authHeader != null && authHeader.startsWith(\"NTLM\")) {\n+          log.debug(\"received type 3: {}\", authHeader);\n+          state = 0;\n+          return checkType3(authHeader, response);\n+        }\n+      default:\n+        sendChallenge(response);\n+        state = 1;\n+        break;\n+    }\n+    return false;\n+  }\n+\n+  private boolean checkType3(String authHeader, HttpServletResponse response) {","path":"httpfixture/src/main/java/org/sonatype/goodies/httpfixture/server/jetty/behaviour/NTLMAuth.java","position":66,"original_position":66,"commit_id":"0fd9ac211e1e69b082b687a201a8e212f9051b8c","original_commit_id":"0fd9ac211e1e69b082b687a201a8e212f9051b8c","user":{"login":"sonatype-zion","id":1497996,"avatar_url":"https://avatars.githubusercontent.com/u/1497996?v=3","gravatar_id":"","url":"https://api.github.com/users/sonatype-zion","html_url":"https://github.com/sonatype-zion","followers_url":"https://api.github.com/users/sonatype-zion/followers","following_url":"https://api.github.com/users/sonatype-zion/following{/other_user}","gists_url":"https://api.github.com/users/sonatype-zion/gists{/gist_id}","starred_url":"https://api.github.com/users/sonatype-zion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonatype-zion/subscriptions","organizations_url":"https://api.github.com/users/sonatype-zion/orgs","repos_url":"https://api.github.com/users/sonatype-zion/repos","events_url":"https://api.github.com/users/sonatype-zion/events{/privacy}","received_events_url":"https://api.github.com/users/sonatype-zion/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Avoid unused method parameters such as 'response'. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](http://nemo.sonarqube.org/coding_rules#rule_key=pmd%3AUnusedFormalParameter)\n![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Avoid unused method parameters such as 'authHeader'. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](http://nemo.sonarqube.org/coding_rules#rule_key=pmd%3AUnusedFormalParameter)\n","created_at":"2015-09-22T19:59:17Z","updated_at":"2015-09-22T19:59:17Z","html_url":"https://github.com/sonatype/goodies/pull/43#discussion_r40135948","pull_request_url":"https://api.github.com/repos/sonatype/goodies/pulls/43","_links":{"self":{"href":"https://api.github.com/repos/sonatype/goodies/pulls/comments/40135948"},"html":{"href":"https://github.com/sonatype/goodies/pull/43#discussion_r40135948"},"pull_request":{"href":"https://api.github.com/repos/sonatype/goodies/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/sonatype/goodies/pulls/43","id":45484984,"html_url":"https://github.com/sonatype/goodies/pull/43","diff_url":"https://github.com/sonatype/goodies/pull/43.diff","patch_url":"https://github.com/sonatype/goodies/pull/43.patch","issue_url":"https://api.github.com/repos/sonatype/goodies/issues/43","number":43,"state":"open","locked":false,"title":"Httpfixture (merge of http-testing-harness)","user":{"login":"jdillon","id":20114,"avatar_url":"https://avatars.githubusercontent.com/u/20114?v=3","gravatar_id":"","url":"https://api.github.com/users/jdillon","html_url":"https://github.com/jdillon","followers_url":"https://api.github.com/users/jdillon/followers","following_url":"https://api.github.com/users/jdillon/following{/other_user}","gists_url":"https://api.github.com/users/jdillon/gists{/gist_id}","starred_url":"https://api.github.com/users/jdillon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdillon/subscriptions","organizations_url":"https://api.github.com/users/jdillon/orgs","repos_url":"https://api.github.com/users/jdillon/repos","events_url":"https://api.github.com/users/jdillon/events{/privacy}","received_events_url":"https://api.github.com/users/jdillon/received_events","type":"User","site_admin":false},"body":"Moves https://github.com/sonatype/http-testing-harness into goodies:\r\n\r\n* goodies-httpfixture-server\r\n* goodies-httpfixture-runner\r\n\r\nRepackages under:\r\n\r\n* org.sonatype.goodies.httpfixture\r\n\r\nBunch of cleanup and tidy to get code closer to standards.\r\n\r\n----\r\n\r\nFTR unsure if we actually need 2 modules or if this could be condensed down to just 1.","created_at":"2015-09-19T21:49:54Z","updated_at":"2015-09-22T19:59:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50a11fa8a6e5e224460b232329ea50855ca759eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sonatype/goodies/pulls/43/commits","review_comments_url":"https://api.github.com/repos/sonatype/goodies/pulls/43/comments","review_comment_url":"https://api.github.com/repos/sonatype/goodies/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sonatype/goodies/issues/43/comments","statuses_url":"https://api.github.com/repos/sonatype/goodies/statuses/0fd9ac211e1e69b082b687a201a8e212f9051b8c","head":{"label":"sonatype:httpfixture","ref":"httpfixture","sha":"0fd9ac211e1e69b082b687a201a8e212f9051b8c","user":{"login":"sonatype","id":44938,"avatar_url":"https://avatars.githubusercontent.com/u/44938?v=3","gravatar_id":"","url":"https://api.github.com/users/sonatype","html_url":"https://github.com/sonatype","followers_url":"https://api.github.com/users/sonatype/followers","following_url":"https://api.github.com/users/sonatype/following{/other_user}","gists_url":"https://api.github.com/users/sonatype/gists{/gist_id}","starred_url":"https://api.github.com/users/sonatype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonatype/subscriptions","organizations_url":"https://api.github.com/users/sonatype/orgs","repos_url":"https://api.github.com/users/sonatype/repos","events_url":"https://api.github.com/users/sonatype/events{/privacy}","received_events_url":"https://api.github.com/users/sonatype/received_events","type":"Organization","site_admin":false},"repo":{"id":2698192,"name":"goodies","full_name":"sonatype/goodies","owner":{"login":"sonatype","id":44938,"avatar_url":"https://avatars.githubusercontent.com/u/44938?v=3","gravatar_id":"","url":"https://api.github.com/users/sonatype","html_url":"https://github.com/sonatype","followers_url":"https://api.github.com/users/sonatype/followers","following_url":"https://api.github.com/users/sonatype/following{/other_user}","gists_url":"https://api.github.com/users/sonatype/gists{/gist_id}","starred_url":"https://api.github.com/users/sonatype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonatype/subscriptions","organizations_url":"https://api.github.com/users/sonatype/orgs","repos_url":"https://api.github.com/users/sonatype/repos","events_url":"https://api.github.com/users/sonatype/events{/privacy}","received_events_url":"https://api.github.com/users/sonatype/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sonatype/goodies","description":"Goodies","fork":false,"url":"https://api.github.com/repos/sonatype/goodies","forks_url":"https://api.github.com/repos/sonatype/goodies/forks","keys_url":"https://api.github.com/repos/sonatype/goodies/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonatype/goodies/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonatype/goodies/teams","hooks_url":"https://api.github.com/repos/sonatype/goodies/hooks","issue_events_url":"https://api.github.com/repos/sonatype/goodies/issues/events{/number}","events_url":"https://api.github.com/repos/sonatype/goodies/events","assignees_url":"https://api.github.com/repos/sonatype/goodies/assignees{/user}","branches_url":"https://api.github.com/repos/sonatype/goodies/branches{/branch}","tags_url":"https://api.github.com/repos/sonatype/goodies/tags","blobs_url":"https://api.github.com/repos/sonatype/goodies/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonatype/goodies/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonatype/goodies/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonatype/goodies/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonatype/goodies/statuses/{sha}","languages_url":"https://api.github.com/repos/sonatype/goodies/languages","stargazers_url":"https://api.github.com/repos/sonatype/goodies/stargazers","contributors_url":"https://api.github.com/repos/sonatype/goodies/contributors","subscribers_url":"https://api.github.com/repos/sonatype/goodies/subscribers","subscription_url":"https://api.github.com/repos/sonatype/goodies/subscription","commits_url":"https://api.github.com/repos/sonatype/goodies/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonatype/goodies/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonatype/goodies/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonatype/goodies/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonatype/goodies/contents/{+path}","compare_url":"https://api.github.com/repos/sonatype/goodies/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonatype/goodies/merges","archive_url":"https://api.github.com/repos/sonatype/goodies/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonatype/goodies/downloads","issues_url":"https://api.github.com/repos/sonatype/goodies/issues{/number}","pulls_url":"https://api.github.com/repos/sonatype/goodies/pulls{/number}","milestones_url":"https://api.github.com/repos/sonatype/goodies/milestones{/number}","notifications_url":"https://api.github.com/repos/sonatype/goodies/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonatype/goodies/labels{/name}","releases_url":"https://api.github.com/repos/sonatype/goodies/releases{/id}","created_at":"2011-11-02T21:23:34Z","updated_at":"2015-09-12T19:57:52Z","pushed_at":"2015-09-22T19:45:08Z","git_url":"git://github.com/sonatype/goodies.git","ssh_url":"git@github.com:sonatype/goodies.git","clone_url":"https://github.com/sonatype/goodies.git","svn_url":"https://github.com/sonatype/goodies","homepage":"","size":2183,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"sonatype:master","ref":"master","sha":"8e6f4d72cd60550c2d08af8ae6454b5b26173032","user":{"login":"sonatype","id":44938,"avatar_url":"https://avatars.githubusercontent.com/u/44938?v=3","gravatar_id":"","url":"https://api.github.com/users/sonatype","html_url":"https://github.com/sonatype","followers_url":"https://api.github.com/users/sonatype/followers","following_url":"https://api.github.com/users/sonatype/following{/other_user}","gists_url":"https://api.github.com/users/sonatype/gists{/gist_id}","starred_url":"https://api.github.com/users/sonatype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonatype/subscriptions","organizations_url":"https://api.github.com/users/sonatype/orgs","repos_url":"https://api.github.com/users/sonatype/repos","events_url":"https://api.github.com/users/sonatype/events{/privacy}","received_events_url":"https://api.github.com/users/sonatype/received_events","type":"Organization","site_admin":false},"repo":{"id":2698192,"name":"goodies","full_name":"sonatype/goodies","owner":{"login":"sonatype","id":44938,"avatar_url":"https://avatars.githubusercontent.com/u/44938?v=3","gravatar_id":"","url":"https://api.github.com/users/sonatype","html_url":"https://github.com/sonatype","followers_url":"https://api.github.com/users/sonatype/followers","following_url":"https://api.github.com/users/sonatype/following{/other_user}","gists_url":"https://api.github.com/users/sonatype/gists{/gist_id}","starred_url":"https://api.github.com/users/sonatype/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonatype/subscriptions","organizations_url":"https://api.github.com/users/sonatype/orgs","repos_url":"https://api.github.com/users/sonatype/repos","events_url":"https://api.github.com/users/sonatype/events{/privacy}","received_events_url":"https://api.github.com/users/sonatype/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sonatype/goodies","description":"Goodies","fork":false,"url":"https://api.github.com/repos/sonatype/goodies","forks_url":"https://api.github.com/repos/sonatype/goodies/forks","keys_url":"https://api.github.com/repos/sonatype/goodies/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonatype/goodies/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonatype/goodies/teams","hooks_url":"https://api.github.com/repos/sonatype/goodies/hooks","issue_events_url":"https://api.github.com/repos/sonatype/goodies/issues/events{/number}","events_url":"https://api.github.com/repos/sonatype/goodies/events","assignees_url":"https://api.github.com/repos/sonatype/goodies/assignees{/user}","branches_url":"https://api.github.com/repos/sonatype/goodies/branches{/branch}","tags_url":"https://api.github.com/repos/sonatype/goodies/tags","blobs_url":"https://api.github.com/repos/sonatype/goodies/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonatype/goodies/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonatype/goodies/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonatype/goodies/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonatype/goodies/statuses/{sha}","languages_url":"https://api.github.com/repos/sonatype/goodies/languages","stargazers_url":"https://api.github.com/repos/sonatype/goodies/stargazers","contributors_url":"https://api.github.com/repos/sonatype/goodies/contributors","subscribers_url":"https://api.github.com/repos/sonatype/goodies/subscribers","subscription_url":"https://api.github.com/repos/sonatype/goodies/subscription","commits_url":"https://api.github.com/repos/sonatype/goodies/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonatype/goodies/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonatype/goodies/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonatype/goodies/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonatype/goodies/contents/{+path}","compare_url":"https://api.github.com/repos/sonatype/goodies/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonatype/goodies/merges","archive_url":"https://api.github.com/repos/sonatype/goodies/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonatype/goodies/downloads","issues_url":"https://api.github.com/repos/sonatype/goodies/issues{/number}","pulls_url":"https://api.github.com/repos/sonatype/goodies/pulls{/number}","milestones_url":"https://api.github.com/repos/sonatype/goodies/milestones{/number}","notifications_url":"https://api.github.com/repos/sonatype/goodies/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonatype/goodies/labels{/name}","releases_url":"https://api.github.com/repos/sonatype/goodies/releases{/id}","created_at":"2011-11-02T21:23:34Z","updated_at":"2015-09-12T19:57:52Z","pushed_at":"2015-09-22T19:45:08Z","git_url":"git://github.com/sonatype/goodies.git","ssh_url":"git@github.com:sonatype/goodies.git","clone_url":"https://github.com/sonatype/goodies.git","svn_url":"https://github.com/sonatype/goodies","homepage":"","size":2183,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sonatype/goodies/pulls/43"},"html":{"href":"https://github.com/sonatype/goodies/pull/43"},"issue":{"href":"https://api.github.com/repos/sonatype/goodies/issues/43"},"comments":{"href":"https://api.github.com/repos/sonatype/goodies/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/sonatype/goodies/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/sonatype/goodies/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sonatype/goodies/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/sonatype/goodies/statuses/0fd9ac211e1e69b082b687a201a8e212f9051b8c"}}}}