Skip to content

Commit

Permalink
Fix compilation error under Xcode 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
kishikawakatsumi committed Sep 26, 2017
1 parent 0e52e52 commit 538b9de
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 68 deletions.
18 changes: 9 additions & 9 deletions Lib/UICKeyChainStore/UICKeyChainStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions Lib/UICKeyChainStore/UICKeyChainStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -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}];
Expand Down
37 changes: 0 additions & 37 deletions Lib/UICKeyChainStoreTests/UICKeyChainStoreTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ @interface UICKeyChainStore (Private)
- (CFTypeRef)protocolTypeObject;
- (CFTypeRef)authenticationTypeObject;
- (CFTypeRef)accessibilityObject;
- (CFOptionFlags)authenticationPolicyObject;

@end

Expand Down Expand Up @@ -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

0 comments on commit 538b9de

Please sign in to comment.