1

I'm new in Android development and I need some help coming with a solution for the following problem: My college's Wi-Fi network has a captive portal that ask for your username and password to access the school's system, so I thought I could automatize the process of logging in the network by sending an HTTP post request to the portal with the user data everytime the phone detects a connection to the school's network (checking the SSID), easy cake, right? The thing is I don't know where to start, Android is a very extensive environment so I'm here to ask you for guidance. I did some homework about it and this is what I've got so far:

  • I can start the app using a BroadcastReceiver with the Connectivity Manager Intent. I think it might give me too much intents I don't need, as I just need the Wifi. I read about it here
  • I can make HTTP Request using the AndroidHTTPClient.

The flow I'm planning is the following: User opens the application for the first time, and he enters the username and password, there's a toggle button for Auto-Connect that changes to "Disconnect" when you press it (as you can only connect one device at a time with the same credentials, it sends a request to the network's logout page). With the system in Auto-Connect mode, everytime the phone connects to the school network, it should send the request, even if the app is not running.

  • First, what's the best approach for this kind of problem??
  • Where (and when) should I store the credentials?
  • Where should I make the Requests? in the Receiver's onRecive()? in the activity?

I know it's like asking you to solve my problem, but I'm trying to learn here, and I need guidance to make the best I can with this software. I very much appreciate your input :)

Community
  • 1
  • 1
fixmycode
  • 8,220
  • 2
  • 28
  • 43
  • https://github.com/bradfitz/android-garage-opener/blob/master/src/com/danga/garagedoor/GarageDoorActivity.java That's a working example of a wifi listener. – grepsedawk Apr 22 '12 at 21:41

1 Answers1

2

I would implement a Service that implements a BroadcastReceiver to check for changes in the internet connectivity which configures an AsyncTask and executes it to make the right request to the login service.

Did you check if this is actually possible? Did you learn about the right parameters for the HTTP request? Can you use curl to authenticate?

I don't know if Android has a decent mechanism for valuable information storage, but essentially where you keep the credentials depends on the level of security risk. I wouldn't give much attention to this for now -assuming that these passwords are not valuable and the application will not be wide-spread. Anyways, you can just store a binary sequence in a static variable and XOR it with the user's password and store it in another static variable. That should be enough for simple memory scanning. I'm not mentioning writing to a file because I think that way is way too risky in terms of security.

By the way, this looks like a good application idea. Did you check whether someone already had made this?

onur güngör
  • 715
  • 5
  • 18
  • Thanks! yes, it is possible, in fact I've made a little bash script for linux laptops and it works like a charm. The user information is not that big of a deal given the post request is made using HTTP and not HTTPS, I was thinking in a simple SQLiteDatabase to store them. About other applications, I know someone on campus did a iOS app that does this and released the code on github, but iOS and Android are different beasts. – fixmycode Apr 22 '12 at 22:24
  • About the Service thing, i would also need an activity to ask for the credentials, isn't it? – fixmycode Apr 22 '12 at 22:30
  • Yes, you need an activity to let the user to enter the credentials. – onur güngör Apr 23 '12 at 08:56