Skip to content

Commit

Permalink
Add Factory implementation for KeychainSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
russhwolf committed May 23, 2022
1 parent 7d5f467 commit 2e1558f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- BREAKING: Remove default values for defaultValue parameters
- Remove `@ExperimentalSettingsApi` from `ObservableSettings`, `SettingsListener`, and related APIs
- Remove `@ExperimentalSettingsImplementation` from JVM implementations
- Add `Factory` implementation for `KeychainSettings`

## v0.9 *(2022-05-01)* ##

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ public class KeychainSettings(vararg defaultProperties: Pair<CFStringRef?, CFTyp

private val defaultProperties = mapOf(kSecClass to kSecClassGenericPassword) + mapOf(*defaultProperties)

/**
* A factory that can produce [Settings] instances.
*
* This class can only be instantiated via a platform-specific constructor. It's purpose is so that `Settings`
* objects can be created in common code, so that the only platform-specific behavior necessary in order to use
* multiple `Settings` objects is the one-time creation of a single `Factory`.
*
* This class creates `Settings` objects backed by the Apple keychain.
*/
public class Factory : Settings.Factory {
override fun create(name: String?): Settings =
if (name != null) KeychainSettings(name) else KeychainSettings()
}

public override val keys: Set<String>
get() = memScoped {
val attributes = alloc<CFArrayRefVar>()
Expand Down

0 comments on commit 2e1558f

Please sign in to comment.