KeychainStoreManager
open class KeychainStoreManager : PersistentStoreManaging
KeychainStoreManager implementation of PersistentStoreManaging
Creates/opens/removes KeychainStorage
instances. The used cipherHandler
provides the Cipher
to used for encryption. When there is no Cipher
then the data won’t be enctypted.
-
To share the
KeychainStore
values this accessGroup should be the same in each applicationDeclaration
Swift
public let accessGroup: String
-
Initializes a new instance of
KeychainStoreManager
Declaration
Swift
public init(keychainAccessGroup: String = "", cipherHandler: @escaping (String?, String) throws -> Ciphering? = KeychainStoreManager.cipher(for:salt:), saltProvider: SaltProviding? = nil)
Parameters
keychainAccessGroup
the keychain access group used to share the data. If
nil
passed the data won’t be shared. Default value isnil
cipherHandler
the close which should provide a
Ciphering
instance which is used for encryption. If returnsnil
the data won’t be encrypted. The defautl value isKeychainStoreManager.cipher(for:)
-
Creates a
KeychainStorage
instance. If passcode is not nil it usesCipher
to encrypt data.Throws
StoreManagerErrorDeclaration
Swift
open func createStore(name: String, passcode: String?) throws -> DataStoring
Parameters
name
name of the store
passcode
passcode used to encrypt the data stored in the store. Passing
nil
means no encryption will be used. In any other case aCipher
instance will be created with its default parametersReturn Value
initialized KeychainStorage instance, can be used to store/retrieve data
-
Tries to open the store with the given passcode
Throws
StoreManagerErrorDeclaration
Swift
open func openStore(name: String, passcode: String?) throws -> DataStoring
Parameters
name
name of the store
passcode
the passcode given by the user
Return Value
opened store
-
Declaration
Swift
open func removeStore(name: String, store: DataStoring?) throws
-
Declaration
Swift
open func changePasscode(store: DataStoring, newPasscode: String?) throws
-
Declaration
Swift
open func storeExists(name: String) throws -> Bool
-
Creates a new instance of
Cipher
class with its default values when thepasscode
parameter is notnil
(even if it is empty string). Returnsnil
if the passcode isnil
.Declaration
Swift
public class func cipher(for passcode: String?, salt: String) throws -> Ciphering?
Parameters
passcode
the passcode to used to create
Cipher
Return Value
new
Cipher
instance or nil