Refactored naming. Added better handling of settings for touchID
This commit is contained in:
parent
76adcf74d4
commit
49326013fb
|
@ -108,11 +108,11 @@
|
||||||
self.touchIdModeButton.menu = touchIDMenu;
|
self.touchIdModeButton.menu = touchIDMenu;
|
||||||
[self.touchIdModeButton bind:NSSelectedTagBinding
|
[self.touchIdModeButton bind:NSSelectedTagBinding
|
||||||
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
||||||
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntryTouchIdEnabled]
|
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyTouchIdEnabled]
|
||||||
options:nil];
|
options:nil];
|
||||||
[self.touchIdEnabledButton bind:NSValueBinding
|
[self.touchIdEnabledButton bind:NSValueBinding
|
||||||
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
||||||
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyEntryTouchIdEnabled]
|
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyTouchIdEnabled]
|
||||||
options:nil];
|
options:nil];
|
||||||
self.touchIdEnabledButton.hidden = YES;
|
self.touchIdEnabledButton.hidden = YES;
|
||||||
if (@available(macOS 10.13.4, *)) {
|
if (@available(macOS 10.13.4, *)) {
|
||||||
|
|
|
@ -23,7 +23,8 @@
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
/* TouchID */
|
/* TouchID */
|
||||||
APPKIT_EXTERN NSString *const kMPSettingsKeyEntryTouchIdEnabled;
|
APPKIT_EXTERN NSString *const kMPSettingsKeyTouchIdEnabled;
|
||||||
|
APPKIT_EXTERN NSString *const kMPSettingsKeyTouchIdEncryptedKeyStore; // NSDictionary with hased file names mapped to keys
|
||||||
APPKIT_EXTERN NSString *const kMPSettingsKeyEntryTouchIdDatabaseEncryptedKeyFormat;
|
APPKIT_EXTERN NSString *const kMPSettingsKeyEntryTouchIdDatabaseEncryptedKeyFormat;
|
||||||
|
|
||||||
/* Clipboard */
|
/* Clipboard */
|
||||||
|
|
|
@ -67,7 +67,8 @@ NSString *const kMPSettingsKeyAutotypeMatchHost = @"Au
|
||||||
NSString *const kMPSettingsKeyAutotypeMatchTags = @"AutotypeMatchTags";
|
NSString *const kMPSettingsKeyAutotypeMatchTags = @"AutotypeMatchTags";
|
||||||
NSString *const kMPSettingsKeyGloablAutotypeAlwaysShowCandidateSelection = @"GloablAutotypeAlwaysShowCandidateSelection";
|
NSString *const kMPSettingsKeyGloablAutotypeAlwaysShowCandidateSelection = @"GloablAutotypeAlwaysShowCandidateSelection";
|
||||||
|
|
||||||
NSString *const kMPSettingsKeyEntryTouchIdEnabled = @"EnableSubsequentUnlocksWithTouchID";
|
NSString *const kMPSettingsKeyTouchIdEnabled = @"EnableSubsequentUnlocksWithTouchID";
|
||||||
|
NSString *const kMPSettingsKeyTouchIdEncryptedKeyStore = @"TouchIdEncryptedKeyStore";
|
||||||
NSString *const kMPSettingsKeyEntryTouchIdDatabaseEncryptedKeyFormat = @"EncryptedDatabaseKeyForTouchID-%@";
|
NSString *const kMPSettingsKeyEntryTouchIdDatabaseEncryptedKeyFormat = @"EncryptedDatabaseKeyForTouchID-%@";
|
||||||
|
|
||||||
NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext";
|
NSString *const kMPSettingsKeyEntrySearchFilterContext = @"EntrySearchFilterContext";
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
@interface MPTouchIdCompositeKeyStore ()
|
@interface MPTouchIdCompositeKeyStore ()
|
||||||
@property (readonly, strong) NSMutableDictionary* keys;
|
@property (readonly, strong) NSMutableDictionary* keys;
|
||||||
|
@property (nonatomic) NSInteger touchIdEnabledState;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MPTouchIdCompositeKeyStore
|
@implementation MPTouchIdCompositeKeyStore
|
||||||
|
@ -30,10 +31,31 @@
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if(self) {
|
if(self) {
|
||||||
_keys = [[NSMutableDictionary alloc] init];
|
_keys = [[NSMutableDictionary alloc] init];
|
||||||
|
[self bind:NSStringFromSelector(@selector(touchIdEnabledState))
|
||||||
|
toObject:NSUserDefaultsController.sharedUserDefaultsController
|
||||||
|
withKeyPath:[MPSettingsHelper defaultControllerPathForKey:kMPSettingsKeyTouchIdEnabled]
|
||||||
|
options:nil];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setTouchIdEnabledState:(NSInteger)touchIdEnabledState {
|
||||||
|
switch(touchIdEnabledState) {
|
||||||
|
case NSControlStateValueMixed:
|
||||||
|
// clear persistent store
|
||||||
|
[NSUserDefaults.standardUserDefaults removeObjectForKey:kMPSettingsKeyTouchIdEncryptedKeyStore];
|
||||||
|
break;
|
||||||
|
case NSControlStateValueOn:
|
||||||
|
// clear transient store
|
||||||
|
[self.keys removeAllObjects];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// clear persitent and transient store
|
||||||
|
[NSUserDefaults.standardUserDefaults removeObjectForKey:kMPSettingsKeyTouchIdEncryptedKeyStore];
|
||||||
|
[self.keys removeAllObjects];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)saveCompositeKey:(KPKCompositeKey *)compositeKey forDocumentKey:(NSString *)documentKey {
|
- (void)saveCompositeKey:(KPKCompositeKey *)compositeKey forDocumentKey:(NSString *)documentKey {
|
||||||
NSError *error;
|
NSError *error;
|
||||||
NSData *encryptedCompositeKey = [self encryptedDataForCompositeKey:compositeKey error:&error];
|
NSData *encryptedCompositeKey = [self encryptedDataForCompositeKey:compositeKey error:&error];
|
||||||
|
@ -42,7 +64,9 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSInteger touchIdMode = [NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyEntryTouchIdEnabled];
|
/* FIXME this behavour is wrong. Old keys do not get cleared so this leaves a lot of data behind that should be cleaned up*/
|
||||||
|
|
||||||
|
NSInteger touchIdMode = [NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyTouchIdEnabled];
|
||||||
switch(touchIdMode) {
|
switch(touchIdMode) {
|
||||||
case NSControlStateValueMixed:
|
case NSControlStateValueMixed:
|
||||||
[NSUserDefaults.standardUserDefaults removeObjectForKey:documentKey];
|
[NSUserDefaults.standardUserDefaults removeObjectForKey:documentKey];
|
||||||
|
@ -62,7 +86,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (NSData *)loadEncryptedCompositeKeyForDocumentKey:(NSString *)documentKey {
|
- (NSData *)loadEncryptedCompositeKeyForDocumentKey:(NSString *)documentKey {
|
||||||
NSInteger touchIdMode = [NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyEntryTouchIdEnabled];
|
NSInteger touchIdMode = [NSUserDefaults.standardUserDefaults integerForKey:kMPSettingsKeyTouchIdEnabled];
|
||||||
NSData* transientKey = self.keys[documentKey];
|
NSData* transientKey = self.keys[documentKey];
|
||||||
NSData* persistentKey =[NSUserDefaults.standardUserDefaults dataForKey:documentKey];
|
NSData* persistentKey =[NSUserDefaults.standardUserDefaults dataForKey:documentKey];
|
||||||
if(nil == transientKey && nil == persistentKey) {
|
if(nil == transientKey && nil == persistentKey) {
|
||||||
|
|
Loading…
Reference in New Issue