Skip to content

Commit

Permalink
SSKeychain -> SAMKeychain
Browse files Browse the repository at this point in the history
  • Loading branch information
donholly committed Sep 29, 2016
1 parent cce3fbc commit 7534327
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 104 deletions.
4 changes: 2 additions & 2 deletions DHPasscodeManager.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DHPasscodeManager"
s.author = { "Don Holly" => "[email protected]" }
s.version = "0.9.5"
s.version = "0.9.6"
s.summary = "The easiest way to add a passcode and TouchID support to your iOS App."
s.license = { :type => 'MIT', :text => <<-LICENSE
The MIT License (MIT)
Expand Down Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/donholly/DHPasscodeManager.git" }
s.source_files = "DHPasscodeManager/**/*.{h,m}"

s.dependency "SSKeychain"
s.dependency "SAMKeychain"
s.dependency "ReactiveCocoa", "2.3.1"

s.framework = 'LocalAuthentication'
Expand Down
48 changes: 24 additions & 24 deletions DHPasscodeManager/controller/DHPasscodeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ - (void)viewDidLayoutSubviews {
CGRectGetMaxY(self.instructionsLabel.frame) + DH_PASSCODE_SPACING,
DH_PASSCODE_DOT_SIZE,
DH_PASSCODE_DOT_SIZE);

self.dotView1.frame = CGRectMake(self.view.frame.size.width/2 - DH_PASSCODE_DOT_SIZE - (0.5 * DH_PASSCODE_DOT_SPACING),
CGRectGetMaxY(self.instructionsLabel.frame) + DH_PASSCODE_SPACING,
DH_PASSCODE_DOT_SIZE,
Expand All @@ -251,7 +251,7 @@ - (void)viewDidLayoutSubviews {
DH_PASSCODE_DOT_SIZE);

// Layout the buttons

// Middle column
self.passcodeButton2.frame = CGRectMake(self.view.center.x - DH_PASSCODE_BUTTON_SIZE/2,
CGRectGetMaxY(self.dotView0.frame) + instructionsPadding,
Expand Down Expand Up @@ -306,7 +306,7 @@ - (void)viewDidLayoutSubviews {
}

- (void)presentTouchIdWithCompletionBlock:(void (^)(BOOL success, NSError *error))completionBlock {

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
LAContext *context = [[LAContext alloc] init];

Expand Down Expand Up @@ -337,7 +337,7 @@ - (void)presentTouchIdWithCompletionBlock:(void (^)(BOOL success, NSError *error
}

- (void)setupSignals {

@weakify(self)

RACSignal *typeSignal = RACObserve(self, type);
Expand Down Expand Up @@ -507,7 +507,7 @@ - (void)setupSignals {
[tuple.first integerValue] == DHPasscodeViewControllerTypeRemove) {

if ([tuple.first integerValue] == DHPasscodeViewControllerTypeAuthenticate) {

NSLog(@"Authenticated with passcode");

if (self.completionBlock) {
Expand All @@ -519,9 +519,9 @@ - (void)setupSignals {
NSLog(@"Disabling passcode");

NSError *removePasscodeError;
BOOL removed = [SSKeychain deletePasswordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&removePasscodeError];
BOOL removed = [SAMKeychain deletePasswordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&removePasscodeError];

if (removePasscodeError) {
NSLog(@"Error removing passcode: %@", removePasscodeError);
Expand Down Expand Up @@ -555,10 +555,10 @@ - (void)setupSignals {
NSLog(@"Creating passcode");

NSError *createPasscodeError;
BOOL created = [SSKeychain setPassword:firstInput
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&createPasscodeError];
BOOL created = [SAMKeychain setPassword:firstInput
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&createPasscodeError];

if (createPasscodeError) {
NSLog(@"Error creating passcode: %@", createPasscodeError);
Expand Down Expand Up @@ -599,10 +599,10 @@ - (void)setupSignals {
NSLog(@"Changing passcode");

NSError *changePasscodeError;
BOOL changed = [SSKeychain setPassword:secondInput
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&changePasscodeError];
BOOL changed = [SAMKeychain setPassword:secondInput
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&changePasscodeError];

if (changePasscodeError) {
NSLog(@"Error changing passcode: %@", changePasscodeError);
Expand Down Expand Up @@ -666,12 +666,12 @@ - (void)loadStyle {
[self.dotViews enumerateObjectsUsingBlock:^(DHPasscodeDotView *dotView, NSUInteger idx, BOOL *stop) {
dotView.style = self.style;
}];

[self.passcodeButtons enumerateObjectsUsingBlock:^(DHPasscodeButton *passcodeButton, NSUInteger idx, BOOL *stop) {
passcodeButton.style = self.style;
}];
}

self.logoImageView.image = self.style.logoImage;

self.cancelButton.titleLabel.font = self.style.cancelButtonTextFont;
Expand Down Expand Up @@ -719,11 +719,11 @@ - (void)enablePasscodeButtons:(BOOL)enable {
}

- (NSString *)currentPasscodeString {

NSError *error = nil;
NSString *password = [SSKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&error];
NSString *password = [SAMKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&error];

if (error && [error code] != errSecItemNotFound) {
NSLog(@"Error fetching passcode: %@", [error localizedDescription]);
Expand Down Expand Up @@ -757,7 +757,7 @@ - (void)setType:(DHPasscodeViewControllerType)type {
}

- (NSMutableArray *)currentInput {

NSMutableArray *currentInput = self.firstInput;

if (self.firstInput.count == DH_PASSCODE_LENGTH) {
Expand Down Expand Up @@ -786,7 +786,7 @@ - (NSMutableArray *)lastInput {
}
}
}

return lastInput;
}

Expand Down
2 changes: 1 addition & 1 deletion DHPasscodeManager/util/DHPasscodeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#import "DHPasscodeManagerStyle.h"

#import <SSKeychain/SSKeychain.h>
#import <SAMKeychain/SAMKeychain.h>

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
#import <LocalAuthentication/LocalAuthentication.h>
Expand Down
68 changes: 34 additions & 34 deletions DHPasscodeManager/util/DHPasscodeManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ - (BOOL)shouldRequirePasscode {

- (NSDate *)lastActiveDate {
NSError *error;
NSString *value = [SSKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_LAST_SEEN
error:&error];
NSString *value = [SAMKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_LAST_SEEN
error:&error];

if (error && error.code != errSecItemNotFound) {
NSLog(@"Error determining passcode interval: %@", error);
Expand All @@ -220,10 +220,10 @@ - (NSDate *)lastActiveDate {
- (void)markLastActive:(NSDate *)date {
NSError *error;
NSString *lastSeenDate = [NSString stringWithFormat:@"%@", [_lastActiveDateFormatter stringFromDate:date]];
BOOL success = [SSKeychain setPassword:lastSeenDate
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_LAST_SEEN
error:&error];
BOOL success = [SAMKeychain setPassword:lastSeenDate
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_LAST_SEEN
error:&error];

if (!success || (error && error.code != errSecItemNotFound)) {
NSLog(@"Error setting last seen date: %@", error);
Expand Down Expand Up @@ -265,9 +265,9 @@ - (BOOL)touchIDSupported {

- (BOOL)touchIDEnabled {
NSError *error;
NSString *value = [SSKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TOUCHID_ENABLED
error:&error];
NSString *value = [SAMKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TOUCHID_ENABLED
error:&error];

if (error && [error code] != errSecItemNotFound) {
NSLog(@"Error determining if TouchID is enabled: %@", error);
Expand All @@ -284,10 +284,10 @@ - (BOOL)touchIDEnabled {

- (void)setTouchIDEnabled:(BOOL)touchIDEnabled {
NSError *error;
BOOL success = [SSKeychain setPassword:[NSString stringWithFormat:@"%@", @(touchIDEnabled)]
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TOUCHID_ENABLED
error:&error];
BOOL success = [SAMKeychain setPassword:[NSString stringWithFormat:@"%@", @(touchIDEnabled)]
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TOUCHID_ENABLED
error:&error];

if (!success || error) {
NSLog(@"Error setting TouchID to enabled/disabled: %@", error);
Expand All @@ -296,9 +296,9 @@ - (void)setTouchIDEnabled:(BOOL)touchIDEnabled {

- (BOOL)isPasscodeStored {
NSError *error = nil;
NSString *passcode = [SSKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&error];
NSString *passcode = [SAMKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&error];

if (error && [error code] != errSecItemNotFound) {
NSLog(@"Error fetching passcode from keychain: %@", [error localizedDescription]);
Expand All @@ -309,9 +309,9 @@ - (BOOL)isPasscodeStored {

- (BOOL)passcodeEnabled {
NSError *error;
NSString *value = [SSKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_ENABLED
error:&error];
NSString *value = [SAMKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_ENABLED
error:&error];

if (error && [error code] != errSecItemNotFound) {
NSLog(@"Error determining if passcode is enabled: %@", error);
Expand All @@ -328,15 +328,15 @@ - (BOOL)passcodeEnabled {

- (void)setPasscodeEnabled:(BOOL)passcodeEnabled {
NSError *error;
BOOL success = [SSKeychain setPassword:[NSString stringWithFormat:@"%@", @(passcodeEnabled)]
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_ENABLED
error:&error];
BOOL success = [SAMKeychain setPassword:[NSString stringWithFormat:@"%@", @(passcodeEnabled)]
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_ENABLED
error:&error];

if (success && !passcodeEnabled) {
success = [SSKeychain deletePasswordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&error];
success = [SAMKeychain deletePasswordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_PASSCODE
error:&error];
}

if (!success || error) {
Expand All @@ -346,9 +346,9 @@ - (void)setPasscodeEnabled:(BOOL)passcodeEnabled {

- (NSTimeInterval)passcodeTimeInterval {
NSError *error;
NSString *value = [SSKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_INTERVAL
error:&error];
NSString *value = [SAMKeychain passwordForService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_INTERVAL
error:&error];

if (error && error.code != errSecItemNotFound) {
NSLog(@"Error determining passcode interval: %@", error);
Expand All @@ -363,10 +363,10 @@ - (NSTimeInterval)passcodeTimeInterval {

- (void)setPasscodeTimeInterval:(NSTimeInterval)passcodeTimeinterval {
NSError *error;
BOOL success = [SSKeychain setPassword:[NSString stringWithFormat:@"%@", @(passcodeTimeinterval)]
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_INTERVAL
error:&error];
BOOL success = [SAMKeychain setPassword:[NSString stringWithFormat:@"%@", @(passcodeTimeinterval)]
forService:DH_PASSCODE_KEYCHAIN_SERVICE_NAME
account:DH_PASSCODE_KEYCHAIN_ACCOUNT_NAME_TIME_INTERVAL
error:&error];

if (!success || error) {
NSLog(@"Error setting passcode time interval: %@", error);
Expand Down
2 changes: 1 addition & 1 deletion Example/DHPasscodeManager/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.donholly.$(PRODUCT_NAME:rfc1034identifier)</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Loading

0 comments on commit 7534327

Please sign in to comment.