2
0

Keychain fix + signout fix.

[FIXED]     GenericPassword class keychain items should have both an
            Account and a Service attribute.
[FIXED]     OS X: Logout when key is saved.
This commit is contained in:
Maarten Billemont 2012-05-13 19:50:40 +02:00
parent b0875beb36
commit ada6d6b36a
4 changed files with 17 additions and 12 deletions

View File

@ -17,8 +17,10 @@ static NSDictionary *keyQuery() {
static NSDictionary *MPKeyQuery = nil;
if (!MPKeyQuery)
MPKeyQuery = [PearlKeyChain createQueryForClass:kSecClassGenericPassword
attributes:[NSDictionary dictionaryWithObject:@"Saved Master Password"
forKey:(__bridge id)kSecAttrService]
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
@"Saved Master Password", (__bridge id)kSecAttrService,
@"default", (__bridge id)kSecAttrAccount,
nil]
matches:nil];
return MPKeyQuery;
@ -29,8 +31,10 @@ static NSDictionary *keyIDQuery() {
static NSDictionary *MPKeyIDQuery = nil;
if (!MPKeyIDQuery)
MPKeyIDQuery = [PearlKeyChain createQueryForClass:kSecClassGenericPassword
attributes:[NSDictionary dictionaryWithObject:@"Master Password Verification"
forKey:(__bridge id)kSecAttrService]
attributes:[NSDictionary dictionaryWithObjectsAndKeys:
@"Master Password Check", (__bridge id)kSecAttrService,
@"default", (__bridge id)kSecAttrAccount,
nil]
matches:nil];
return MPKeyIDQuery;
@ -39,8 +43,10 @@ static NSDictionary *keyIDQuery() {
- (void)forgetKey {
inf(@"Deleting key and ID from keychain.");
[PearlKeyChain deleteItemForQuery:keyQuery()];
[PearlKeyChain deleteItemForQuery:keyIDQuery()];
if ([PearlKeyChain deleteItemForQuery:keyQuery()] != errSecItemNotFound)
inf(@"Removed key from keychain.");
if ([PearlKeyChain deleteItemForQuery:keyIDQuery()] != errSecItemNotFound)
inf(@"Removed key ID from keychain.");
[[NSNotificationCenter defaultCenter] postNotificationName:MPNotificationKeyForgotten object:self];
#ifdef TESTFLIGHT_SDK_VERSION
@ -49,7 +55,8 @@ static NSDictionary *keyIDQuery() {
}
- (IBAction)signOut:(id)sender {
[MPConfig get].saveKey = [NSNumber numberWithBool:NO];
[self updateKey:nil];
}

View File

@ -212,9 +212,10 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
#pragma mark - UbiquityStoreManagerDelegate
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)didSwitch {
- (void)ubiquityStoreManager:(UbiquityStoreManager *)manager didSwitchToiCloud:(BOOL)iCloudEnabled {
self.useICloudItem.state = didSwitch? NSOnState: NSOffState;
self.useICloudItem.state = iCloudEnabled? NSOnState: NSOffState;
self.useICloudItem.enabled = !iCloudEnabled;
}
@end

View File

@ -105,8 +105,6 @@
// "Unlock" button.
[[MPAppDelegate get] tryMasterPassword:[(NSSecureTextField *)alert.accessoryView stringValue]];
}
[self unlock];
}
- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index {

View File

@ -425,7 +425,6 @@
case 5:
#endif
{
[MPConfig get].saveKey = [NSNumber numberWithBool:NO];
[[MPAppDelegate get] signOut:self];
[[MPAppDelegate get] loadKey:YES];
break;