]> nmode's Git Repositories - signal-cli/commitdiff
Fix coding issues v0.0.3
authorAsamK <asamk@gmx.de>
Fri, 7 Aug 2015 11:22:15 +0000 (13:22 +0200)
committerAsamK <asamk@gmx.de>
Fri, 7 Aug 2015 11:22:15 +0000 (13:22 +0200)
src/main/java/cli/JsonAxolotlStore.java
src/main/java/cli/JsonIdentityKeyStore.java
src/main/java/cli/JsonPreKeyStore.java
src/main/java/cli/JsonSessionStore.java
src/main/java/cli/JsonSignedPreKeyStore.java
src/main/java/cli/Main.java
src/main/java/cli/Manager.java
src/main/java/cli/Util.java
src/main/java/cli/WhisperTrustStore.java

index d260b6b07ba2a02fa38f7b3a861d236d2b5e96b9..02b9cdf1bc3ce152922556257c90781f81bc17fc 100644 (file)
@@ -10,7 +10,7 @@ import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
 import java.io.IOException;
 import java.util.List;
 
-public class JsonAxolotlStore implements AxolotlStore {
+class JsonAxolotlStore implements AxolotlStore {
     private final JsonPreKeyStore preKeyStore;
     private final JsonSessionStore sessionStore;
     private final JsonSignedPreKeyStore signedPreKeyStore;
index 75e6ba06945238e1fa87212fff70cd665742161a..827bf055d0e8c52963d395e4a2d269995e395382 100644 (file)
@@ -11,7 +11,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-public class JsonIdentityKeyStore implements IdentityKeyStore {
+class JsonIdentityKeyStore implements IdentityKeyStore {
 
     private final Map<String, IdentityKey> trustedKeys = new HashMap<>();
 
index 63e7ea774cd5db9aa29e83129666924d5459b8ef..a0133ec8e41ca77fdadbe5fe9c52feb972df00d7 100644 (file)
@@ -10,7 +10,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 
-public class JsonPreKeyStore implements PreKeyStore {
+class JsonPreKeyStore implements PreKeyStore {
 
     private final Map<Integer, byte[]> store = new HashMap<>();
 
@@ -18,7 +18,7 @@ public class JsonPreKeyStore implements PreKeyStore {
 
     }
 
-    public JsonPreKeyStore(JSONArray list) throws IOException {
+    public JsonPreKeyStore(JSONArray list) {
         for (int i = 0; i < list.length(); i++) {
             JSONObject k = list.getJSONObject(i);
             try {
index c034fc2cd47b06b41e8de62249021a291e8345cd..d2fe0a4a7c428b387f44fa48ff3d4330d28fb49b 100644 (file)
@@ -9,15 +9,15 @@ import org.whispersystems.libaxolotl.state.SessionStore;
 import java.io.IOException;
 import java.util.*;
 
-public class JsonSessionStore implements SessionStore {
+class JsonSessionStore implements SessionStore {
 
-    private Map<AxolotlAddress, byte[]> sessions = new HashMap<>();
+    private final Map<AxolotlAddress, byte[]> sessions = new HashMap<>();
 
     public JsonSessionStore() {
 
     }
 
-    public JsonSessionStore(JSONArray list) throws IOException {
+    public JsonSessionStore(JSONArray list) {
         for (int i = 0; i < list.length(); i++) {
             JSONObject k = list.getJSONObject(i);
             try {
index 5b24c8dc6b6c07a6db7bb10f35969c3d76172d2f..f992d2d6101318fb622577e719866fa06a451d4b 100644 (file)
@@ -12,7 +12,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-public class JsonSignedPreKeyStore implements SignedPreKeyStore {
+class JsonSignedPreKeyStore implements SignedPreKeyStore {
 
     private final Map<Integer, byte[]> store = new HashMap<>();
 
@@ -20,7 +20,7 @@ public class JsonSignedPreKeyStore implements SignedPreKeyStore {
 
     }
 
-    public JsonSignedPreKeyStore(JSONArray list) throws IOException {
+    public JsonSignedPreKeyStore(JSONArray list) {
         for (int i = 0; i < list.length(); i++) {
             JSONObject k = list.getJSONObject(i);
             try {
index cc7495912400c7edb98dd774ba5945f178f473dc..319ca42ae1cf4c9512440ac01b460b1c0683fe41 100644 (file)
@@ -232,7 +232,7 @@ public class Main {
     }
 
     private static class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
-        Manager m;
+        final Manager m;
 
         public ReceiveMessageHandler(Manager m) {
             this.m = m;
index 49043832268d56f562007ce6e195280c94ad3aa7..5650921d5d568b750750ffff55f7ff0e883e7b32 100644 (file)
@@ -47,7 +47,7 @@ import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-public class Manager {
+class Manager {
     private final static String URL = "https://textsecure-service.whispersystems.org";
     private final static TrustStore TRUST_STORE = new WhisperTrustStore();
 
@@ -64,7 +64,7 @@ public class Manager {
     private boolean registered = false;
 
     private JsonAxolotlStore axolotlStore;
-    TextSecureAccountManager accountManager;
+    private TextSecureAccountManager accountManager;
 
     public Manager(String username) {
         this.username = username;
@@ -77,10 +77,7 @@ public class Manager {
 
     public boolean userExists() {
         File f = new File(getFileName());
-        if (!f.exists() || f.isDirectory()) {
-            return false;
-        }
-        return true;
+        return !(!f.exists() || f.isDirectory());
     }
 
     public boolean userHasKeys() {
@@ -124,7 +121,6 @@ public class Manager {
             writer.close();
         } catch (Exception e) {
             System.out.println("Saving file error: " + e.getMessage());
-            return;
         }
     }
 
@@ -300,12 +296,12 @@ public class Manager {
         return outputFile;
     }
 
-    public String canonicalizeNumber(String number) throws InvalidNumberException {
+    private String canonicalizeNumber(String number) throws InvalidNumberException {
         String localNumber = username;
         return PhoneNumberFormatter.formatNumber(number, localNumber);
     }
 
-    protected TextSecureAddress getPushAddress(String number) throws InvalidNumberException {
+    TextSecureAddress getPushAddress(String number) throws InvalidNumberException {
         String e164number = canonicalizeNumber(number);
         return new TextSecureAddress(e164number);
     }
index 36921de295e8b70b0b743af482fac8d487614a70..907c4ed1147319c2a7afc46fa80eaf8ce4fefcad 100644 (file)
@@ -3,19 +3,19 @@ package cli;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 
-public class Util {
+class Util {
     public static String getSecret(int size) {
         byte[] secret = getSecretBytes(size);
         return Base64.encodeBytes(secret);
     }
 
-    public static byte[] getSecretBytes(int size) {
+    private static byte[] getSecretBytes(int size) {
         byte[] secret = new byte[size];
         getSecureRandom().nextBytes(secret);
         return secret;
     }
 
-    public static SecureRandom getSecureRandom() {
+    private static SecureRandom getSecureRandom() {
         try {
             return SecureRandom.getInstance("SHA1PRNG");
         } catch (NoSuchAlgorithmException e) {
index 621b43e921f8fa278489d6527431a837d4cc3673..085196532662aefa217c26ac7a11d7bf1f9a8046 100644 (file)
@@ -4,7 +4,7 @@ import org.whispersystems.textsecure.api.push.TrustStore;
 
 import java.io.InputStream;
 
-public class WhisperTrustStore implements TrustStore {
+class WhisperTrustStore implements TrustStore {
 
     @Override
     public InputStream getKeyStoreInputStream() {