From 538b9de50e738c054b8c58b655ce9e8b3f2f7934 Mon Sep 17 00:00:00 2001 From: Kishikawa Katsumi Date: Tue, 26 Sep 2017 03:13:57 +0900 Subject: [PATCH] Fix compilation error under Xcode 8.x --- Lib/UICKeyChainStore/UICKeyChainStore.h | 18 ++++----- Lib/UICKeyChainStore/UICKeyChainStore.m | 22 ----------- .../UICKeyChainStoreTests.m | 37 ------------------- 3 files changed, 9 insertions(+), 68 deletions(-) diff --git a/Lib/UICKeyChainStore/UICKeyChainStore.h b/Lib/UICKeyChainStore/UICKeyChainStore.h index 2f1d78a..6737318 100644 --- a/Lib/UICKeyChainStore/UICKeyChainStore.h +++ b/Lib/UICKeyChainStore/UICKeyChainStore.h @@ -96,15 +96,15 @@ typedef NS_ENUM(NSInteger, UICKeyChainStoreAccessibility) { } __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_4_0); -typedef NS_ENUM(NSInteger, UICKeyChainStoreAuthenticationPolicy) { - UICKeyChainStoreAuthenticationPolicyUserPresence = 1 << 0, - UICKeyChainStoreAuthenticationPolicyTouchIDAny __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_9_0) = 1u << 1, - UICKeyChainStoreAuthenticationPolicyTouchIDCurrentSet __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_9_0) = 1u << 3, - UICKeyChainStoreAuthenticationPolicyDevicePasscode __OSX_AVAILABLE_STARTING(__MAC_10_11, __IPHONE_9_0) = 1u << 4, - UICKeyChainStoreAuthenticationPolicyControlOr __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_9_0) = 1u << 14, - UICKeyChainStoreAuthenticationPolicyControlAnd __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_9_0) = 1u << 15, - UICKeyChainStoreAuthenticationPolicyPrivateKeyUsage __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_9_0) = 1u << 30, - UICKeyChainStoreAuthenticationPolicyApplicationPassword __OSX_AVAILABLE_STARTING(__MAC_10_12_1, __IPHONE_9_0) = 1u << 31, +typedef NS_ENUM(unsigned long, UICKeyChainStoreAuthenticationPolicy) { + UICKeyChainStoreAuthenticationPolicyUserPresence = 1 << 0, + UICKeyChainStoreAuthenticationPolicyTouchIDAny NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 1, + UICKeyChainStoreAuthenticationPolicyTouchIDCurrentSet NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 3, + UICKeyChainStoreAuthenticationPolicyDevicePasscode NS_ENUM_AVAILABLE(10_11, 9_0) = 1u << 4, + UICKeyChainStoreAuthenticationPolicyControlOr NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 14, + UICKeyChainStoreAuthenticationPolicyControlAnd NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 15, + UICKeyChainStoreAuthenticationPolicyPrivateKeyUsage NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 30, + UICKeyChainStoreAuthenticationPolicyApplicationPassword NS_ENUM_AVAILABLE(10_12_1, 9_0) = 1u << 31, }__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); @interface UICKeyChainStore : NSObject diff --git a/Lib/UICKeyChainStore/UICKeyChainStore.m b/Lib/UICKeyChainStore/UICKeyChainStore.m index 793ff04..ace499b 100644 --- a/Lib/UICKeyChainStore/UICKeyChainStore.m +++ b/Lib/UICKeyChainStore/UICKeyChainStore.m @@ -1339,28 +1339,6 @@ - (CFTypeRef)accessibilityObject } } -- (CFOptionFlags)authenticationPolicyObject -{ - switch (_authenticationPolicy) { - case UICKeyChainStoreAuthenticationPolicyUserPresence: - return kSecAccessControlUserPresence; - case UICKeyChainStoreAuthenticationPolicyTouchIDAny: - return kSecAccessControlTouchIDAny; - case UICKeyChainStoreAuthenticationPolicyTouchIDCurrentSet: - return kSecAccessControlTouchIDCurrentSet; - case UICKeyChainStoreAuthenticationPolicyDevicePasscode: - return kSecAccessControlDevicePasscode; - case UICKeyChainStoreAuthenticationPolicyControlOr: - return kSecAccessControlOr; - case UICKeyChainStoreAuthenticationPolicyControlAnd: - return kSecAccessControlAnd; - case UICKeyChainStoreAuthenticationPolicyPrivateKeyUsage: - return kSecAccessControlPrivateKeyUsage; - default: - return 0; - } -} - + (NSError *)argumentError:(NSString *)message { NSError *error = [NSError errorWithDomain:UICKeyChainStoreErrorDomain code:UICKeyChainStoreErrorInvalidArguments userInfo:@{NSLocalizedDescriptionKey: message}]; diff --git a/Lib/UICKeyChainStoreTests/UICKeyChainStoreTests.m b/Lib/UICKeyChainStoreTests/UICKeyChainStoreTests.m index 2576634..aed55d9 100644 --- a/Lib/UICKeyChainStoreTests/UICKeyChainStoreTests.m +++ b/Lib/UICKeyChainStoreTests/UICKeyChainStoreTests.m @@ -14,7 +14,6 @@ @interface UICKeyChainStore (Private) - (CFTypeRef)protocolTypeObject; - (CFTypeRef)authenticationTypeObject; - (CFTypeRef)accessibilityObject; -- (CFOptionFlags)authenticationPolicyObject; @end @@ -1611,40 +1610,4 @@ - (void)testAccessibilityPrivateMethod XCTAssertEqualObjects([keychain accessibilityObject], (__bridge id)kSecAttrAccessibleAlwaysThisDeviceOnly); } -- (void)testAuthenticationPolicy -{ - UICKeyChainStore *keychain; - - keychain = [UICKeyChainStore keyChainStoreWithService:@"Twitter"]; - - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyUserPresence]; - XCTAssertEqual([keychain authenticationPolicyObject], kSecAccessControlUserPresence); - - #endif - - #if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0 - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyTouchIDAny]; - XCTAssertEqual([keychain authenticationPolicyObject], kSecAccessControlTouchIDAny); - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyTouchIDCurrentSet]; - XCTAssertEqual([keychain authenticationPolicyObject], kSecAccessControlTouchIDCurrentSet); - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyDevicePasscode]; - XCTAssertEqual([keychain authenticationPolicyObject],kSecAccessControlDevicePasscode); - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyControlAnd]; - XCTAssertEqual([keychain authenticationPolicyObject],kSecAccessControlAnd); - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyControlOr]; - XCTAssertEqual([keychain authenticationPolicyObject],kSecAccessControlOr); - - [keychain setAccessibility:UICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly authenticationPolicy:UICKeyChainStoreAuthenticationPolicyPrivateKeyUsage]; - XCTAssertEqual([keychain authenticationPolicyObject],kSecAccessControlPrivateKeyUsage); - - #endif -} - @end