{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments/50831291","id":50831291,"diff_hunk":"@@ -91,15 +105,53 @@ public static String makeRandomId(int l) {\n         return new String(id);\n     }\n \n+    /**\n+     *\n+     * @param length of password to be returned\n+     * @return randomly generated password containing at least one of each upper case,\n+     * lower case, numeric, and non alpha-numeric characters.  Hopefully this is acceptible\n+     * for most password schemes.\n+     */\n+    public static String makeRandomPassword(final int length) {\n+        return makeRandomPassword(length, UPPER_CASE_ALPHA, LOWER_CASE_ALPHA, NUMERIC, NON_ALPHA_NUMERIC, PASSWORD_VALID_CHARS);\n+    }\n+\n+    /**\n+     * A fairly slow but hopefully secure way to randomly select characters for a password\n+     * Takes a pool of acceptible characters using the first set in the pool for the first character,\n+     * second set for the second character, ..., nth set for all remaining character.\n+     *\n+     * @param length length of password\n+     * @param passwordValidCharsPool pool of acceptable character sets\n+     * @return a randomly generated password\n+     */\n+    public static String makeRandomPassword(final int length, String... passwordValidCharsPool) {\n+        Preconditions.checkState(length >= passwordValidCharsPool.length);\n+        int l = 0;\n+\n+        char[] id = new char[length];\n+\n+        for(int i = 0; i < passwordValidCharsPool.length; i++){\n+            id[l++] = pickRandomCharFrom(passwordValidCharsPool[i]);\n+        }\n+\n+        String remainingValidChars = passwordValidCharsPool[passwordValidCharsPool.length - 1];","path":"brooklyn-server/utils/common/src/main/java/org/apache/brooklyn/util/text/Identifiers.java","position":92,"original_position":92,"commit_id":"50f70fe5be5bdac65f446e8309fcf703f36c08ba","original_commit_id":"50f70fe5be5bdac65f446e8309fcf703f36c08ba","user":{"login":"aledsage","id":593113,"avatar_url":"https://avatars.githubusercontent.com/u/593113?v=3","gravatar_id":"","url":"https://api.github.com/users/aledsage","html_url":"https://github.com/aledsage","followers_url":"https://api.github.com/users/aledsage/followers","following_url":"https://api.github.com/users/aledsage/following{/other_user}","gists_url":"https://api.github.com/users/aledsage/gists{/gist_id}","starred_url":"https://api.github.com/users/aledsage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aledsage/subscriptions","organizations_url":"https://api.github.com/users/aledsage/orgs","repos_url":"https://api.github.com/users/aledsage/repos","events_url":"https://api.github.com/users/aledsage/events{/privacy}","received_events_url":"https://api.github.com/users/aledsage/received_events","type":"User","site_admin":false},"body":"I'd concatenate all of the `passwordValidCharsPool` (optionally removing duplicate chars!), and choose the rest of the letters from that. But no strong feelings.","created_at":"2016-01-26T13:01:13Z","updated_at":"2016-01-26T13:01:13Z","html_url":"https://github.com/apache/incubator-brooklyn/pull/1169#discussion_r50831291","pull_request_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments/50831291"},"html":{"href":"https://github.com/apache/incubator-brooklyn/pull/1169#discussion_r50831291"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169","id":56784946,"html_url":"https://github.com/apache/incubator-brooklyn/pull/1169","diff_url":"https://github.com/apache/incubator-brooklyn/pull/1169.diff","patch_url":"https://github.com/apache/incubator-brooklyn/pull/1169.patch","issue_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/1169","number":1169,"state":"open","locked":false,"title":"Create Password Sensor","user":{"login":"duncangrant","id":770352,"avatar_url":"https://avatars.githubusercontent.com/u/770352?v=3","gravatar_id":"","url":"https://api.github.com/users/duncangrant","html_url":"https://github.com/duncangrant","followers_url":"https://api.github.com/users/duncangrant/followers","following_url":"https://api.github.com/users/duncangrant/following{/other_user}","gists_url":"https://api.github.com/users/duncangrant/gists{/gist_id}","starred_url":"https://api.github.com/users/duncangrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncangrant/subscriptions","organizations_url":"https://api.github.com/users/duncangrant/orgs","repos_url":"https://api.github.com/users/duncangrant/repos","events_url":"https://api.github.com/users/duncangrant/events{/privacy}","received_events_url":"https://api.github.com/users/duncangrant/received_events","type":"User","site_admin":false},"body":"A simple initialiser for creating passwords in yaml as a sensor\r\n\r\nAdded a password generating function in the Identifiers class which uses\r\nSecureRandom","created_at":"2016-01-21T17:51:48Z","updated_at":"2016-01-26T13:01:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5aa6ab5be6f901e6918a74f660b79f7e15a868e6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/1169/comments","statuses_url":"https://api.github.com/repos/apache/incubator-brooklyn/statuses/50f70fe5be5bdac65f446e8309fcf703f36c08ba","head":{"label":"duncangrant:feature/add-password-sensor","ref":"feature/add-password-sensor","sha":"50f70fe5be5bdac65f446e8309fcf703f36c08ba","user":{"login":"duncangrant","id":770352,"avatar_url":"https://avatars.githubusercontent.com/u/770352?v=3","gravatar_id":"","url":"https://api.github.com/users/duncangrant","html_url":"https://github.com/duncangrant","followers_url":"https://api.github.com/users/duncangrant/followers","following_url":"https://api.github.com/users/duncangrant/following{/other_user}","gists_url":"https://api.github.com/users/duncangrant/gists{/gist_id}","starred_url":"https://api.github.com/users/duncangrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncangrant/subscriptions","organizations_url":"https://api.github.com/users/duncangrant/orgs","repos_url":"https://api.github.com/users/duncangrant/repos","events_url":"https://api.github.com/users/duncangrant/events{/privacy}","received_events_url":"https://api.github.com/users/duncangrant/received_events","type":"User","site_admin":false},"repo":{"id":27075253,"name":"incubator-brooklyn","full_name":"duncangrant/incubator-brooklyn","owner":{"login":"duncangrant","id":770352,"avatar_url":"https://avatars.githubusercontent.com/u/770352?v=3","gravatar_id":"","url":"https://api.github.com/users/duncangrant","html_url":"https://github.com/duncangrant","followers_url":"https://api.github.com/users/duncangrant/followers","following_url":"https://api.github.com/users/duncangrant/following{/other_user}","gists_url":"https://api.github.com/users/duncangrant/gists{/gist_id}","starred_url":"https://api.github.com/users/duncangrant/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duncangrant/subscriptions","organizations_url":"https://api.github.com/users/duncangrant/orgs","repos_url":"https://api.github.com/users/duncangrant/repos","events_url":"https://api.github.com/users/duncangrant/events{/privacy}","received_events_url":"https://api.github.com/users/duncangrant/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/duncangrant/incubator-brooklyn","description":"Mirror of Apache Brooklyn","fork":true,"url":"https://api.github.com/repos/duncangrant/incubator-brooklyn","forks_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/forks","keys_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/teams","hooks_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/hooks","issue_events_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/issues/events{/number}","events_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/events","assignees_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/assignees{/user}","branches_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/branches{/branch}","tags_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/tags","blobs_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/statuses/{sha}","languages_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/languages","stargazers_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/stargazers","contributors_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/contributors","subscribers_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/subscribers","subscription_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/subscription","commits_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/contents/{+path}","compare_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/merges","archive_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/downloads","issues_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/issues{/number}","pulls_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/pulls{/number}","milestones_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/milestones{/number}","notifications_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/labels{/name}","releases_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/releases{/id}","deployments_url":"https://api.github.com/repos/duncangrant/incubator-brooklyn/deployments","created_at":"2014-11-24T12:38:13Z","updated_at":"2014-11-24T12:38:21Z","pushed_at":"2016-01-21T17:42:35Z","git_url":"git://github.com/duncangrant/incubator-brooklyn.git","ssh_url":"git@github.com:duncangrant/incubator-brooklyn.git","clone_url":"https://github.com/duncangrant/incubator-brooklyn.git","svn_url":"https://github.com/duncangrant/incubator-brooklyn","homepage":null,"size":257096,"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":"apache:master","ref":"master","sha":"b28ba027e4aa5e0221bc5a1189466f3671f99b8a","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":19368221,"name":"incubator-brooklyn","full_name":"apache/incubator-brooklyn","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-brooklyn","description":"Mirror of Apache Brooklyn","fork":false,"url":"https://api.github.com/repos/apache/incubator-brooklyn","forks_url":"https://api.github.com/repos/apache/incubator-brooklyn/forks","keys_url":"https://api.github.com/repos/apache/incubator-brooklyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-brooklyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-brooklyn/teams","hooks_url":"https://api.github.com/repos/apache/incubator-brooklyn/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-brooklyn/events","assignees_url":"https://api.github.com/repos/apache/incubator-brooklyn/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-brooklyn/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-brooklyn/tags","blobs_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-brooklyn/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-brooklyn/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-brooklyn/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-brooklyn/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-brooklyn/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-brooklyn/subscription","commits_url":"https://api.github.com/repos/apache/incubator-brooklyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-brooklyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-brooklyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-brooklyn/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-brooklyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-brooklyn/merges","archive_url":"https://api.github.com/repos/apache/incubator-brooklyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-brooklyn/downloads","issues_url":"https://api.github.com/repos/apache/incubator-brooklyn/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-brooklyn/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-brooklyn/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-brooklyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-brooklyn/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-brooklyn/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-brooklyn/deployments","created_at":"2014-05-02T07:00:07Z","updated_at":"2016-01-23T08:51:12Z","pushed_at":"2016-01-26T12:54:40Z","git_url":"git://github.com/apache/incubator-brooklyn.git","ssh_url":"git@github.com:apache/incubator-brooklyn.git","clone_url":"https://github.com/apache/incubator-brooklyn.git","svn_url":"https://github.com/apache/incubator-brooklyn","homepage":null,"size":259413,"stargazers_count":143,"watchers_count":143,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":109,"mirror_url":"git://git.apache.org/incubator-brooklyn.git","open_issues_count":16,"forks":109,"open_issues":16,"watchers":143,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169"},"html":{"href":"https://github.com/apache/incubator-brooklyn/pull/1169"},"issue":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/issues/1169"},"comments":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/issues/1169/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/pulls/1169/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-brooklyn/statuses/50f70fe5be5bdac65f446e8309fcf703f36c08ba"}}}}