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 application

    Declaration

    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 is nil

    cipherHandler

    the close which should provide a Ciphering instance which is used for encryption. If returns nil the data won’t be encrypted. The defautl value is KeychainStoreManager.cipher(for:)

  • Creates a KeychainStorage instance. If passcode is not nil it uses Cipher to encrypt data.

    Throws

    StoreManagerError

    Declaration

    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 a Cipher instance will be created with its default parameters

    Return Value

    initialized KeychainStorage instance, can be used to store/retrieve data

  • Tries to open the store with the given passcode

    Throws

    StoreManagerError

    Declaration

    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 the passcode parameter is not nil (even if it is empty string). Returns nil if the passcode is nil.

    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