aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util
diff options
context:
space:
mode:
authorAdithya Abraham Philip <adithyaphilip@gmail.com>2015-06-16 14:36:18 +0530
committerAdithya Abraham Philip <adithyaphilip@gmail.com>2015-07-03 20:46:15 +0530
commit2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8 (patch)
tree3b6e9eb10f21be97e94582616e309c230ae5f327 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util
parentf6d0f88ac973328b3b7a9d426214beb76efefb3f (diff)
downloadopen-keychain-2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8.tar.gz
open-keychain-2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8.tar.bz2
open-keychain-2402c6d3c72b19b8eded017ff3fbeb83c30ae0a8.zip
ensuring code style is preserved
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/TlsHelper.java16
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java26
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java42
5 files changed, 31 insertions, 60 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java
index 601547fa9..4898e7f1a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ParcelableProxy.java
@@ -54,7 +54,7 @@ public class ParcelableProxy implements Parcelable {
}
public Proxy getProxy() {
- if(mProxyHost == null) return null;
+ if (mProxyHost == null) return null;
Proxy.Type type = null;
switch (mProxyType) {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
index f54eac867..c13c07503 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/Preferences.java
@@ -296,8 +296,7 @@ public class Preferences {
if (useTor) {
return new ProxyPrefs(true, false, Constants.Orbot.PROXY_HOST, Constants.Orbot.PROXY_PORT,
Constants.Orbot.PROXY_TYPE);
- }
- else if (useNormalProxy) {
+ } else if (useNormalProxy) {
return new ProxyPrefs(useTor, useNormalProxy, getProxyHost(), getProxyPort(), getProxyType());
} else {
return new ProxyPrefs(false, false, null, -1, null);
@@ -318,7 +317,7 @@ public class Preferences {
public ProxyPrefs(boolean torEnabled, boolean normalPorxyEnabled, String hostName, int port, Proxy.Type type) {
this.torEnabled = torEnabled;
this.normalPorxyEnabled = normalPorxyEnabled;
- if(!torEnabled && !normalPorxyEnabled) this.parcelableProxy = new ParcelableProxy(null, -1, null);
+ if (!torEnabled && !normalPorxyEnabled) this.parcelableProxy = new ParcelableProxy(null, -1, null);
else this.parcelableProxy = new ParcelableProxy(hostName, port, type);
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/TlsHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/TlsHelper.java
index 58c250cab..d1d1ada2a 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/TlsHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/TlsHelper.java
@@ -27,7 +27,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
@@ -62,7 +61,7 @@ public class TlsHelper {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int reads = is.read();
- while(reads != -1){
+ while (reads != -1) {
baos.write(reads);
reads = is.read();
}
@@ -75,17 +74,6 @@ public class TlsHelper {
}
}
- public static URLConnection opeanConnection(URL url) throws IOException, TlsHelperException {
- if (url.getProtocol().equals("https")) {
- for (String domain : sStaticCA.keySet()) {
- if (url.getHost().endsWith(domain)) {
- return openCAConnection(sStaticCA.get(domain), url);
- }
- }
- }
- return url.openConnection();
- }
-
public static void pinCertificateIfNecessary(OkHttpClient client, URL url) throws TlsHelperException, IOException {
if (url.getProtocol().equals("https")) {
for (String domain : sStaticCA.keySet()) {
@@ -103,7 +91,7 @@ public class TlsHelper {
* TODO: Refactor - More like SSH StrictHostKeyChecking than pinning?
*
* @param certificate certificate to pin
- * @param client OkHttpClient to enforce pinning on
+ * @param client OkHttpClient to enforce pinning on
* @throws TlsHelperException
* @throws IOException
*/
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java
index 5e0e393c5..f57496767 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/OrbotHelper.java
@@ -77,15 +77,13 @@ public class OrbotHelper {
public final static String ACTION_START_TOR = "org.torproject.android.START_TOR";
- public static boolean isOrbotRunning()
- {
+ public static boolean isOrbotRunning() {
int procId = TorServiceUtils.findProcessId(TOR_BIN_PATH);
return (procId != -1);
}
- public static boolean isOrbotInstalled(Context context)
- {
+ public static boolean isOrbotInstalled(Context context) {
return isAppInstalled(ORBOT_PACKAGE_NAME, context);
}
@@ -102,30 +100,28 @@ public class OrbotHelper {
}
/**
- * hack to get around teh fact that PreferenceActivity still supports only android.app.DialogFragment
+ * hack to get around the fact that PreferenceActivity still supports only android.app.DialogFragment
*
* @return
*/
- public static android.app.DialogFragment getPreferenceInstallDialogFragment()
- {
+ public static android.app.DialogFragment getPreferenceInstallDialogFragment() {
return PreferenceInstallDialogFragment.newInstance(R.string.orbot_install_dialog_title,
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME);
}
- public static DialogFragment getInstallDialogFragment()
- {
+ public static DialogFragment getInstallDialogFragment() {
return InstallDialogFragment.newInstance(R.string.orbot_install_dialog_title,
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME);
}
- public static DialogFragment getInstallDialogFragmentWithThirdButton(Messenger messenger, int middleButton)
- {
+ public static DialogFragment getInstallDialogFragmentWithThirdButton(Messenger messenger, int middleButton) {
return InstallDialogFragment.newInstance(messenger, R.string.orbot_install_dialog_title,
R.string.orbot_install_dialog_content, ORBOT_PACKAGE_NAME, middleButton, true);
}
public static DialogFragment getOrbotStartDialogFragment(Messenger messenger, int middleButton) {
- return OrbotStartDialogFragment.newInstance(messenger, R.string.orbot_start_dialog_title, R.string.orbot_start_dialog_content,
+ return OrbotStartDialogFragment.newInstance(messenger, R.string.orbot_start_dialog_title, R.string
+ .orbot_start_dialog_content,
middleButton);
}
@@ -139,7 +135,7 @@ public class OrbotHelper {
/**
* checks if Tor is enabled and if it is, that Orbot is installed and runnign. Generates appropriate dialogs.
*
- * @param middleButton resourceId of string to display as the middle button of install and enable dialogs
+ * @param middleButton resourceId of string to display as the middle button of install and enable dialogs
* @param middleButtonRunnable runnable to be executed if the user clicks on the middle button
* @param proxyPrefs
* @param fragmentActivity
@@ -159,7 +155,7 @@ public class OrbotHelper {
return true;
}
- if(!OrbotHelper.isOrbotInstalled(fragmentActivity)) {
+ if (!OrbotHelper.isOrbotInstalled(fragmentActivity)) {
OrbotHelper.getInstallDialogFragmentWithThirdButton(
new Messenger(ignoreTorHandler),
@@ -167,7 +163,7 @@ public class OrbotHelper {
).show(fragmentActivity.getSupportFragmentManager(), "OrbotHelperOrbotInstallDialog");
return false;
- } else if(!OrbotHelper.isOrbotRunning()) {
+ } else if (!OrbotHelper.isOrbotRunning()) {
OrbotHelper.getOrbotStartDialogFragment(new Messenger(ignoreTorHandler),
R.string.orbot_install_dialog_ignore_tor)
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java
index 127e9d43f..b1d8327fb 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/orbot/TorServiceUtils.java
@@ -49,14 +49,14 @@
package org.sufficientlysecure.keychain.util.orbot;
+import android.util.Log;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.net.URLEncoder;
import java.util.StringTokenizer;
-import android.util.Log;
-
/**
* This class is taken from the NetCipher library: https://github.com/guardianproject/NetCipher/
*/
@@ -68,23 +68,18 @@ public class TorServiceUtils {
public final static String SHELL_CMD_PS = "ps";
public final static String SHELL_CMD_PIDOF = "pidof";
- public static int findProcessId(String command)
- {
+ public static int findProcessId(String command) {
int procId = -1;
- try
- {
+ try {
procId = findProcessIdWithPidOf(command);
if (procId == -1)
procId = findProcessIdWithPS(command);
- } catch (Exception e)
- {
- try
- {
+ } catch (Exception e) {
+ try {
procId = findProcessIdWithPS(command);
- } catch (Exception e2)
- {
+ } catch (Exception e2) {
Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2);
}
}
@@ -93,8 +88,7 @@ public class TorServiceUtils {
}
// use 'pidof' command
- public static int findProcessIdWithPidOf(String command) throws Exception
- {
+ public static int findProcessIdWithPidOf(String command) throws Exception {
int procId = -1;
@@ -104,7 +98,7 @@ public class TorServiceUtils {
String baseName = new File(command).getName();
// fix contributed my mikos on 2010.12.10
- procPs = r.exec(new String[] {
+ procPs = r.exec(new String[]{
SHELL_CMD_PIDOF, baseName
});
// procPs = r.exec(SHELL_CMD_PIDOF);
@@ -112,16 +106,13 @@ public class TorServiceUtils {
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
String line = null;
- while ((line = reader.readLine()) != null)
- {
+ while ((line = reader.readLine()) != null) {
- try
- {
+ try {
// this line should just be the process id
procId = Integer.parseInt(line.trim());
break;
- } catch (NumberFormatException e)
- {
+ } catch (NumberFormatException e) {
Log.e("TorServiceUtils", "unable to parse process pid: " + line, e);
}
}
@@ -131,8 +122,7 @@ public class TorServiceUtils {
}
// use 'ps' command
- public static int findProcessIdWithPS(String command) throws Exception
- {
+ public static int findProcessIdWithPS(String command) throws Exception {
int procId = -1;
@@ -145,10 +135,8 @@ public class TorServiceUtils {
BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
String line = null;
- while ((line = reader.readLine()) != null)
- {
- if (line.indexOf(' ' + command) != -1)
- {
+ while ((line = reader.readLine()) != null) {
+ if (line.indexOf(' ' + command) != -1) {
StringTokenizer st = new StringTokenizer(line, " ");
st.nextToken(); // proc owner