Added a secret button to the login controller to start the J-PAKE process experimental
authorstefan
Fri, 22 Oct 2010 14:24:43 -0400
branchexperimental
changeset 183 3585b1c166a60bc34cf5495d24cedf2b3623c39c
parent 182 acc2f52b762e5ff1f4d8f7e9a149094b5fd7748f
push id114
push userstefan@arentz.ca
push dateFri, 22 Oct 2010 18:25:05 +0000
Added a secret button to the login controller to start the J-PAKE process
Sources/English.lproj/LoginController.xib
Sources/UserInterface/LoginController.h
Sources/UserInterface/LoginController.m
--- a/Sources/English.lproj/LoginController.xib
+++ b/Sources/English.lproj/LoginController.xib
@@ -7,18 +7,18 @@
 		<string key="IBDocument.AppKitVersion">1038.29</string>
 		<string key="IBDocument.HIToolboxVersion">461.00</string>
 		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
 			<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 			<string key="NS.object.0">123</string>
 		</object>
 		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
 			<bool key="EncodedWithXMLCoder">YES</bool>
+			<integer value="31"/>
 			<integer value="4"/>
-			<integer value="31"/>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 		</object>
 		<object class="NSMutableDictionary" key="IBDocument.Metadata">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 			<object class="NSArray" key="dict.sortedKeys" id="0">
@@ -182,41 +182,58 @@
 						<reference key="NSNextResponder" ref="412782505"/>
 						<int key="NSvFlags">297</int>
 						<string key="NSFrame">{{220, 80}, {80, 25}}</string>
 						<reference key="NSSuperview" ref="412782505"/>
 						<bool key="IBUIOpaque">NO</bool>
 						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 						<int key="IBUIContentHorizontalAlignment">0</int>
 						<int key="IBUIContentVerticalAlignment">0</int>
-						<object class="NSFont" key="IBUIFont">
+						<object class="NSFont" key="IBUIFont" id="718911975">
 							<string key="NSName">Helvetica-Bold</string>
 							<double key="NSSize">15</double>
 							<int key="NSfFlags">16</int>
 						</object>
 						<int key="IBUILineBreakMode">4</int>
 						<string key="IBUINormalTitle">Help!</string>
 						<object class="NSColor" key="IBUIHighlightedTitleColor" id="272482259">
 							<int key="NSColorSpace">3</int>
 							<bytes key="NSWhite">MQA</bytes>
 						</object>
 						<object class="NSColor" key="IBUINormalTitleColor">
 							<int key="NSColorSpace">3</int>
 							<bytes key="NSWhite">MQA</bytes>
 							<reference key="NSCustomColorSpace" ref="945719015"/>
 						</object>
-						<object class="NSColor" key="IBUINormalTitleShadowColor">
+						<object class="NSColor" key="IBUINormalTitleShadowColor" id="710074458">
 							<int key="NSColorSpace">3</int>
 							<bytes key="NSWhite">MC41AA</bytes>
 						</object>
 						<object class="NSCustomResource" key="IBUINormalBackgroundImage">
 							<string key="NSClassName">NSImage</string>
 							<string key="NSResourceName">button-small-default.png</string>
 						</object>
 					</object>
+					<object class="IBUIButton" id="491835024">
+						<reference key="NSNextResponder" ref="412782505"/>
+						<int key="NSvFlags">292</int>
+						<string key="NSFrame">{{62, 24}, {59, 66}}</string>
+						<reference key="NSSuperview" ref="412782505"/>
+						<bool key="IBUIOpaque">NO</bool>
+						<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+						<int key="IBUIContentHorizontalAlignment">0</int>
+						<int key="IBUIContentVerticalAlignment">0</int>
+						<reference key="IBUIFont" ref="718911975"/>
+						<reference key="IBUIHighlightedTitleColor" ref="272482259"/>
+						<object class="NSColor" key="IBUINormalTitleColor">
+							<int key="NSColorSpace">1</int>
+							<bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes>
+						</object>
+						<reference key="IBUINormalTitleShadowColor" ref="710074458"/>
+					</object>
 				</object>
 				<string key="NSFrameSize">{320, 460}</string>
 				<reference key="NSSuperview"/>
 				<reference key="IBUIBackgroundColor" ref="272482259"/>
 				<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
 				<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
 			</object>
 			<object class="IBUIView" id="1049553232">
@@ -352,16 +369,25 @@
 					<object class="IBCocoaTouchEventConnection" key="connection">
 						<string key="label">loginHelp</string>
 						<reference key="source" ref="1001823222"/>
 						<reference key="destination" ref="372490531"/>
 						<int key="IBEventType">7</int>
 					</object>
 					<int key="connectionID">47</int>
 				</object>
+				<object class="IBConnectionRecord">
+					<object class="IBCocoaTouchEventConnection" key="connection">
+						<string key="label">cake</string>
+						<reference key="source" ref="491835024"/>
+						<reference key="destination" ref="372490531"/>
+						<int key="IBEventType">7</int>
+					</object>
+					<int key="connectionID">50</int>
+				</object>
 			</object>
 			<object class="IBMutableOrderedSet" key="objectRecords">
 				<object class="NSArray" key="orderedObjects">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<object class="IBObjectRecord">
 						<int key="objectID">0</int>
 						<reference key="object" ref="0"/>
 						<reference key="children" ref="1000"/>
@@ -385,16 +411,17 @@
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<reference ref="202975862"/>
 							<reference ref="1001823222"/>
 							<reference ref="484499354"/>
 							<reference ref="993096758"/>
 							<reference ref="756434886"/>
 							<reference ref="362041752"/>
 							<reference ref="228060581"/>
+							<reference ref="491835024"/>
 						</object>
 						<reference key="parent" ref="0"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">5</int>
 						<reference key="object" ref="202975862"/>
 						<reference key="parent" ref="412782505"/>
 					</object>
@@ -444,16 +471,21 @@
 						<reference key="object" ref="362041752"/>
 						<reference key="parent" ref="412782505"/>
 					</object>
 					<object class="IBObjectRecord">
 						<int key="objectID">44</int>
 						<reference key="object" ref="228060581"/>
 						<reference key="parent" ref="412782505"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">48</int>
+						<reference key="object" ref="491835024"/>
+						<reference key="parent" ref="412782505"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
 				<bool key="EncodedWithXMLCoder">YES</bool>
 				<object class="NSArray" key="dict.sortedKeys">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<string>-1.CustomClassName</string>
 					<string>-2.CustomClassName</string>
@@ -462,30 +494,32 @@
 					<string>31.IBPluginDependency</string>
 					<string>32.IBPluginDependency</string>
 					<string>33.IBPluginDependency</string>
 					<string>4.IBEditorWindowLastContentRect</string>
 					<string>4.IBPluginDependency</string>
 					<string>40.IBPluginDependency</string>
 					<string>41.IBPluginDependency</string>
 					<string>44.IBPluginDependency</string>
+					<string>48.IBPluginDependency</string>
 					<string>5.IBPluginDependency</string>
 					<string>7.IBPluginDependency</string>
 					<string>9.IBPluginDependency</string>
 				</object>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 					<string>LoginController</string>
 					<string>UIResponder</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>{{68, 340}, {320, 460}}</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
-					<string>{{99, 116}, {320, 460}}</string>
+					<string>{{473, 630}, {320, 460}}</string>
+					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 					<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
 				</object>
@@ -501,33 +535,54 @@
 			<object class="NSMutableDictionary" key="localizations">
 				<bool key="EncodedWithXMLCoder">YES</bool>
 				<reference key="dict.sortedKeys" ref="0"/>
 				<object class="NSMutableArray" key="dict.values">
 					<bool key="EncodedWithXMLCoder">YES</bool>
 				</object>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">47</int>
+			<int key="maxID">50</int>
 		</object>
 		<object class="IBClassDescriber" key="IBDocument.Classes">
 			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
 				<bool key="EncodedWithXMLCoder">YES</bool>
 				<object class="IBPartialClassDescription">
 					<string key="className">LoginController</string>
 					<string key="superclassName">UIViewController</string>
 					<object class="NSMutableDictionary" key="actions">
-						<string key="NS.key.0">loginHelp</string>
-						<string key="NS.object.0">id</string>
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>cake</string>
+							<string>loginHelp</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>id</string>
+							<string>id</string>
+						</object>
 					</object>
 					<object class="NSMutableDictionary" key="actionInfosByName">
-						<string key="NS.key.0">loginHelp</string>
-						<object class="IBActionInfo" key="NS.object.0">
-							<string key="name">loginHelp</string>
-							<string key="candidateClassName">id</string>
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>cake</string>
+							<string>loginHelp</string>
+						</object>
+						<object class="NSMutableArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<object class="IBActionInfo">
+								<string key="name">cake</string>
+								<string key="candidateClassName">id</string>
+							</object>
+							<object class="IBActionInfo">
+								<string key="name">loginHelp</string>
+								<string key="candidateClassName">id</string>
+							</object>
 						</object>
 					</object>
 					<object class="NSMutableDictionary" key="outlets">
 						<bool key="EncodedWithXMLCoder">YES</bool>
 						<object class="NSArray" key="dict.sortedKeys">
 							<bool key="EncodedWithXMLCoder">YES</bool>
 							<string>passwordField</string>
 							<string>secretPhraseField</string>
--- a/Sources/UserInterface/LoginController.h
+++ b/Sources/UserInterface/LoginController.h
@@ -32,18 +32,19 @@
  required by the GPL or the LGPL. If you do not delete the provisions above, a
  recipient may use your version of this file under the terms of any one of the
  MPL, the GPL or the LGPL.
   
  ***** END LICENSE BLOCK *****/
 
 #import <UIKit/UIKit.h>
 #import "CryptoUtils.h"
+#import "JPAKEViewController.h"
 
-@interface LoginController : UIViewController <UITextFieldDelegate, UIAlertViewDelegate>
+@interface LoginController : UIViewController <UITextFieldDelegate, UIAlertViewDelegate, JPAKEViewControllerDelegate>
 {
   UITextField *userNameField;
 	UITextField *passwordField;
 	UITextField *secretPhraseField;
   
   UIView* spinnerView;
   UIActivityIndicatorView* spinner;
   CryptoUtils* _newCryptoManager;
@@ -52,9 +53,11 @@
 - (IBAction) loginHelp;
 
 @property (nonatomic, retain) IBOutlet UITextField *userNameField;
 @property (nonatomic, retain) IBOutlet UITextField *passwordField;
 @property (nonatomic, retain) IBOutlet UITextField *secretPhraseField;
 @property (nonatomic, retain) IBOutlet UIView *spinnerView;
 @property (nonatomic, retain) IBOutlet UIActivityIndicatorView* spinner;
 
+- (IBAction) cake;
+
 @end
--- a/Sources/UserInterface/LoginController.m
+++ b/Sources/UserInterface/LoginController.m
@@ -207,9 +207,42 @@
   [_newCryptoManager release];
   [super dealloc];
 }
 
 //- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 //  return YES;
 //}
 
+#pragma mark -
+
+- (IBAction) cake
+{
+	JPAKEViewController* vc = [[JPAKEViewController new] autorelease];
+	if (vc != nil) {
+		vc.server = [NSURL URLWithString: @"http://localhost:5000"];
+		vc.delegate = self;
+		[self presentModalViewController: vc animated: YES];
+	}
+}
+
+#pragma mark -
+
+- (void) JPAKEViewController: (JPAKEViewController*) vc didFinishWithMessage: (id) message
+{
+	[vc dismissModalViewControllerAnimated: YES];
+
+	userNameField.text = [message objectForKey: @"username"];
+	passwordField.text = [message objectForKey: @"password"];
+	secretPhraseField.text = [message objectForKey: @"secret"];
+}
+
+- (void) JPAKEViewController: (JPAKEViewController*) vc didFailWithError: (NSError*) error
+{
+	[vc dismissModalViewControllerAnimated: YES];
+
+	UIAlertView* alert = [[[UIAlertView alloc] initWithTitle: @"Received J-PAKE Error"
+		message: [error localizedDescription]
+			delegate: nil cancelButtonTitle: @"OK" otherButtonTitles: nil] autorelease];
+	[alert show];
+}
+
 @end