From 761fbdcbecd50236a5e8e653c27327b653b3ccf9 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 27 Oct 2016 20:57:53 -0400 Subject: [PATCH 1/4] Added extended EnterpriseWifi class --- .../qrgen/core/scheme/EnterpriseWifi.java | 121 ++++++++++++++++++ .../java/net/glxn/qrgen/core/scheme/Wifi.java | 18 +-- 2 files changed, 130 insertions(+), 9 deletions(-) create mode 100644 core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java diff --git a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java new file mode 100644 index 0000000..a9ec9ef --- /dev/null +++ b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java @@ -0,0 +1,121 @@ +package net.glxn.qrgen.core.scheme; + +import java.util.Map; + +import static net.glxn.qrgen.core.scheme.SchemeUtil.getParameters; + +/** + * Encodes a Wifi connection, format is: + * WIFI:S:SSID;U:USER;P:PSK;E:EAP;PH:PHASE;; + */ +public class EnterpriseWifi extends Wifi { + + private static final String USER = "U"; + private static final String EAP = "E"; + private static final String PHASE = "PH"; + private String username; + private String eap; + private String phase; + private boolean hidden = false; + public EnterpriseWifi() { + } + + public static EnterpriseWifi parse(final String wifiCode) { + if (wifiCode == null || !wifiCode.startsWith(WIFI_PROTOCOL_HEADER)) { + throw new IllegalArgumentException( + "this is not a valid WIFI code: " + wifiCode); + } + Wifi wifi = new Wifi(); + Map parameters = getParameters( + wifiCode.substring(WIFI_PROTOCOL_HEADER.length()), "(? Date: Sat, 29 Oct 2016 16:09:18 -0400 Subject: [PATCH 2/4] Fixed syntax errors, wrote unit test --- .../qrgen/core/scheme/EnterpriseWifi.java | 4 +- .../qrgen/core/scheme/EnterpriseWifiTest.java | 90 +++++++++++++++++++ 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 core/src/test/java/net/glxn/qrgen/core/scheme/EnterpriseWifiTest.java diff --git a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java index a9ec9ef..502d18a 100644 --- a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java +++ b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java @@ -25,7 +25,7 @@ public static EnterpriseWifi parse(final String wifiCode) { throw new IllegalArgumentException( "this is not a valid WIFI code: " + wifiCode); } - Wifi wifi = new Wifi(); + EnterpriseWifi wifi = new EnterpriseWifi(); Map parameters = getParameters( wifiCode.substring(WIFI_PROTOCOL_HEADER.length()), "(? Date: Sat, 29 Oct 2016 16:09:18 -0400 Subject: [PATCH 3/4] Fixed syntax errors, wrote unit test --- .../qrgen/core/scheme/EnterpriseWifi.java | 24 ++--- .../qrgen/core/scheme/EnterpriseWifiTest.java | 90 +++++++++++++++++++ .../net/glxn/qrgen/core/scheme/WifiTest.java | 12 ++- 3 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 core/src/test/java/net/glxn/qrgen/core/scheme/EnterpriseWifiTest.java diff --git a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java index a9ec9ef..8e4c797 100644 --- a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java +++ b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java @@ -9,14 +9,14 @@ * WIFI:S:SSID;U:USER;P:PSK;E:EAP;PH:PHASE;; */ public class EnterpriseWifi extends Wifi { - private static final String USER = "U"; private static final String EAP = "E"; private static final String PHASE = "PH"; - private String username; + private String user; private String eap; private String phase; private boolean hidden = false; + public EnterpriseWifi() { } @@ -25,7 +25,7 @@ public static EnterpriseWifi parse(final String wifiCode) { throw new IllegalArgumentException( "this is not a valid WIFI code: " + wifiCode); } - Wifi wifi = new Wifi(); + EnterpriseWifi wifi = new EnterpriseWifi(); Map parameters = getParameters( wifiCode.substring(WIFI_PROTOCOL_HEADER.length()), "(? Date: Sun, 30 Oct 2016 16:26:50 -0400 Subject: [PATCH 4/4] Made some variables private --- .../glxn/qrgen/core/scheme/EnterpriseWifi.java | 9 ++++----- .../java/net/glxn/qrgen/core/scheme/Wifi.java | 18 +++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java index c192d5e..6eb4f92 100644 --- a/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java +++ b/core/src/main/java/net/glxn/qrgen/core/scheme/EnterpriseWifi.java @@ -5,17 +5,16 @@ import static net.glxn.qrgen.core.scheme.SchemeUtil.getParameters; /** - * Encodes a Wifi connection, format is: + * Encodes a Wifi connection containing a username / password scheme for authentication, format is: * WIFI:S:SSID;U:USER;P:PSK;E:EAP;PH:PHASE;; */ public class EnterpriseWifi extends Wifi { - private static final String USER = "U"; - private static final String EAP = "E"; - private static final String PHASE = "PH"; + public static final String USER = "U"; + public static final String EAP = "E"; + public static final String PHASE = "PH"; private String user; private String eap; private String phase; - private boolean hidden = false; public EnterpriseWifi() { } diff --git a/core/src/main/java/net/glxn/qrgen/core/scheme/Wifi.java b/core/src/main/java/net/glxn/qrgen/core/scheme/Wifi.java index d4f1863..d29d13d 100644 --- a/core/src/main/java/net/glxn/qrgen/core/scheme/Wifi.java +++ b/core/src/main/java/net/glxn/qrgen/core/scheme/Wifi.java @@ -9,16 +9,16 @@ * WIFI:T:AUTHENTICATION;S:SSID;P:PSK;H:HIDDEN; */ public class Wifi { + public static final String WIFI_PROTOCOL_HEADER = "WIFI:"; + public static final String AUTHENTICATION = "T"; + public static final String SSID = "S"; + public static final String PSK = "P"; + public static final String HIDDEN = "H"; + private String authentication; + private String ssid; + private String psk; + private boolean hidden = false; - protected static final String WIFI_PROTOCOL_HEADER = "WIFI:"; - protected static final String AUTHENTICATION = "T"; - protected static final String SSID = "S"; - protected static final String PSK = "P"; - protected static final String HIDDEN = "H"; - protected String authentication; - protected String ssid; - protected String psk; - protected boolean hidden = false; public Wifi() { }