KerberosAgent now saves successfully authenticated identities to favorites automatica...
authorJustin Anderson <jander@mit.edu>
Wed, 29 Oct 2008 21:58:56 +0000 (21:58 +0000)
committerJustin Anderson <jander@mit.edu>
Wed, 29 Oct 2008 21:58:56 +0000 (21:58 +0000)
ticket: 6222

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20940 dc483132-0cff-0310-8789-dd5450dbe970

src/kim/agent/mac/IPCClient.h
src/kim/agent/mac/IPCClient.m
src/kim/agent/mac/Identities.m

index 361c4283aadc6961bd13990eb1c0745b12da6a12..0bea6000b18cd40feb46b70e6c2931437bdc28ff 100644 (file)
@@ -28,6 +28,7 @@
 
 @class SelectIdentityController;
 @class AuthenticationController;
+@class Identities;
 
 @interface IPCClient : NSObject {
     mach_port_t port;
@@ -49,6 +50,7 @@
 @property (readonly, retain) AuthenticationController *authController;
 
 - (void) cleanup;
+- (void) saveIdentityToFavoritesIfSuccessful;
 
 - (kim_error) selectIdentity: (NSDictionary *) info;
 - (kim_error) enterIdentity: (NSDictionary *) info;
index 53a7fe54008b5acbf36ba84021b87fcb17629e23..d4ac8a699a4c22268b8c54ef39ef786eea9e254d 100644 (file)
@@ -27,6 +27,7 @@
 #import "SelectIdentityController.h"
 #import "AuthenticationController.h"
 #import "KerberosAgentListener.h"
+#import "Identities.h"
 
 enum krb_agent_client_state {
     ipc_client_state_idle,
@@ -105,6 +106,9 @@ enum krb_agent_client_state {
 
 - (void) cleanup
 {
+    if (![[self.selectController window] isVisible]) {
+        [self saveIdentityToFavoritesIfSuccessful];
+    }
     [self.selectController close];
     [self.authController close];
     self.selectController = nil;
@@ -112,6 +116,25 @@ enum krb_agent_client_state {
     self.currentInfo = nil;
 }
 
+- (void) saveIdentityToFavoritesIfSuccessful
+{
+    NSString *identityString = [self.currentInfo valueForKeyPath:@"identity_string"];
+    NSDictionary *options = [self.currentInfo valueForKeyPath:@"options"];
+    
+    Identities *identities = [[Identities alloc] init];
+    Identity *theIdentity = [[Identity alloc] initWithIdentity:identityString 
+                                                       options:options];
+    for (Identity *anIdentity in [identities identities]) {
+        if ([anIdentity isEqual:theIdentity]) {
+            if (!anIdentity.favorite) {
+                anIdentity.favorite = YES;
+                [identities synchronizePreferences];
+            }
+            break;
+        }
+    }
+}
+
 - (void) didCancel
 {
     kim_error err = KIM_USER_CANCELED_ERR;
index 13c7578f734f0bbfc297daf5da3104d0278b48c1..1fa7e6ef4e0afebab99d896abb53037149798f83 100644 (file)
             }
 
             //NSLog(@"waited %@", [[NSThread currentThread] description]);
-            [(Identities *) [connection rootProxy] update];
+            [(Identities *) [connection rootProxy] reload];
            sleep (1);
         }