summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJustin Anderson <jander@mit.edu>2008-10-02 13:20:04 +0000
committerJustin Anderson <jander@mit.edu>2008-10-02 13:20:04 +0000
commitea05c23ca1596d0b3a0f1e0c2e00b841d942399f (patch)
treed740aeb5a1b5bfc2973b8750f3967f240636db84 /src
parent63b0e281cfdfa1cb4f8487cc5f53cdf5c1860c06 (diff)
downloadkrb5-ea05c23ca1596d0b3a0f1e0c2e00b841d942399f.tar.gz
krb5-ea05c23ca1596d0b3a0f1e0c2e00b841d942399f.tar.xz
krb5-ea05c23ca1596d0b3a0f1e0c2e00b841d942399f.zip
Make enter identity dialog's smarter about matching a string with a set of favorite options
ticket:6055 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20808 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src')
-rw-r--r--src/kim/agent/mac/AuthenticationController.h3
-rw-r--r--src/kim/agent/mac/AuthenticationController.m79
-rw-r--r--src/kim/agent/mac/KIMUtilities.h2
-rw-r--r--src/kim/agent/mac/KIMUtilities.m29
-rw-r--r--src/kim/agent/mac/resources/English.lproj/Authentication.xib33
5 files changed, 115 insertions, 31 deletions
diff --git a/src/kim/agent/mac/AuthenticationController.h b/src/kim/agent/mac/AuthenticationController.h
index 4035668e2..c62611db7 100644
--- a/src/kim/agent/mac/AuthenticationController.h
+++ b/src/kim/agent/mac/AuthenticationController.h
@@ -97,4 +97,7 @@
returnCode: (int) returnCode
contextInfo: (void *) contextInfo;
+- (IBAction) changePasswordGearAction: (id) sender;
+- (void) changePasswordThread: (NSString *) identityString;
+
@end
diff --git a/src/kim/agent/mac/AuthenticationController.m b/src/kim/agent/mac/AuthenticationController.m
index eaf4e6913..34e7662d2 100644
--- a/src/kim/agent/mac/AuthenticationController.m
+++ b/src/kim/agent/mac/AuthenticationController.m
@@ -370,17 +370,23 @@
- (IBAction) showTicketOptions: (id) sender
{
NSDictionary *options = nil;
+ NSString *expandedString = nil;
// if this is a favorite, try to load its default options
[identityField validateEditing];
- options = [favoriteOptions valueForKey:[identityField stringValue]];
+ expandedString = [KIMUtilities expandedIdentity:[identityField stringValue]];
+
+ // edit the favorite options for this favorite identity
+ if (expandedString) {
+ options = [favoriteOptions objectForKey:expandedString];
+ }
+ // else fallback to options passed from client
+ // use a copy of the current options
if (!options) {
options = [[[glueController valueForKeyPath:options_keypath] mutableCopy] autorelease];
}
- // else fallback to options passed from client
- // use a copy of the current options
[ticketOptionsController setContent:options];
[ticketOptionsController setValue:[NSNumber numberWithInteger:[KIMUtilities minValidLifetime]]
@@ -424,26 +430,31 @@
// discard new options
[ticketOptionsController setContent:nil];
} else {
- // replace existing options with new
- // add to favorites if not already in list
-
- // replace options of existing if already in list
kim_error err = KIM_NO_ERROR;
kim_preferences prefs = NULL;
kim_identity identity = NULL;
kim_options options = NULL;
+ NSString *expandedString = [KIMUtilities expandedIdentity:[identityField stringValue]];;
- [glueController setValue:[ticketOptionsController content]
- forKeyPath:options_keypath];
-
- err = kim_preferences_create(&prefs);
-
+ // replace options if favorite exists
+ // add to favorites if not already in list
+ if (!expandedString) {
+ err = KIM_BAD_PRINCIPAL_STRING_ERR;
+ }
+ if (!err) {
+ [favoriteOptions setObject:[ticketOptionsController content]
+ forKey:expandedString];
+ }
+ if (!err) {
+ err = kim_preferences_create(&prefs);
+ }
if (!err) {
err = kim_identity_create_from_string(&identity, [[identityField stringValue] UTF8String]);
}
if (!err) {
options = [KIMUtilities kimOptionsForDictionary:[ticketOptionsController content]];
}
+
if (!identity) { err = KIM_BAD_PRINCIPAL_STRING_ERR; }
if (!options) { err = KIM_BAD_OPTIONS_ERR; }
@@ -453,7 +464,6 @@
if (!err && identity && options) {
err = kim_preferences_add_favorite_identity(prefs, identity, options);
}
-
if (!err) {
err = kim_preferences_synchronize(prefs);
}
@@ -465,6 +475,40 @@
[ticketOptionsSheet orderOut:nil];
}
+- (IBAction) changePasswordGearAction: (id) sender
+{
+ NSString *expandedString = [KIMUtilities expandedIdentity:[identityField stringValue]];
+ NSLog(@"%s", __FUNCTION__);
+ if (expandedString && [expandedString length] > 0) {
+ [expandedString retain];
+ [NSThread detachNewThreadSelector:@selector(changePasswordThread:)
+ toTarget:self
+ withObject:expandedString];
+ }
+}
+
+- (void) changePasswordThread: (NSString *) identityString
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ kim_error err = KIM_NO_ERROR;
+ kim_identity identity = NULL;
+
+ NSLog(@"%s %@", __FUNCTION__, identityString);
+ if (!err) {
+ err = kim_identity_create_from_string(&identity, [identityString UTF8String]);
+ }
+ if (!err) {
+ err = kim_identity_change_password(identity);
+ }
+
+ NSLog(@"%s %d", __FUNCTION__, err);
+
+ kim_identity_free(&identity);
+
+ [identityString release];
+ [pool release];
+}
+
- (IBAction) cancel: (id) sender
{
[associatedClient didCancel];
@@ -473,11 +517,14 @@
- (IBAction) enterIdentity: (id) sender
{
- NSString *identityString = [glueController valueForKeyPath:identity_string_keypath];
- NSDictionary *options = [glueController valueForKeyPath:options_keypath];
+ NSString *expandedString = [KIMUtilities expandedIdentity:[identityField stringValue]];
+ NSDictionary *options = [favoriteOptions objectForKey:expandedString];
+ if (!options) {
+ options = [glueController valueForKeyPath:options_keypath];
+ }
// the principal must already be valid to get this far
- [associatedClient didEnterIdentity:identityString options:options];
+ [associatedClient didEnterIdentity:expandedString options:options];
}
- (IBAction) answerAuthPrompt: (id) sender
diff --git a/src/kim/agent/mac/KIMUtilities.h b/src/kim/agent/mac/KIMUtilities.h
index 4e448b9d5..516e8effe 100644
--- a/src/kim/agent/mac/KIMUtilities.h
+++ b/src/kim/agent/mac/KIMUtilities.h
@@ -82,6 +82,8 @@ NSLog(@"%s got error %@", __FUNCTION__, [KIMUtilities stringForLastKIMError:err]
+ (BOOL) validateIdentity: (NSString *) identityString;
++ (NSString *) expandedIdentity: (NSString *) identityString;
+
+ (NSDictionary *) dictionaryForKimOptions: (kim_options) options;
+ (kim_options) kimOptionsForDictionary: (NSDictionary *) aDict;
diff --git a/src/kim/agent/mac/KIMUtilities.m b/src/kim/agent/mac/KIMUtilities.m
index f450cdf2b..34ff38e7f 100644
--- a/src/kim/agent/mac/KIMUtilities.m
+++ b/src/kim/agent/mac/KIMUtilities.m
@@ -63,6 +63,7 @@
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
+
if (!identityString || [identityString length] <= 1) {
err = KIM_BAD_PRINCIPAL_STRING_ERR;
}
@@ -77,6 +78,34 @@
return (err == KIM_NO_ERROR);
}
++ (NSString *) expandedIdentity: (NSString *) identityString
+{
+ NSString *result = nil;
+ kim_error err = KIM_NO_ERROR;
+ kim_identity identity = NULL;
+ kim_string validated_string = NULL;
+
+ // convert to how it will actually be
+ // e.g. foo becomes foo@ATHENA.MIT.EDU
+ // for the purpose of matching to a favorite
+ if (!identityString) {
+ err = KIM_BAD_PRINCIPAL_STRING_ERR;
+ }
+ if (!err) {
+ err = kim_identity_create_from_string(&identity, [identityString UTF8String]);
+ }
+ if (!err && identity) {
+ err = kim_identity_get_display_string(identity, &validated_string);
+ }
+ if (!err && validated_string) {
+ result = [NSString stringWithUTF8String:validated_string];
+ }
+ kim_identity_free(&identity);
+ kim_string_free(&validated_string);
+
+ return result;
+}
+
+ (NSDictionary *) dictionaryForKimOptions: (kim_options) options
{
kim_error err = KIM_NO_ERROR;
diff --git a/src/kim/agent/mac/resources/English.lproj/Authentication.xib b/src/kim/agent/mac/resources/English.lproj/Authentication.xib
index e5273b70c..d665e878d 100644
--- a/src/kim/agent/mac/resources/English.lproj/Authentication.xib
+++ b/src/kim/agent/mac/resources/English.lproj/Authentication.xib
@@ -341,6 +341,7 @@
</object>
<object class="NSMenuItem" id="744766544">
<reference key="NSMenu" ref="594991555"/>
+ <bool key="NSIsHidden">YES</bool>
<string type="base64-UTF8" key="NSTitle">Q2hhbmdlIFBhc3N3b3Jk4oCmA</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
@@ -373,6 +374,7 @@
</object>
</object>
</object>
+ <int key="NSSelectedIndex">2</int>
<bool key="NSPullDown">YES</bool>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
@@ -386,7 +388,7 @@
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="866582848">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -395,7 +397,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{104, 82}, {376, 22}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="508869457">
<int key="NSCellFlags">-1804468671</int>
@@ -418,7 +419,6 @@
<int key="NSvFlags">289</int>
<string key="NSFrame">{{388, 12}, {98, 32}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="200893597">
<int key="NSCellFlags">67239424</int>
@@ -440,7 +440,6 @@
<int key="NSvFlags">289</int>
<string key="NSFrame">{{295, 12}, {93, 32}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="935364959">
<int key="NSCellFlags">67239424</int>
@@ -462,7 +461,6 @@
<int key="NSvFlags">266</int>
<string key="NSFrame">{{101, 126}, {382, 41}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="999660494">
<int key="NSCellFlags">67239424</int>
@@ -479,7 +477,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 84}, {80, 17}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="916263740">
<int key="NSCellFlags">68288064</int>
@@ -496,7 +493,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{102, 58}, {380, 18}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="883697888">
<int key="NSCellFlags">-2080244224</int>
@@ -524,13 +520,10 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 126}, {64, 64}}</string>
<reference key="NSSuperview" ref="866582848"/>
- <reference key="NSWindow"/>
<string key="NSClassName">BadgedImageView</string>
</object>
</object>
<string key="NSFrameSize">{500, 210}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="898191415">
@@ -2019,7 +2012,7 @@
<string key="NSKeyPath">selection.identity_string</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSContinuouslyUpdatesValue</string>
- <integer value="1" key="NS.object.0" id="5"/>
+ <reference key="NS.object.0" ref="9"/>
</object>
<reference key="NSPreviousConnector" ref="407856422"/>
<int key="NSNibBindingConnectorVersion">2</int>
@@ -2040,7 +2033,7 @@
<string key="NSKeyPath">selection.valid_lifetime</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSContinuouslyUpdatesValue</string>
- <reference key="NS.object.0" ref="5"/>
+ <reference key="NS.object.0" ref="9"/>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
@@ -2060,7 +2053,7 @@
<string key="NSKeyPath">selection.renewal_lifetime</string>
<object class="NSDictionary" key="NSOptions">
<string key="NS.key.0">NSContinuouslyUpdatesValue</string>
- <reference key="NS.object.0" ref="5"/>
+ <reference key="NS.object.0" ref="9"/>
</object>
<int key="NSNibBindingConnectorVersion">2</int>
</object>
@@ -2083,6 +2076,14 @@
</object>
<int key="connectionID">300520</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">changePasswordGearAction:</string>
+ <reference key="source" ref="262677138"/>
+ <reference key="destination" ref="744766544"/>
+ </object>
+ <int key="connectionID">300522</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -3121,7 +3122,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{611, 382}, {189, 93}}</string>
+ <string>{{611, 408}, {189, 93}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -3201,7 +3202,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">300520</int>
+ <int key="maxID">300522</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -3217,6 +3218,7 @@
<string>cancel:</string>
<string>cancelTicketOptions:</string>
<string>changePassword:</string>
+ <string>changePasswordGearAction:</string>
<string>enterIdentity:</string>
<string>saveTicketOptions:</string>
<string>showTicketOptions:</string>
@@ -3234,6 +3236,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
+ <string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">