-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update: Add different files for all Keychain classes
- Loading branch information
1 parent
8615d28
commit bdfe239
Showing
8 changed files
with
581 additions
and
435 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
GIGLibrary.xcodeproj/xcshareddata/xcschemes/GIGLibraryApp.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1130" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "FA680F191B009B6B006FC484" | ||
BuildableName = "GIGLibraryApp.app" | ||
BlueprintName = "GIGLibraryApp" | ||
ReferencedContainer = "container:GIGLibrary.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "FA680F191B009B6B006FC484" | ||
BuildableName = "GIGLibraryApp.app" | ||
BlueprintName = "GIGLibraryApp" | ||
ReferencedContainer = "container:GIGLibrary.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "FA680F191B009B6B006FC484" | ||
BuildableName = "GIGLibraryApp.app" | ||
BlueprintName = "GIGLibraryApp" | ||
ReferencedContainer = "container:GIGLibrary.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// | ||
// KeychainAccessibility.swift | ||
// GIGLibrary | ||
// | ||
// Created by Jerilyn Gonçalves on 06/03/2020. | ||
// Copyright © 2020 Gigigo SL. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum KeychainAccessibility { | ||
/** | ||
Item data can only be accessed | ||
while the device is unlocked. This is recommended for items that only | ||
need be accesible while the application is in the foreground. Items | ||
with this attribute will migrate to a new device when using encrypted | ||
backups. | ||
*/ | ||
case whenUnlocked | ||
|
||
/** | ||
Item data can only be | ||
accessed once the device has been unlocked after a restart. This is | ||
recommended for items that need to be accesible by background | ||
applications. Items with this attribute will migrate to a new device | ||
when using encrypted backups. | ||
*/ | ||
case afterFirstUnlock | ||
|
||
/** | ||
Item data can always be accessed | ||
regardless of the lock state of the device. This is not recommended | ||
for anything except system use. Items with this attribute will migrate | ||
to a new device when using encrypted backups. | ||
*/ | ||
case always | ||
|
||
/** | ||
Item data can only | ||
be accessed while the device is unlocked. This is recommended for items | ||
that only need be accesible while the application is in the foreground. | ||
Items with this attribute will never migrate to a new device, so after | ||
a backup is restored to a new device, these items will be missing. | ||
*/ | ||
case whenUnlockedThisDeviceOnly | ||
|
||
/** | ||
Item data can | ||
only be accessed once the device has been unlocked after a restart. | ||
This is recommended for items that need to be accessible by background | ||
applications. Items with this attribute will never migrate to a new | ||
device, so after a backup is restored to a new device these items will | ||
be missing. | ||
*/ | ||
case afterFirstUnlockThisDeviceOnly | ||
|
||
/** | ||
Item data can always | ||
be accessed regardless of the lock state of the device. This option | ||
is not recommended for anything except system use. Items with this | ||
attribute will never migrate to a new device, so after a backup is | ||
restored to a new device, these items will be missing. | ||
*/ | ||
case alwaysThisDeviceOnly | ||
} | ||
|
||
extension KeychainAccessibility: RawRepresentable, CustomStringConvertible { | ||
|
||
public init?(rawValue: String) { | ||
switch rawValue { | ||
case String(kSecAttrAccessibleWhenUnlocked): | ||
self = .whenUnlocked | ||
case String(kSecAttrAccessibleAfterFirstUnlock): | ||
self = .afterFirstUnlock | ||
case String(kSecAttrAccessibleAlways): | ||
self = .always | ||
case String(kSecAttrAccessibleWhenUnlockedThisDeviceOnly): | ||
self = .whenUnlockedThisDeviceOnly | ||
case String(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly): | ||
self = .afterFirstUnlockThisDeviceOnly | ||
case String(kSecAttrAccessibleAlwaysThisDeviceOnly): | ||
self = .alwaysThisDeviceOnly | ||
default: | ||
return nil | ||
} | ||
} | ||
|
||
public var rawValue: String { | ||
switch self { | ||
case .whenUnlocked: | ||
return String(kSecAttrAccessibleWhenUnlocked) | ||
case .afterFirstUnlock: | ||
return String(kSecAttrAccessibleAfterFirstUnlock) | ||
case .always: | ||
return String(kSecAttrAccessibleAlways) | ||
case .whenUnlockedThisDeviceOnly: | ||
return String(kSecAttrAccessibleWhenUnlockedThisDeviceOnly) | ||
case .afterFirstUnlockThisDeviceOnly: | ||
return String(kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly) | ||
case .alwaysThisDeviceOnly: | ||
return String(kSecAttrAccessibleAlwaysThisDeviceOnly) | ||
} | ||
} | ||
|
||
public var description: String { | ||
switch self { | ||
case .whenUnlocked: | ||
return "WhenUnlocked" | ||
case .afterFirstUnlock: | ||
return "AfterFirstUnlock" | ||
case .always: | ||
return "Always" | ||
case .whenUnlockedThisDeviceOnly: | ||
return "WhenUnlockedThisDeviceOnly" | ||
case .afterFirstUnlockThisDeviceOnly: | ||
return "AfterFirstUnlockThisDeviceOnly" | ||
case .alwaysThisDeviceOnly: | ||
return "AlwaysThisDeviceOnly" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// | ||
// KeychainAttributes.swift | ||
// GIGLibrary | ||
// | ||
// Created by Jerilyn Gonçalves on 06/03/2020. | ||
// Copyright © 2020 Gigigo SL. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct Attributes { | ||
|
||
public var `class`: String? { | ||
return self.attributes[KeychainConstants.Class] as? String | ||
} | ||
public var data: Data? { | ||
return self.attributes[KeychainConstants.ValueData] as? Data | ||
} | ||
public var ref: Data? { | ||
return self.attributes[KeychainConstants.ValueRef] as? Data | ||
} | ||
public var persistentRef: Data? { | ||
return self.attributes[KeychainConstants.ValuePersistentRef] as? Data | ||
} | ||
public var accessible: String? { | ||
return self.attributes[KeychainConstants.AttributeAccessible] as? String | ||
} | ||
public var accessGroup: String? { | ||
return self.attributes[KeychainConstants.AttributeAccessGroup] as? String | ||
} | ||
public var synchronizable: Bool? { | ||
return self.attributes[KeychainConstants.AttributeSynchronizable] as? Bool | ||
} | ||
public var creationDate: Date? { | ||
return self.attributes[KeychainConstants.AttributeCreationDate] as? Date | ||
} | ||
public var modificationDate: Date? { | ||
return self.attributes[KeychainConstants.AttributeModificationDate] as? Date | ||
} | ||
public var attributeDescription: String? { | ||
return self.attributes[KeychainConstants.AttributeDescription] as? String | ||
} | ||
public var comment: String? { | ||
return self.attributes[KeychainConstants.AttributeComment] as? String | ||
} | ||
public var creator: String? { | ||
return self.attributes[KeychainConstants.AttributeCreator] as? String | ||
} | ||
public var type: String? { | ||
return self.attributes[KeychainConstants.AttributeType] as? String | ||
} | ||
public var label: String? { | ||
return self.attributes[KeychainConstants.AttributeLabel] as? String | ||
} | ||
public var isInvisible: Bool? { | ||
return self.attributes[KeychainConstants.AttributeIsInvisible] as? Bool | ||
} | ||
public var isNegative: Bool? { | ||
return self.attributes[KeychainConstants.AttributeIsNegative] as? Bool | ||
} | ||
public var account: String? { | ||
return self.attributes[KeychainConstants.AttributeAccount] as? String | ||
} | ||
public var service: String? { | ||
return self.attributes[KeychainConstants.AttributeService] as? String | ||
} | ||
public var generic: Data? { | ||
return self.attributes[KeychainConstants.AttributeGeneric] as? Data | ||
} | ||
|
||
fileprivate let attributes: [String: Any] | ||
|
||
init(attributes: [String: Any]) { | ||
self.attributes = attributes | ||
} | ||
|
||
public subscript(key: String) -> Any? { | ||
get { | ||
return self.attributes[key] | ||
} | ||
} | ||
} | ||
|
||
extension Attributes: CustomStringConvertible, CustomDebugStringConvertible { | ||
|
||
public var description: String { | ||
return "\(self.attributes)" | ||
} | ||
|
||
public var debugDescription: String { | ||
return self.description | ||
} | ||
} |
Oops, something went wrong.