Permalink
Browse files

Initial support for security questions in Mac app.

  • Loading branch information...
1 parent 0269c27 commit 64829c99d86d8312a1c167b15f04d520b4112db8 @lhunath lhunath committed Feb 21, 2016
@@ -5,7 +5,6 @@
<inspection_tool class="Convert to string" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="FunctionImplicitDeclarationInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="ImplicitIntegerAndEnumConversion" enabled="false" level="WARNING" enabled_by_default="false" />
- <inspection_tool class="LossyEncoding" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="MethodIsLaterInTheScope" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="OCNotLocalizedStringInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="OCUnusedMacroInspection" enabled="false" level="WARNING" enabled_by_default="false" />
@@ -22,6 +22,13 @@
@end
+@interface MPSiteQuestionEntity(MP)
+
+- (NSString *)resolveQuestionAnswerUsingKey:(MPKey *)key;
+- (void)resolveQuestionAnswerUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result;
+
+@end
+
@interface MPSiteEntity(MP)<MPFixable>
@property(assign) BOOL loginGenerated;
@@ -38,8 +45,10 @@
- (BOOL)tryMigrateExplicitly:(BOOL)explicit;
- (NSString *)resolveLoginUsingKey:(MPKey *)key;
- (NSString *)resolvePasswordUsingKey:(MPKey *)key;
+- (NSString *)resolveSiteAnswerUsingKey:(MPKey *)key;
- (void)resolveLoginUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result;
- (void)resolvePasswordUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result;
+- (void)resolveSiteAnswerUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result;
@end
@@ -35,6 +35,20 @@ - (BOOL)saveToStore {
@end
+@implementation MPSiteQuestionEntity(MP)
+
+- (NSString *)resolveQuestionAnswerUsingKey:(MPKey *)key {
+
+ return [self.site.algorithm resolveAnswerForQuestion:self usingKey:key];
+}
+
+- (void)resolveQuestionAnswerUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result {
+
+ [self.site.algorithm resolveAnswerForQuestion:self usingKey:key result:result];
+}
+
+@end
+
@implementation MPSiteEntity(MP)
- (MPFixableResult)findAndFixInconsistenciesInContext:(NSManagedObjectContext *)context {
@@ -175,6 +189,11 @@ - (NSString *)resolvePasswordUsingKey:(MPKey *)key {
return [self.algorithm resolvePasswordForSite:self usingKey:key];
}
+- (NSString *)resolveSiteAnswerUsingKey:(MPKey *)key {
+
+ return [self.algorithm resolveAnswerForSite:self usingKey:key];
+}
+
- (void)resolveLoginUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result {
[self.algorithm resolveLoginForSite:self usingKey:key result:result];
@@ -185,6 +204,11 @@ - (void)resolvePasswordUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))resu
[self.algorithm resolvePasswordForSite:self usingKey:key result:result];
}
+- (void)resolveSiteAnswerUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result {
+
+ [self.algorithm resolveAnswerForSite:self usingKey:key result:result];
+}
+
@end
@implementation MPGeneratedSiteEntity(MP)
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
</dependencies>
<objects>
@@ -28,6 +28,7 @@
@property(nonatomic) NSString *masterPassword;
@property(nonatomic) BOOL showVersionContainer;
@property(nonatomic) BOOL alternatePressed;
+@property(nonatomic) BOOL shiftPressed;
@property(nonatomic) BOOL locked;
@property(nonatomic) BOOL newUser;
@@ -124,6 +124,10 @@ - (void)replaceFonts:(NSView *)view {
- (void)flagsChanged:(NSEvent *)theEvent {
+ BOOL shiftPressed = (theEvent.modifierFlags & NSShiftKeyMask) != 0;
+ if (shiftPressed != self.shiftPressed)
+ self.shiftPressed = shiftPressed;
+
BOOL alternatePressed = (theEvent.modifierFlags & NSAlternateKeyMask) != 0;
if (alternatePressed != self.alternatePressed) {
self.alternatePressed = alternatePressed;
@@ -486,7 +490,7 @@ - (void)useSite {
}
// Performing action while content is available. Copy it.
- [self copyContent:selectedSite.content];
+ [self copyContent:self.shiftPressed? selectedSite.answer: selectedSite.content];
[self fadeOut];
Oops, something went wrong.

0 comments on commit 64829c9

Please sign in to comment.