Fix coding issues

This commit is contained in:
AsamK 2015-08-07 13:22:15 +02:00
parent e1b584ab84
commit 9e1cd7e398
9 changed files with 19 additions and 23 deletions

View file

@ -10,7 +10,7 @@ import org.whispersystems.libaxolotl.state.SignedPreKeyRecord;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
public class JsonAxolotlStore implements AxolotlStore { class JsonAxolotlStore implements AxolotlStore {
private final JsonPreKeyStore preKeyStore; private final JsonPreKeyStore preKeyStore;
private final JsonSessionStore sessionStore; private final JsonSessionStore sessionStore;
private final JsonSignedPreKeyStore signedPreKeyStore; private final JsonSignedPreKeyStore signedPreKeyStore;

View file

@ -11,7 +11,7 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class JsonIdentityKeyStore implements IdentityKeyStore { class JsonIdentityKeyStore implements IdentityKeyStore {
private final Map<String, IdentityKey> trustedKeys = new HashMap<>(); private final Map<String, IdentityKey> trustedKeys = new HashMap<>();

View file

@ -10,7 +10,7 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class JsonPreKeyStore implements PreKeyStore { class JsonPreKeyStore implements PreKeyStore {
private final Map<Integer, byte[]> store = new HashMap<>(); 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++) { for (int i = 0; i < list.length(); i++) {
JSONObject k = list.getJSONObject(i); JSONObject k = list.getJSONObject(i);
try { try {

View file

@ -9,15 +9,15 @@ import org.whispersystems.libaxolotl.state.SessionStore;
import java.io.IOException; import java.io.IOException;
import java.util.*; 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() {
} }
public JsonSessionStore(JSONArray list) throws IOException { public JsonSessionStore(JSONArray list) {
for (int i = 0; i < list.length(); i++) { for (int i = 0; i < list.length(); i++) {
JSONObject k = list.getJSONObject(i); JSONObject k = list.getJSONObject(i);
try { try {

View file

@ -12,7 +12,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class JsonSignedPreKeyStore implements SignedPreKeyStore { class JsonSignedPreKeyStore implements SignedPreKeyStore {
private final Map<Integer, byte[]> store = new HashMap<>(); 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++) { for (int i = 0; i < list.length(); i++) {
JSONObject k = list.getJSONObject(i); JSONObject k = list.getJSONObject(i);
try { try {

View file

@ -232,7 +232,7 @@ public class Main {
} }
private static class ReceiveMessageHandler implements Manager.ReceiveMessageHandler { private static class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
Manager m; final Manager m;
public ReceiveMessageHandler(Manager m) { public ReceiveMessageHandler(Manager m) {
this.m = m; this.m = m;

View file

@ -47,7 +47,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
public class Manager { class Manager {
private final static String URL = "https://textsecure-service.whispersystems.org"; private final static String URL = "https://textsecure-service.whispersystems.org";
private final static TrustStore TRUST_STORE = new WhisperTrustStore(); private final static TrustStore TRUST_STORE = new WhisperTrustStore();
@ -64,7 +64,7 @@ public class Manager {
private boolean registered = false; private boolean registered = false;
private JsonAxolotlStore axolotlStore; private JsonAxolotlStore axolotlStore;
TextSecureAccountManager accountManager; private TextSecureAccountManager accountManager;
public Manager(String username) { public Manager(String username) {
this.username = username; this.username = username;
@ -77,10 +77,7 @@ public class Manager {
public boolean userExists() { public boolean userExists() {
File f = new File(getFileName()); File f = new File(getFileName());
if (!f.exists() || f.isDirectory()) { return !(!f.exists() || f.isDirectory());
return false;
}
return true;
} }
public boolean userHasKeys() { public boolean userHasKeys() {
@ -124,7 +121,6 @@ public class Manager {
writer.close(); writer.close();
} catch (Exception e) { } catch (Exception e) {
System.out.println("Saving file error: " + e.getMessage()); System.out.println("Saving file error: " + e.getMessage());
return;
} }
} }
@ -300,12 +296,12 @@ public class Manager {
return outputFile; return outputFile;
} }
public String canonicalizeNumber(String number) throws InvalidNumberException { private String canonicalizeNumber(String number) throws InvalidNumberException {
String localNumber = username; String localNumber = username;
return PhoneNumberFormatter.formatNumber(number, localNumber); return PhoneNumberFormatter.formatNumber(number, localNumber);
} }
protected TextSecureAddress getPushAddress(String number) throws InvalidNumberException { TextSecureAddress getPushAddress(String number) throws InvalidNumberException {
String e164number = canonicalizeNumber(number); String e164number = canonicalizeNumber(number);
return new TextSecureAddress(e164number); return new TextSecureAddress(e164number);
} }

View file

@ -3,19 +3,19 @@ package cli;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom; import java.security.SecureRandom;
public class Util { class Util {
public static String getSecret(int size) { public static String getSecret(int size) {
byte[] secret = getSecretBytes(size); byte[] secret = getSecretBytes(size);
return Base64.encodeBytes(secret); return Base64.encodeBytes(secret);
} }
public static byte[] getSecretBytes(int size) { private static byte[] getSecretBytes(int size) {
byte[] secret = new byte[size]; byte[] secret = new byte[size];
getSecureRandom().nextBytes(secret); getSecureRandom().nextBytes(secret);
return secret; return secret;
} }
public static SecureRandom getSecureRandom() { private static SecureRandom getSecureRandom() {
try { try {
return SecureRandom.getInstance("SHA1PRNG"); return SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) { } catch (NoSuchAlgorithmException e) {

View file

@ -4,7 +4,7 @@ import org.whispersystems.textsecure.api.push.TrustStore;
import java.io.InputStream; import java.io.InputStream;
public class WhisperTrustStore implements TrustStore { class WhisperTrustStore implements TrustStore {
@Override @Override
public InputStream getKeyStoreInputStream() { public InputStream getKeyStoreInputStream() {