Permalink
Browse files

working prototype for touchstone authentication

  • Loading branch information...
1 parent 5c4d627 commit 4de76de16463bf878483b6f955b5c8ed0a1bba99 @sseligma sseligma committed Jul 25, 2011
View
@@ -1,9 +1,10 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="lib" path="libs/commons-io-2.0.1.jar"/>
- <classpathentry kind="lib" path="libs/httpmime-4.1.1.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="lib" path="libs/commons-io-2.0.1.jar"/>
+ <classpathentry kind="lib" path="libs/httpmime-4.1.1.jar"/>
+ <classpathentry kind="lib" path="libs/jsoup-1.6.1.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
@@ -205,6 +205,10 @@
<activity android:name=".facilities.FacilitiesLeasedBuildingActivity" />
<activity android:name=".facilities.FacilitiesUploadSuccessModuleActivity" />
+ <!-- TOUCHSTONE -->
+ <activity android:name=".touchstone.TouchstoneActivity" />
+ <activity android:name=".TouchstonePrefsActivity"></activity>
+
<activity android:name=".about.AboutActivity" />
<activity android:name=".about.AboutMITActivity" />
<activity android:name=".about.AboutCreditsActivity" />
View
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=Google Inc.:Google APIs:7
+target=Google Inc.:Google APIs:8
View
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <edu.mit.mitmobile2.TitleBar
+ android:text="Touchstone"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <WebView android:id="@+id/touchstoneWV"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:paddingTop="@dimen/verticalPadding"
+ android:paddingBottom="@dimen/verticalPadding"
+ android:paddingLeft="@dimen/horizontalPadding"
+ android:paddingRight="@dimen/horizontalPadding" />
+
+ <TextView android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textColor="#000000"
+ android:background="@drawable/main_repeat"
+ android:id="@+id/touchstoneTest"
+ android:text="touchstone_test"
+ style="@style/SmallPrint"
+ android:paddingLeft="@dimen/horizontalPadding"
+ android:paddingRight="@dimen/horizontalPadding"
+ android:paddingTop="@dimen/verticalPadding"
+ android:paddingBottom="@dimen/verticalPadding"
+ android:scrollbars = "vertical"
+ android:visibility="visible"></TextView>
+
+</LinearLayout>
Binary file not shown.
View
@@ -85,4 +85,10 @@ MIT\&apos;s commitment to innovation has led to a host of scientific breakthroug
<item>m.mit.edu</item>
</string-array>
+ <!-- TOUCHSTONE -->
+ <string name="pref_touchstone_password_summary">Password for your touchstone account</string>
+ <string name="pref_touchstone_password_title">Password</string>
+ <string name="pref_touchstone_username_summary">User name for touchstone account</string>
+ <string name="pref_touchstone_username_title">User Name</string>
+
</resources>
View
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <EditTextPreference android:summary="@string/pref_touchstone_username_summary"
+ android:key="PREF_TOUCHSTONE_USERNAME" android:title="@string/pref_touchstone_username_title" />
+ <EditTextPreference android:summary="@string/pref_touchstone_password_summary"
+ android:key="PREF_TOUCHSTONE_PASSWORD" android:title="@string/pref_touchstone_password_title"
+ android:password="true" />
+</PreferenceScreen>
@@ -43,6 +43,7 @@
import edu.mit.mitmobile2.objs.NewsItem;
import edu.mit.mitmobile2.people.PeopleModule;
import edu.mit.mitmobile2.shuttles.ShuttlesModule;
+import edu.mit.mitmobile2.touchstone.TouchstoneModule;
import edu.mit.mitmobile2.tour.TourModule;
public class MITNewsWidgetActivity extends Activity implements OnSharedPreferenceChangeListener {
@@ -216,6 +217,7 @@ public void onClick(View v) {
new EmergencyModule(),
new FacilitiesModule(),
new QRReaderModule(),
+ new TouchstoneModule(),
};
mSpringBoard = (GridView) findViewById(R.id.homeSpringBoardGV);
@@ -0,0 +1,17 @@
+package edu.mit.mitmobile2;
+
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+public class TouchstonePrefsActivity extends PreferenceActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.touchstone);
+ }
+
+}
@@ -0,0 +1,62 @@
+package edu.mit.mitmobile2.touchstone;
+
+import edu.mit.mitmobile2.R;
+import android.content.Context;
+import android.util.Log;
+
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.SingleClientConnManager;
+
+import java.io.InputStream;
+import java.security.Certificate;
+import java.security.KeyStore;
+import java.security.PublicKey;
+
+public class MyHttpClient extends DefaultHttpClient {
+
+ final Context context;
+ public static final String TAG = "MyHttpClient";
+
+ public MyHttpClient(Context context) {
+ this.context = context;
+ }
+
+ @Override protected ClientConnectionManager createClientConnectionManager() {
+ SchemeRegistry registry = new SchemeRegistry();
+ registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ registry.register(new Scheme("https", newSslSocketFactory(), 443));
+ return new SingleClientConnManager(getParams(), registry);
+ }
+
+ private SSLSocketFactory newSslSocketFactory() {
+ try {
+ KeyStore trusted = KeyStore.getInstance("BKS");
+ InputStream in = context.getResources().openRawResource(R.raw.trusted_key_store);
+
+ try {
+ trusted.load(in, "testpass".toCharArray());
+ }
+ catch (Exception e) {
+ Log.d(TAG,e.getMessage());
+ }
+ finally {
+ in.close();
+ }
+ //DEBUG
+ java.security.cert.Certificate cert = trusted.getCertificate("ca");
+ byte[] encoded = cert.getEncoded();
+ Log.d(TAG,"encoded = " + encoded);
+ PublicKey publicKey = cert.getPublicKey();
+ Log.d(TAG,"public key = " + publicKey.getEncoded());
+ //DEBUG
+ return new SSLSocketFactory(trusted);
+ } catch (Exception e) {
+ throw new AssertionError(e);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 4de76de

Please sign in to comment.