diff options
| author | Aditya Wasan <adityawasan55@gmail.com> | 2020-07-01 00:00:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 00:00:02 +0530 |
| commit | 82a9a6125473dbffa6a76f33c6ff83b4a1bd69b3 (patch) | |
| tree | 965c887adfb0c5603f6e8f9dbcbd04d4d1011904 /app/src/main/java/com/zeapo/pwdstore/git/config | |
| parent | e11ef1ca1d504bcccf73e75c3782cce2c8fc4bec (diff) | |
| download | HardenedPass-82a9a6125473dbffa6a76f33c6ff83b4a1bd69b3.tar.gz HardenedPass-82a9a6125473dbffa6a76f33c6ff83b4a1bd69b3.zip | |
Use PreferenceKeys file to manage SharedPreferences keys. (#891)
* Use PreferenceKeys file to manage SharedPreferences keys.
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Use PreferenceKeys in all files
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Divide PreferenceKeys into multiple regions
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Fix build error
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Use PreferenceKeys in more files
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Reformat code
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Fix build error
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
* Fix merge issues
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/config')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/git/config/SshApiSessionFactory.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/config/SshApiSessionFactory.java b/app/src/main/java/com/zeapo/pwdstore/git/config/SshApiSessionFactory.java index e5a5fd17..5ad12ef8 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/config/SshApiSessionFactory.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/config/SshApiSessionFactory.java @@ -21,6 +21,7 @@ import com.jcraft.jsch.Session; import com.jcraft.jsch.UserInfo; import com.zeapo.pwdstore.R; import com.zeapo.pwdstore.git.BaseGitActivity; +import com.zeapo.pwdstore.utils.PreferenceKeys; import org.eclipse.jgit.errors.UnsupportedCredentialItem; import org.eclipse.jgit.transport.CredentialItem; @@ -51,8 +52,8 @@ public class SshApiSessionFactory extends JschConfigSessionFactory { */ public static final int POST_SIGNATURE = 301; - private String username; - private Identity identity; + private final String username; + private final Identity identity; public SshApiSessionFactory(String username, Identity identity) { this.username = username; @@ -108,12 +109,12 @@ public class SshApiSessionFactory extends JschConfigSessionFactory { * build. */ public static class IdentityBuilder { - private SshAuthenticationConnection connection; + private final SshAuthenticationConnection connection; private SshAuthenticationApi api; private String keyId, description, alg; private byte[] publicKey; - private BaseGitActivity callingActivity; - private SharedPreferences settings; + private final BaseGitActivity callingActivity; + private final SharedPreferences settings; /** * Construct a new IdentityBuilder @@ -137,7 +138,7 @@ public class SshApiSessionFactory extends JschConfigSessionFactory { settings = PreferenceManager.getDefaultSharedPreferences( callingActivity.getApplicationContext()); - keyId = settings.getString("ssh_openkeystore_keyid", null); + keyId = settings.getString(PreferenceKeys.SSH_OPENKEYSTORE_KEYID, null); } /** @@ -163,7 +164,7 @@ public class SshApiSessionFactory extends JschConfigSessionFactory { SshAuthenticationApiError error = result.getParcelableExtra(SshAuthenticationApi.EXTRA_ERROR); // On an OpenKeychain SSH API error, clear out the stored keyid - settings.edit().putString("ssh_openkeystore_keyid", null).apply(); + settings.edit().putString(PreferenceKeys.SSH_OPENKEYSTORE_KEYID, null).apply(); switch (error.getError()) { // If the problem was just a bad keyid, reset to allow them to choose a @@ -214,7 +215,7 @@ public class SshApiSessionFactory extends JschConfigSessionFactory { if (intent.hasExtra(SshAuthenticationApi.EXTRA_KEY_ID)) { keyId = intent.getStringExtra(SshAuthenticationApi.EXTRA_KEY_ID); description = intent.getStringExtra(SshAuthenticationApi.EXTRA_KEY_DESCRIPTION); - settings.edit().putString("ssh_openkeystore_keyid", keyId).apply(); + settings.edit().putString(PreferenceKeys.SSH_OPENKEYSTORE_KEYID, keyId).apply(); } if (intent.hasExtra(SshAuthenticationApi.EXTRA_SSH_PUBLIC_KEY)) { @@ -284,10 +285,12 @@ public class SshApiSessionFactory extends JschConfigSessionFactory { * A Jsch identity that delegates key operations via the OpenKeychain SSH API */ public static class ApiIdentity implements Identity { - private String keyId, description, alg; - private byte[] publicKey; - private Activity callingActivity; - private SshAuthenticationApi api; + private final String keyId; + private final String description; + private final String alg; + private final byte[] publicKey; + private final Activity callingActivity; + private final SshAuthenticationApi api; private CountDownLatch latch; private byte[] signature; |
