summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-03-24 19:07:43 +0100
committerParménides GV <parmegv@sdf.org>2015-03-24 19:07:43 +0100
commitb87f082fe0e9c05cf45c56b510a2c4000133b572 (patch)
tree76a035cef8dc08b159eb19399fc0a823143d6742 /app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
parent9bb172e96cfd741e528e692118ee32fc609c6da8 (diff)
Indent everything with IntelliJ
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java100
1 files changed, 51 insertions, 49 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
index 10ddc0ef..b2c7af8c 100644
--- a/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
+++ b/app/src/main/java/se/leap/bitmaskclient/eip/Gateway.java
@@ -1,6 +1,6 @@
/**
* Copyright (c) 2013 LEAP Encryption Access Project and contributers
- *
+ *
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -21,6 +21,7 @@ import android.util.*;
import com.google.gson.*;
import org.json.*;
+
import java.io.*;
import de.blinkt.openvpn.*;
@@ -30,12 +31,12 @@ import de.blinkt.openvpn.core.*;
* Gateway provides objects defining gateways and their metadata.
* Each instance contains a VpnProfile for OpenVPN specific data and member
* variables describing capabilities and location (name)
- *
+ *
* @author Sean Leonard <meanderingcode@aetherislands.net>
* @author Parménides GV <parmegv@sdf.org>
*/
public class Gateway {
-
+
public final static String TAG = Gateway.class.getSimpleName();
private JSONObject general_configuration;
@@ -45,86 +46,87 @@ public class Gateway {
private String mName;
private int timezone;
private VpnProfile mVpnProfile;
+
/**
* Build a gateway object from a JSON OpenVPN gateway definition in eip-service.json
* and create a VpnProfile belonging to it.
*/
- public Gateway(JSONObject eip_definition, JSONObject secrets, JSONObject gateway){
+ public Gateway(JSONObject eip_definition, JSONObject secrets, JSONObject gateway) {
- this.gateway = gateway;
+ this.gateway = gateway;
this.secrets = secrets;
- general_configuration = getGeneralConfiguration(eip_definition);
- timezone = getTimezone(eip_definition);
- mName = locationAsName(eip_definition);
+ general_configuration = getGeneralConfiguration(eip_definition);
+ timezone = getTimezone(eip_definition);
+ mName = locationAsName(eip_definition);
- mVpnProfile = createVPNProfile();
- mVpnProfile.mName = mName;
+ mVpnProfile = createVPNProfile();
+ mVpnProfile.mName = mName;
}
private JSONObject getGeneralConfiguration(JSONObject eip_definition) {
- try {
- return eip_definition.getJSONObject("openvpn_configuration");
- } catch (JSONException e) {
- return new JSONObject();
- }
+ try {
+ return eip_definition.getJSONObject("openvpn_configuration");
+ } catch (JSONException e) {
+ return new JSONObject();
+ }
}
private int getTimezone(JSONObject eip_definition) {
- JSONObject location = getLocationInfo(eip_definition);
- return location.optInt("timezone");
+ JSONObject location = getLocationInfo(eip_definition);
+ return location.optInt("timezone");
}
private String locationAsName(JSONObject eip_definition) {
- JSONObject location = getLocationInfo(eip_definition);
- return location.optString("name");
+ JSONObject location = getLocationInfo(eip_definition);
+ return location.optString("name");
}
private JSONObject getLocationInfo(JSONObject eip_definition) {
- try {
- JSONObject locations = eip_definition.getJSONObject("locations");
+ try {
+ JSONObject locations = eip_definition.getJSONObject("locations");
- return locations.getJSONObject(gateway.getString("location"));
- } catch (JSONException e) {
- return new JSONObject();
- }
+ return locations.getJSONObject(gateway.getString("location"));
+ } catch (JSONException e) {
+ return new JSONObject();
+ }
}
-
+
/**
* Create and attach the VpnProfile to our gateway object
*/
- private VpnProfile createVPNProfile(){
- try {
- ConfigParser cp = new ConfigParser();
-
- VpnConfigGenerator vpn_configuration_generator = new VpnConfigGenerator(general_configuration, secrets, gateway);
- String configuration = vpn_configuration_generator.generate();
-
- cp.parseConfig(new StringReader(configuration));
- return cp.convertProfile();
- } catch (ConfigParser.ConfigParseError e) {
- // FIXME We didn't get a VpnProfile! Error handling! and log level
- Log.v(TAG,"Error creating VPNProfile");
- e.printStackTrace();
- return null;
- } catch (IOException e) {
- // FIXME We didn't get a VpnProfile! Error handling! and log level
- Log.v(TAG,"Error creating VPNProfile");
- e.printStackTrace();
- return null;
- }
+ private VpnProfile createVPNProfile() {
+ try {
+ ConfigParser cp = new ConfigParser();
+
+ VpnConfigGenerator vpn_configuration_generator = new VpnConfigGenerator(general_configuration, secrets, gateway);
+ String configuration = vpn_configuration_generator.generate();
+
+ cp.parseConfig(new StringReader(configuration));
+ return cp.convertProfile();
+ } catch (ConfigParser.ConfigParseError e) {
+ // FIXME We didn't get a VpnProfile! Error handling! and log level
+ Log.v(TAG, "Error creating VPNProfile");
+ e.printStackTrace();
+ return null;
+ } catch (IOException e) {
+ // FIXME We didn't get a VpnProfile! Error handling! and log level
+ Log.v(TAG, "Error creating VPNProfile");
+ e.printStackTrace();
+ return null;
+ }
}
public String getName() {
- return mName;
+ return mName;
}
public VpnProfile getProfile() {
- return mVpnProfile;
+ return mVpnProfile;
}
public int getTimezone() {
- return timezone;
+ return timezone;
}
@Override