{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/comments/47373178","id":47373178,"diff_hunk":"@@ -182,11 +201,26 @@ private void add(TaskListener listener, SCMSourceObserver observer, GHRepository\n             return new GitHubSCMNavigator(\"\", name, \"\", AbstractGitHubSCMSource.AbstractGitHubSCMSourceDescriptor.SAME);\n         }\n \n-        public FormValidation doCheckScanCredentialsId(@QueryParameter String value) {\n-            if (!value.isEmpty()) {\n-                return FormValidation.ok();\n+        @Restricted(NoExternalUse.class)\n+        public FormValidation doCheckScanCredentialsId(@AncestorInPath SCMSourceOwner context,\n+                @QueryParameter String scanCredentialsId, @QueryParameter String apiUri) {\n+            if (!scanCredentialsId.isEmpty()) {\n+                StandardCredentials credentials = Connector.lookupScanCredentials(context, apiUri, scanCredentialsId);\n+                if (credentials == null) {\n+                    FormValidation.error(\"Invalid credentials\");\n+                } else {\n+                    try {\n+                        GitHub connector = Connector.connect(apiUri, credentials);\n+                        if (connector.isCredentialValid()) {\n+                            return FormValidation.ok();\n+                        }\n+                    } catch (IOException e) {\n+                        // ignore, never thrown\n+                    }\n+                }\n+                return FormValidation.error(\"Invalid credentials\");\n             } else {\n-                return FormValidation.warning(\"Credentials are required\");\n+                return FormValidation.warning(\"Credentials are recommended\");","path":"src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java","position":123,"original_position":123,"commit_id":"b8bdb54e1e7eeaa01941f49703009eb99a3041fe","original_commit_id":"b8bdb54e1e7eeaa01941f49703009eb99a3041fe","user":{"login":"recena","id":1021745,"avatar_url":"https://avatars.githubusercontent.com/u/1021745?v=3","gravatar_id":"","url":"https://api.github.com/users/recena","html_url":"https://github.com/recena","followers_url":"https://api.github.com/users/recena/followers","following_url":"https://api.github.com/users/recena/following{/other_user}","gists_url":"https://api.github.com/users/recena/gists{/gist_id}","starred_url":"https://api.github.com/users/recena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/recena/subscriptions","organizations_url":"https://api.github.com/users/recena/orgs","repos_url":"https://api.github.com/users/recena/repos","events_url":"https://api.github.com/users/recena/events{/privacy}","received_events_url":"https://api.github.com/users/recena/received_events","type":"User","site_admin":false},"body":"Well, this is only a validation message. That recommendation should be in the documentation.","created_at":"2015-12-11T16:23:29Z","updated_at":"2015-12-11T16:23:29Z","html_url":"https://github.com/jenkinsci/github-branch-source-plugin/pull/11#discussion_r47373178","pull_request_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/comments/47373178"},"html":{"href":"https://github.com/jenkinsci/github-branch-source-plugin/pull/11#discussion_r47373178"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11","id":51521705,"html_url":"https://github.com/jenkinsci/github-branch-source-plugin/pull/11","diff_url":"https://github.com/jenkinsci/github-branch-source-plugin/pull/11.diff","patch_url":"https://github.com/jenkinsci/github-branch-source-plugin/pull/11.patch","issue_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues/11","number":11,"state":"open","locked":false,"title":"[JENKINS-31574] Improved validation for Scan Credentials","user":{"login":"recena","id":1021745,"avatar_url":"https://avatars.githubusercontent.com/u/1021745?v=3","gravatar_id":"","url":"https://api.github.com/users/recena","html_url":"https://github.com/recena","followers_url":"https://api.github.com/users/recena/followers","following_url":"https://api.github.com/users/recena/following{/other_user}","gists_url":"https://api.github.com/users/recena/gists{/gist_id}","starred_url":"https://api.github.com/users/recena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/recena/subscriptions","organizations_url":"https://api.github.com/users/recena/orgs","repos_url":"https://api.github.com/users/recena/repos","events_url":"https://api.github.com/users/recena/events{/privacy}","received_events_url":"https://api.github.com/users/recena/received_events","type":"User","site_admin":false},"body":"[JENKINS-31574](https://issues.jenkins-ci.org/browse/JENKINS-31574)\r\n\r\n- [x] Improve error handling\r\n- [x] Anonymous (none) is a option valid for Scan Credentials\r\n- [x] Implement a `RateLimitHandler`. Used in anonymous connections.\r\n\r\n### Form validation\r\n\r\n![jenkins-31574_1](https://cloud.githubusercontent.com/assets/1021745/11340751/ba538b7a-91ff-11e5-8db8-7f133d69d416.png)\r\n\r\n### Behavior with error handling in place\r\n\r\n![jenkins-31574_2](https://cloud.githubusercontent.com/assets/1021745/11340787/e1302744-91ff-11e5-8e43-279480fb7fe5.png)\r\n\r\n\r\n@reviewbybees","created_at":"2015-11-23T13:17:28Z","updated_at":"2015-12-11T16:23:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e66f70abe8a3a2530b71b4cccfac6de8ded7bd47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues/11/comments","statuses_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/statuses/b8bdb54e1e7eeaa01941f49703009eb99a3041fe","head":{"label":"recena:JENKINS-31574","ref":"JENKINS-31574","sha":"b8bdb54e1e7eeaa01941f49703009eb99a3041fe","user":{"login":"recena","id":1021745,"avatar_url":"https://avatars.githubusercontent.com/u/1021745?v=3","gravatar_id":"","url":"https://api.github.com/users/recena","html_url":"https://github.com/recena","followers_url":"https://api.github.com/users/recena/followers","following_url":"https://api.github.com/users/recena/following{/other_user}","gists_url":"https://api.github.com/users/recena/gists{/gist_id}","starred_url":"https://api.github.com/users/recena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/recena/subscriptions","organizations_url":"https://api.github.com/users/recena/orgs","repos_url":"https://api.github.com/users/recena/repos","events_url":"https://api.github.com/users/recena/events{/privacy}","received_events_url":"https://api.github.com/users/recena/received_events","type":"User","site_admin":false},"repo":{"id":44967991,"name":"github-branch-source-plugin","full_name":"recena/github-branch-source-plugin","owner":{"login":"recena","id":1021745,"avatar_url":"https://avatars.githubusercontent.com/u/1021745?v=3","gravatar_id":"","url":"https://api.github.com/users/recena","html_url":"https://github.com/recena","followers_url":"https://api.github.com/users/recena/followers","following_url":"https://api.github.com/users/recena/following{/other_user}","gists_url":"https://api.github.com/users/recena/gists{/gist_id}","starred_url":"https://api.github.com/users/recena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/recena/subscriptions","organizations_url":"https://api.github.com/users/recena/orgs","repos_url":"https://api.github.com/users/recena/repos","events_url":"https://api.github.com/users/recena/events{/privacy}","received_events_url":"https://api.github.com/users/recena/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/recena/github-branch-source-plugin","description":"","fork":true,"url":"https://api.github.com/repos/recena/github-branch-source-plugin","forks_url":"https://api.github.com/repos/recena/github-branch-source-plugin/forks","keys_url":"https://api.github.com/repos/recena/github-branch-source-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/recena/github-branch-source-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/recena/github-branch-source-plugin/teams","hooks_url":"https://api.github.com/repos/recena/github-branch-source-plugin/hooks","issue_events_url":"https://api.github.com/repos/recena/github-branch-source-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/recena/github-branch-source-plugin/events","assignees_url":"https://api.github.com/repos/recena/github-branch-source-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/recena/github-branch-source-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/recena/github-branch-source-plugin/tags","blobs_url":"https://api.github.com/repos/recena/github-branch-source-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/recena/github-branch-source-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/recena/github-branch-source-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/recena/github-branch-source-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/recena/github-branch-source-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/recena/github-branch-source-plugin/languages","stargazers_url":"https://api.github.com/repos/recena/github-branch-source-plugin/stargazers","contributors_url":"https://api.github.com/repos/recena/github-branch-source-plugin/contributors","subscribers_url":"https://api.github.com/repos/recena/github-branch-source-plugin/subscribers","subscription_url":"https://api.github.com/repos/recena/github-branch-source-plugin/subscription","commits_url":"https://api.github.com/repos/recena/github-branch-source-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/recena/github-branch-source-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/recena/github-branch-source-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/recena/github-branch-source-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/recena/github-branch-source-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/recena/github-branch-source-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/recena/github-branch-source-plugin/merges","archive_url":"https://api.github.com/repos/recena/github-branch-source-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/recena/github-branch-source-plugin/downloads","issues_url":"https://api.github.com/repos/recena/github-branch-source-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/recena/github-branch-source-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/recena/github-branch-source-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/recena/github-branch-source-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/recena/github-branch-source-plugin/labels{/name}","releases_url":"https://api.github.com/repos/recena/github-branch-source-plugin/releases{/id}","created_at":"2015-10-26T12:50:58Z","updated_at":"2015-10-26T12:50:59Z","pushed_at":"2015-12-11T10:42:45Z","git_url":"git://github.com/recena/github-branch-source-plugin.git","ssh_url":"git@github.com:recena/github-branch-source-plugin.git","clone_url":"https://github.com/recena/github-branch-source-plugin.git","svn_url":"https://github.com/recena/github-branch-source-plugin","homepage":null,"size":60,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"384e7a983e15df1a0671a2579f5ab67f7897cbba","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":43903637,"name":"github-branch-source-plugin","full_name":"jenkinsci/github-branch-source-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/github-branch-source-plugin","description":"","fork":true,"url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin","forks_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/releases{/id}","created_at":"2015-10-08T16:52:19Z","updated_at":"2015-12-02T20:41:39Z","pushed_at":"2015-12-11T10:42:46Z","git_url":"git://github.com/jenkinsci/github-branch-source-plugin.git","ssh_url":"git@github.com:jenkinsci/github-branch-source-plugin.git","clone_url":"https://github.com/jenkinsci/github-branch-source-plugin.git","svn_url":"https://github.com/jenkinsci/github-branch-source-plugin","homepage":null,"size":93,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11"},"html":{"href":"https://github.com/jenkinsci/github-branch-source-plugin/pull/11"},"issue":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues/11"},"comments":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/github-branch-source-plugin/statuses/b8bdb54e1e7eeaa01941f49703009eb99a3041fe"}}}}