{"action":"created","comment":{"url":"https://api.github.com/repos/cgeo/cgeo/pulls/comments/232095855","pull_request_review_id":173216763,"id":232095855,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjA5NTg1NQ==","diff_hunk":"@@ -0,0 +1,186 @@\n+package cgeo.geocaching.connector.su;\n+\n+import android.app.Application;\n+import android.support.annotation.NonNull;\n+\n+import org.apache.commons.lang3.StringUtils;\n+\n+import java.util.regex.Pattern;\n+\n+import cgeo.geocaching.CgeoApplication;\n+import cgeo.geocaching.R;\n+import cgeo.geocaching.connector.AbstractLogin;\n+import cgeo.geocaching.enumerations.StatusCode;\n+import cgeo.geocaching.network.Network;\n+import cgeo.geocaching.network.OAuth;\n+import cgeo.geocaching.network.OAuthTokens;\n+import cgeo.geocaching.network.Parameters;\n+import cgeo.geocaching.settings.Credentials;\n+import cgeo.geocaching.settings.Settings;\n+import cgeo.geocaching.utils.Log;\n+import cgeo.geocaching.utils.MatcherWrapper;\n+import okhttp3.Response;\n+\n+public class SuLogin extends AbstractLogin {\n+\n+    private static final Pattern PARAMS_PATTERN_1 = Pattern.compile(\"oauth_token=([\\\\w_.-]+)\");\n+    private static final Pattern PARAMS_PATTERN_2 = Pattern.compile(\"oauth_token_secret=([\\\\w_.-]+)\");\n+    private static final String host = \"www.geocaching.su\";\n+    private static final String FULL_HOST_URL = \"http://\" + host;\n+    private static final String LOGON_PATH = \"/api/oauth/logon.php\";\n+    private static final String REQUEST_TOKEN_PATH = \"/api/oauth/request_token.php\";\n+    private static final String ACCESS_TOKEN_PATH = \"/api/oauth/access_token.php\";\n+    private static final String AUTHORIZE_TOKEN_PATH = \"/api/oauth/authorize.php\";\n+    private static String oAtoken;\n+    private static String oAtokenSecret;\n+\n+    private SuLogin() {\n+        // singleton\n+    }\n+\n+    @NonNull\n+    public static SuLogin getInstance() {\n+        return SingletonHolder.INSTANCE;\n+    }\n+\n+    @Override\n+    @NonNull\n+    protected StatusCode login(final boolean retry) {\n+        return login(retry, Settings.getCredentials(SuConnector.getInstance()));\n+    }\n+\n+    @NonNull\n+    public OAuthTokens getOAuthTokens() {\n+        return new OAuthTokens(oAtoken, oAtokenSecret);\n+    }\n+\n+    @Override\n+    @NonNull\n+    protected StatusCode login(final boolean retry, @NonNull final Credentials credentials) {\n+        if (credentials.isInvalid()) {\n+            clearLoginInfo();\n+            Log.w(\"SuLogin.login: No login information stored\");\n+            return StatusCode.NO_LOGIN_INFO_STORED;\n+        }\n+\n+        final Application application = CgeoApplication.getInstance();\n+        setActualStatus(application.getString(R.string.init_login_popup_working));\n+\n+        final Parameters params = new Parameters(\"username\", credentials.getUserName(), \"password\", credentials.getPassword());\n+\n+        final String loginData = Network.getResponseData(Network.postRequest(FULL_HOST_URL + LOGON_PATH, params));\n+\n+        if (StringUtils.isBlank(loginData)) {\n+            Log.e(\"SuLogin.login: Failed to retrieve login data\");\n+            setActualStatus(application.getString(R.string.init_login_popup_failed));\n+            return StatusCode.CONNECTION_FAILED_SU; // no login page\n+        }\n+\n+        if (!loginData.contains(\"Login succesful\")) { // hardcoded in English\n+            Log.i(\"Failed to log in Geocaching.su as \" + credentials.getUserName() + \" because of wrong username/password\");\n+            setActualStatus(application.getString(R.string.init_login_popup_failed));\n+            return StatusCode.WRONG_LOGIN_DATA; // wrong login\n+        }\n+\n+        setActualUserName(credentials.getUserName());\n+\n+        Log.i(\"Successfully logged in Geocaching.su as \" + credentials.getUserName());\n+        requestToken();\n+        authorizeToken();\n+        accessToken();\n+","path":"main/src/cgeo/geocaching/connector/su/SuLogin.java","position":null,"original_position":91,"commit_id":"d20fc0526a3109b0e702545220b3b05286feceea","original_commit_id":"56503ae0116790be8f719f67f4167e18c297188d","user":{"login":"okainov","id":918446,"node_id":"MDQ6VXNlcjkxODQ0Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/918446?v=4","gravatar_id":"","url":"https://api.github.com/users/okainov","html_url":"https://github.com/okainov","followers_url":"https://api.github.com/users/okainov/followers","following_url":"https://api.github.com/users/okainov/following{/other_user}","gists_url":"https://api.github.com/users/okainov/gists{/gist_id}","starred_url":"https://api.github.com/users/okainov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okainov/subscriptions","organizations_url":"https://api.github.com/users/okainov/orgs","repos_url":"https://api.github.com/users/okainov/repos","events_url":"https://api.github.com/users/okainov/events{/privacy}","received_events_url":"https://api.github.com/users/okainov/received_events","type":"User","site_admin":false},"body":"done","created_at":"2018-11-08T23:18:11Z","updated_at":"2018-11-08T23:18:11Z","html_url":"https://github.com/cgeo/cgeo/pull/7170#discussion_r232095855","pull_request_url":"https://api.github.com/repos/cgeo/cgeo/pulls/7170","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/cgeo/cgeo/pulls/comments/232095855"},"html":{"href":"https://github.com/cgeo/cgeo/pull/7170#discussion_r232095855"},"pull_request":{"href":"https://api.github.com/repos/cgeo/cgeo/pulls/7170"}},"in_reply_to_id":230040503},"pull_request":{"url":"https://api.github.com/repos/cgeo/cgeo/pulls/7170","id":226261614,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2MjYxNjE0","html_url":"https://github.com/cgeo/cgeo/pull/7170","diff_url":"https://github.com/cgeo/cgeo/pull/7170.diff","patch_url":"https://github.com/cgeo/cgeo/pull/7170.patch","issue_url":"https://api.github.com/repos/cgeo/cgeo/issues/7170","number":7170,"state":"open","locked":false,"title":"Implement authorization on geocaching.su","user":{"login":"okainov","id":918446,"node_id":"MDQ6VXNlcjkxODQ0Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/918446?v=4","gravatar_id":"","url":"https://api.github.com/users/okainov","html_url":"https://github.com/okainov","followers_url":"https://api.github.com/users/okainov/followers","following_url":"https://api.github.com/users/okainov/following{/other_user}","gists_url":"https://api.github.com/users/okainov/gists{/gist_id}","starred_url":"https://api.github.com/users/okainov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okainov/subscriptions","organizations_url":"https://api.github.com/users/okainov/orgs","repos_url":"https://api.github.com/users/okainov/repos","events_url":"https://api.github.com/users/okainov/events{/privacy}","received_events_url":"https://api.github.com/users/okainov/received_events","type":"User","site_admin":false},"body":"- Implement SU Authorization activity\r\n- Use new API for searching by geocode and map\r\n\r\n- [x] Using OAuth authorization\r\n- [x] Using new API for caches search\r\n- [x] Hiding current user's found caches on the map\r\n- [x] Postings logs\r\n- [x] Waypoints support. \r\n\r\n\r\nMostly implements #5269 \r\n\r\nThere are still several minor things to do (like posting images, checking watched caches), but main functionality is done, so I assume we can close never-ending #5269  and I'll implement the rest later","created_at":"2018-10-27T01:52:04Z","updated_at":"2018-11-08T23:18:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2436bef86f2e6d778a382dd7e66fca78d242144","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/cgeo/cgeo/pulls/7170/commits","review_comments_url":"https://api.github.com/repos/cgeo/cgeo/pulls/7170/comments","review_comment_url":"https://api.github.com/repos/cgeo/cgeo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cgeo/cgeo/issues/7170/comments","statuses_url":"https://api.github.com/repos/cgeo/cgeo/statuses/d20fc0526a3109b0e702545220b3b05286feceea","head":{"label":"okainov:su","ref":"su","sha":"d20fc0526a3109b0e702545220b3b05286feceea","user":{"login":"okainov","id":918446,"node_id":"MDQ6VXNlcjkxODQ0Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/918446?v=4","gravatar_id":"","url":"https://api.github.com/users/okainov","html_url":"https://github.com/okainov","followers_url":"https://api.github.com/users/okainov/followers","following_url":"https://api.github.com/users/okainov/following{/other_user}","gists_url":"https://api.github.com/users/okainov/gists{/gist_id}","starred_url":"https://api.github.com/users/okainov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okainov/subscriptions","organizations_url":"https://api.github.com/users/okainov/orgs","repos_url":"https://api.github.com/users/okainov/repos","events_url":"https://api.github.com/users/okainov/events{/privacy}","received_events_url":"https://api.github.com/users/okainov/received_events","type":"User","site_admin":false},"repo":{"id":66709827,"node_id":"MDEwOlJlcG9zaXRvcnk2NjcwOTgyNw==","name":"cgeo","full_name":"okainov/cgeo","private":false,"owner":{"login":"okainov","id":918446,"node_id":"MDQ6VXNlcjkxODQ0Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/918446?v=4","gravatar_id":"","url":"https://api.github.com/users/okainov","html_url":"https://github.com/okainov","followers_url":"https://api.github.com/users/okainov/followers","following_url":"https://api.github.com/users/okainov/following{/other_user}","gists_url":"https://api.github.com/users/okainov/gists{/gist_id}","starred_url":"https://api.github.com/users/okainov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/okainov/subscriptions","organizations_url":"https://api.github.com/users/okainov/orgs","repos_url":"https://api.github.com/users/okainov/repos","events_url":"https://api.github.com/users/okainov/events{/privacy}","received_events_url":"https://api.github.com/users/okainov/received_events","type":"User","site_admin":false},"html_url":"https://github.com/okainov/cgeo","description":"c:geo - The powerful Android geocaching app.","fork":true,"url":"https://api.github.com/repos/okainov/cgeo","forks_url":"https://api.github.com/repos/okainov/cgeo/forks","keys_url":"https://api.github.com/repos/okainov/cgeo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/okainov/cgeo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/okainov/cgeo/teams","hooks_url":"https://api.github.com/repos/okainov/cgeo/hooks","issue_events_url":"https://api.github.com/repos/okainov/cgeo/issues/events{/number}","events_url":"https://api.github.com/repos/okainov/cgeo/events","assignees_url":"https://api.github.com/repos/okainov/cgeo/assignees{/user}","branches_url":"https://api.github.com/repos/okainov/cgeo/branches{/branch}","tags_url":"https://api.github.com/repos/okainov/cgeo/tags","blobs_url":"https://api.github.com/repos/okainov/cgeo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/okainov/cgeo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/okainov/cgeo/git/refs{/sha}","trees_url":"https://api.github.com/repos/okainov/cgeo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/okainov/cgeo/statuses/{sha}","languages_url":"https://api.github.com/repos/okainov/cgeo/languages","stargazers_url":"https://api.github.com/repos/okainov/cgeo/stargazers","contributors_url":"https://api.github.com/repos/okainov/cgeo/contributors","subscribers_url":"https://api.github.com/repos/okainov/cgeo/subscribers","subscription_url":"https://api.github.com/repos/okainov/cgeo/subscription","commits_url":"https://api.github.com/repos/okainov/cgeo/commits{/sha}","git_commits_url":"https://api.github.com/repos/okainov/cgeo/git/commits{/sha}","comments_url":"https://api.github.com/repos/okainov/cgeo/comments{/number}","issue_comment_url":"https://api.github.com/repos/okainov/cgeo/issues/comments{/number}","contents_url":"https://api.github.com/repos/okainov/cgeo/contents/{+path}","compare_url":"https://api.github.com/repos/okainov/cgeo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/okainov/cgeo/merges","archive_url":"https://api.github.com/repos/okainov/cgeo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/okainov/cgeo/downloads","issues_url":"https://api.github.com/repos/okainov/cgeo/issues{/number}","pulls_url":"https://api.github.com/repos/okainov/cgeo/pulls{/number}","milestones_url":"https://api.github.com/repos/okainov/cgeo/milestones{/number}","notifications_url":"https://api.github.com/repos/okainov/cgeo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/okainov/cgeo/labels{/name}","releases_url":"https://api.github.com/repos/okainov/cgeo/releases{/id}","deployments_url":"https://api.github.com/repos/okainov/cgeo/deployments","created_at":"2016-08-27T10:49:40Z","updated_at":"2018-08-26T16:17:05Z","pushed_at":"2018-11-08T23:17:50Z","git_url":"git://github.com/okainov/cgeo.git","ssh_url":"git@github.com:okainov/cgeo.git","clone_url":"https://github.com/okainov/cgeo.git","svn_url":"https://github.com/okainov/cgeo","homepage":"www.cgeo.org","size":300873,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"cgeo:master","ref":"master","sha":"f326083c0c988b8a2d9281fba8ac2fab2a5cad2a","user":{"login":"cgeo","id":907088,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkwNzA4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/907088?v=4","gravatar_id":"","url":"https://api.github.com/users/cgeo","html_url":"https://github.com/cgeo","followers_url":"https://api.github.com/users/cgeo/followers","following_url":"https://api.github.com/users/cgeo/following{/other_user}","gists_url":"https://api.github.com/users/cgeo/gists{/gist_id}","starred_url":"https://api.github.com/users/cgeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgeo/subscriptions","organizations_url":"https://api.github.com/users/cgeo/orgs","repos_url":"https://api.github.com/users/cgeo/repos","events_url":"https://api.github.com/users/cgeo/events{/privacy}","received_events_url":"https://api.github.com/users/cgeo/received_events","type":"Organization","site_admin":false},"repo":{"id":2028724,"node_id":"MDEwOlJlcG9zaXRvcnkyMDI4NzI0","name":"cgeo","full_name":"cgeo/cgeo","private":false,"owner":{"login":"cgeo","id":907088,"node_id":"MDEyOk9yZ2FuaXphdGlvbjkwNzA4OA==","avatar_url":"https://avatars0.githubusercontent.com/u/907088?v=4","gravatar_id":"","url":"https://api.github.com/users/cgeo","html_url":"https://github.com/cgeo","followers_url":"https://api.github.com/users/cgeo/followers","following_url":"https://api.github.com/users/cgeo/following{/other_user}","gists_url":"https://api.github.com/users/cgeo/gists{/gist_id}","starred_url":"https://api.github.com/users/cgeo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgeo/subscriptions","organizations_url":"https://api.github.com/users/cgeo/orgs","repos_url":"https://api.github.com/users/cgeo/repos","events_url":"https://api.github.com/users/cgeo/events{/privacy}","received_events_url":"https://api.github.com/users/cgeo/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/cgeo/cgeo","description":"c:geo - The powerful Android geocaching app.","fork":false,"url":"https://api.github.com/repos/cgeo/cgeo","forks_url":"https://api.github.com/repos/cgeo/cgeo/forks","keys_url":"https://api.github.com/repos/cgeo/cgeo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cgeo/cgeo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cgeo/cgeo/teams","hooks_url":"https://api.github.com/repos/cgeo/cgeo/hooks","issue_events_url":"https://api.github.com/repos/cgeo/cgeo/issues/events{/number}","events_url":"https://api.github.com/repos/cgeo/cgeo/events","assignees_url":"https://api.github.com/repos/cgeo/cgeo/assignees{/user}","branches_url":"https://api.github.com/repos/cgeo/cgeo/branches{/branch}","tags_url":"https://api.github.com/repos/cgeo/cgeo/tags","blobs_url":"https://api.github.com/repos/cgeo/cgeo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cgeo/cgeo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cgeo/cgeo/git/refs{/sha}","trees_url":"https://api.github.com/repos/cgeo/cgeo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cgeo/cgeo/statuses/{sha}","languages_url":"https://api.github.com/repos/cgeo/cgeo/languages","stargazers_url":"https://api.github.com/repos/cgeo/cgeo/stargazers","contributors_url":"https://api.github.com/repos/cgeo/cgeo/contributors","subscribers_url":"https://api.github.com/repos/cgeo/cgeo/subscribers","subscription_url":"https://api.github.com/repos/cgeo/cgeo/subscription","commits_url":"https://api.github.com/repos/cgeo/cgeo/commits{/sha}","git_commits_url":"https://api.github.com/repos/cgeo/cgeo/git/commits{/sha}","comments_url":"https://api.github.com/repos/cgeo/cgeo/comments{/number}","issue_comment_url":"https://api.github.com/repos/cgeo/cgeo/issues/comments{/number}","contents_url":"https://api.github.com/repos/cgeo/cgeo/contents/{+path}","compare_url":"https://api.github.com/repos/cgeo/cgeo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cgeo/cgeo/merges","archive_url":"https://api.github.com/repos/cgeo/cgeo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cgeo/cgeo/downloads","issues_url":"https://api.github.com/repos/cgeo/cgeo/issues{/number}","pulls_url":"https://api.github.com/repos/cgeo/cgeo/pulls{/number}","milestones_url":"https://api.github.com/repos/cgeo/cgeo/milestones{/number}","notifications_url":"https://api.github.com/repos/cgeo/cgeo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cgeo/cgeo/labels{/name}","releases_url":"https://api.github.com/repos/cgeo/cgeo/releases{/id}","deployments_url":"https://api.github.com/repos/cgeo/cgeo/deployments","created_at":"2011-07-11T06:02:47Z","updated_at":"2018-11-08T22:32:06Z","pushed_at":"2018-11-08T23:17:52Z","git_url":"git://github.com/cgeo/cgeo.git","ssh_url":"git@github.com:cgeo/cgeo.git","clone_url":"https://github.com/cgeo/cgeo.git","svn_url":"https://github.com/cgeo/cgeo","homepage":"www.cgeo.org","size":300770,"stargazers_count":866,"watchers_count":866,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":490,"mirror_url":null,"archived":false,"open_issues_count":544,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":490,"open_issues":544,"watchers":866,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cgeo/cgeo/pulls/7170"},"html":{"href":"https://github.com/cgeo/cgeo/pull/7170"},"issue":{"href":"https://api.github.com/repos/cgeo/cgeo/issues/7170"},"comments":{"href":"https://api.github.com/repos/cgeo/cgeo/issues/7170/comments"},"review_comments":{"href":"https://api.github.com/repos/cgeo/cgeo/pulls/7170/comments"},"review_comment":{"href":"https://api.github.com/repos/cgeo/cgeo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cgeo/cgeo/pulls/7170/commits"},"statuses":{"href":"https://api.github.com/repos/cgeo/cgeo/statuses/d20fc0526a3109b0e702545220b3b05286feceea"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"okainov"}}