Add 36c3 support. Add support for 3 connection profiles plus special

This commit is contained in:
Wilco Baan Hofman 2019-12-05 16:04:09 +01:00
parent 21e5605ec9
commit d27b08f97c
6 changed files with 95 additions and 42 deletions

View file

@ -32,10 +32,12 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ViewFlipper; import android.widget.ViewFlipper;
@ -48,7 +50,12 @@ import java.util.List;
/* import android.util.Base64; */ /* import android.util.Base64; */
// API level 18 and up // API level 18 and up
enum Profile {
PROFILE_UNFILTERED,
PROFILE_SITEONLY,
PROFILE_PROTECTME,
PROFILE_SPECIAL
};
public class WifiSetup extends Activity { public class WifiSetup extends Activity {
protected static final int SHOW_PREFERENCES = 0; protected static final int SHOW_PREFERENCES = 0;
// FIXME This should be a configuration setting somehow // FIXME This should be a configuration setting somehow
@ -88,6 +95,8 @@ public class WifiSetup extends Activity {
private String s_username; private String s_username;
private String s_password; private String s_password;
private ViewFlipper flipper; private ViewFlipper flipper;
Profile selected_profile;
static String removeQuotes(String str) { static String removeQuotes(String str) {
int len = str.length(); int len = str.length();
@ -141,23 +150,41 @@ public class WifiSetup extends Activity {
} }
*/ */
ImageView img = (ImageView) findViewById(R.id.logo); Spinner spinner = (Spinner) findViewById(R.id.profile);
img.setOnClickListener(new View.OnClickListener() { spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onClick(View view) { public void onItemSelected(AdapterView<?> parent, View v, int position,
logoclicks++; long id) {
if (logoclicks == 4) { View logindata = findViewById(R.id.logindata);;
toastText("You're cute!"); logindata.setVisibility(View.INVISIBLE);
} switch((int) id) {
if (logoclicks == 6) { case 0:
toastText("Stop that!"); selected_profile = Profile.PROFILE_UNFILTERED;
} toastText("Don't filter me!");
if (logoclicks == 7) { break;
View logindata = findViewById(R.id.logindata); case 1:
logindata.setVisibility(View.VISIBLE); selected_profile = Profile.PROFILE_SITEONLY;
} toastText("You trust people on-site more than the internet! Thank you!");
break;
case 2:
selected_profile = Profile.PROFILE_PROTECTME;
toastText("You don't trust anyone? Or maybe not your device?");
break;
case 3:
selected_profile = Profile.PROFILE_SPECIAL;
logindata.setVisibility(View.VISIBLE);
toastText("Hi fellow special person!");
break;
}
} }
});
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
btn = (Button) findViewById(R.id.button1); btn = (Button) findViewById(R.id.button1);
if (btn == null) if (btn == null)
@ -233,25 +260,37 @@ public class WifiSetup extends Activity {
} }
if (check5g.isChecked()) { if (check5g.isChecked()) {
ssid = "Camp2019"; ssid = "36C3";
} else { } else {
ssid = "Camp2019-legacy"; ssid = "36C3-legacy";
} }
subject_match = "/CN=radius.c3noc.net"; subject_match = "/CN=radius.c3noc.net";
altsubject_match = "DNS:radius.c3noc.net"; altsubject_match = "DNS:radius.c3noc.net";
s_username = username.getText().toString();
s_password = password.getText().toString();
realm = ""; realm = "";
if (s_username.equals("") && s_password.equals("")) { switch(selected_profile) {
s_username = "Camp2019"; case PROFILE_UNFILTERED:
s_password = "Camp2019"; s_username = "36C3";
} else { s_password = "36C3";
if (s_username.contains("@")) { break;
int idx = s_username.indexOf("@"); case PROFILE_SITEONLY:
realm = s_username.substring(idx); s_username = "congressonly";
} s_password = "congressonly";
} break;
case PROFILE_PROTECTME:
s_username = "outboundonly";
s_password = "outboundonly";
break;
case PROFILE_SPECIAL:
s_username = username.getText().toString();
s_password = password.getText().toString();
if (s_username.contains("@")) {
int idx = s_username.indexOf("@");
realm = s_username.substring(idx);
}
break;
}
// Use the existing ssid profile if it exists. // Use the existing ssid profile if it exists.
@ -365,7 +404,7 @@ public class WifiSetup extends Activity {
builder.setMessage(getString(R.string.ABOUT_CONTENT)+ builder.setMessage(getString(R.string.ABOUT_CONTENT)+
"\n\n"+pi.packageName+"\n"+ "\n\n"+pi.packageName+"\n"+
"V"+pi.versionName+ "V"+pi.versionName+
"C"+pi.versionCode+"-equi"); "C"+pi.versionCode+"-syn");
builder.setPositiveButton(getString(android.R.string.ok), null); builder.setPositiveButton(getString(android.R.string.ok), null);
builder.show(); builder.show();

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -27,7 +27,7 @@
android:contentDescription="@string/LOGO" android:contentDescription="@string/LOGO"
android:padding="0dp" android:padding="0dp"
android:scaleType="fitCenter" android:scaleType="fitCenter"
android:src="@drawable/camp19logo" /> android:src="@drawable/ccc36c3" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -41,14 +41,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="15dp" android:layout_marginTop="15dp"
android:text="@string/c5ghz"/> android:text="@string/c5ghz"/>
<TextView
android:id="@+id/label5g"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/l5ghz"
android:textAlignment="center" />
<TextView <TextView
android:id="@+id/labelkeystore" android:id="@+id/labelkeystore"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -58,6 +50,21 @@
android:paddingRight="10dp" android:paddingRight="10dp"
android:text="@string/lkeystore" android:text="@string/lkeystore"
android:textAlignment="center" /> android:textAlignment="center" />
<TextView
android:id="@+id/labelprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/chooseprofile" />
<Spinner
android:id="@+id/profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:prompt="@string/profile_select"
android:entries="@array/profiles_array"
/>
<LinearLayout <LinearLayout
android:id="@+id/logindata" android:id="@+id/logindata"

View file

@ -1,4 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string-array name="profiles_array">
<item>Enable me - no filters = full inbound/outbound</item>
<item>Enable me on-site = outbound only, inbound from event</item>
<item>Protect me = outbound traffic only</item>
<item>I am special = custom username/password</item>
</string-array>
</resources> </resources>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<string name="app_name">CCC Camp 2019 Wifi Setup</string> <string name="app_name">36C3 Wifi Setup</string>
<string name="TITLE_LOGON">Please logon</string> <string name="TITLE_LOGON">Please logon</string>
<string name="Username">username@realm</string> <string name="Username">username@realm</string>
@ -13,10 +13,11 @@
<string name="l5ghz">(Unfortunately, autodetecting 5GHz support is broken&#8230;)</string> <string name="l5ghz">(Unfortunately, autodetecting 5GHz support is broken&#8230;)</string>
<string name="lkeystore">Note: if you have no screen lock, Android refuses to store the security settings!</string> <string name="lkeystore">Note: if you have no screen lock, Android refuses to store the security settings!</string>
<string name="chooseprofile">Choose your connection profile:</string>
<string name="profile_select">Select profile</string>
<string name="ABOUT_TITLE">About</string> <string name="ABOUT_TITLE">About</string>
<string name="EXIT_TITLE">Exit</string> <string name="EXIT_TITLE">Exit</string>
<string name="ABOUT_CONTENT">This small helper app creates a Wifi connection entry for the CCC/EMF/SHA2017 networks. It configures the correct SSL CA and subject name match, making it a little more secure than a hand-created entry.</string> <string name="ABOUT_CONTENT">This small helper app creates a Wifi connection entry for the CCC/EMF/SHA2017 networks. It configures the correct SSL CA and subject name match, making it a little more secure than a hand-created entry.</string>
<string name="LOGO">Camp2019 Logo</string> <string name="LOGO">36c3 Logo</string>
</resources> </resources>