-
Notifications
You must be signed in to change notification settings - Fork 2
Pop expanded #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
boek
wants to merge
9
commits into
pop
Choose a base branch
from
pop_expanded
base: pop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Pop expanded #1
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0fd3012
Poppy
boek 22faff8
fix indentation
boek 5c5688c
Migrator
boek 473cca2
Merged Pop into pop_expanded
boek 52e7090
Keychain sadness
boek 267d9da
Added comments
boek 4592049
Secure Storage
boek 4db8a9f
Added docstrings, renamed SecureDataStore to KeychainDataStore
boek bf6aeb8
typo
boek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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,36 @@ | ||
| // | ||
| // SecureDataStore.swift | ||
| // Protocol-Oriented | ||
| // | ||
| // Created by Jeff Boek on 7/4/15. | ||
| // Copyright © 2015 pdx-ios.org. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| /// Keychain Store | ||
| final class KeychainDataStore: SecureStorageType { | ||
|
|
||
| private var keychain = Keychain(service: "org.pdx-ios") | ||
|
|
||
| /// Fetch an object from the keychain | ||
| func fetchObjectForKey<T : Storable>(key: String) -> T? { | ||
| guard let data = keychain.getData(key) else { return nil } | ||
| guard let object: AnyObject = NSKeyedUnarchiver.unarchiveObjectWithData(data) else { return nil } | ||
|
|
||
| return object as? T | ||
| } | ||
|
|
||
| /// Remove an object from the keychain | ||
| func removeObjectForKey(key: String) { | ||
| keychain.remove(key) | ||
| } | ||
|
|
||
| /// Store an object in the keychain | ||
| func storeObject<T : Storable>(object: T, forKey key: String) { | ||
| guard let object: AnyObject = object as? AnyObject else { return } | ||
| let data = NSKeyedArchiver.archivedDataWithRootObject(object) | ||
|
|
||
| keychain.set(data, key: key) | ||
| } | ||
| } |
This file contains hidden or 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,24 @@ | ||
| // | ||
| // DataStore.swift | ||
| // Protocol-Oriented | ||
| // | ||
| // Created by Ryan Arana on 7/3/15. | ||
| // Copyright © 2015 pdx-ios.org. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension NSUserDefaults: StorageType { | ||
|
|
||
| /// Fetch an object from the Store | ||
| func fetchObjectForKey<T : Storable>(key: String) -> T? { | ||
| return objectForKey(key) as? T | ||
| } | ||
|
|
||
| // NSUserDefaults already implements removeObjectForKey: | ||
|
|
||
| /// Store object | ||
| func storeObject<T : Storable>(object: T, forKey key: String) { | ||
| setObject((object as? AnyObject), forKey: key) | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,40 @@ | ||
| // | ||
| // UnsecureToSecureDataStore.swift | ||
| // Protocol-Oriented | ||
| // | ||
| // Created by Jeff Boek on 7/6/15. | ||
| // Copyright © 2015 pdx-ios.org. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| final class UnsecureToSecureDataStore: StorageType { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to have a docstring describing this class |
||
|
|
||
| private let secureStorage: SecureStorageType | ||
| private let unsecureStorage: StorageType | ||
|
|
||
| init(unsecureStorage: StorageType, secureStorage: SecureStorageType) { | ||
| self.secureStorage = secureStorage | ||
| self.unsecureStorage = unsecureStorage | ||
| } | ||
|
|
||
| func fetchObjectForKey<T : Storable>(key: String) -> T? { | ||
| return secureStorage.fetchObjectForKey(key) ?? migrateKey(key) | ||
| } | ||
|
|
||
| func removeObjectForKey(key: String) { | ||
| secureStorage.removeObjectForKey(key) | ||
| unsecureStorage.removeObjectForKey(key) | ||
| } | ||
|
|
||
| func storeObject<T : Storable>(object: T, forKey key: String) { | ||
| secureStorage.storeObject(object, forKey: key) | ||
| } | ||
|
|
||
| private func migrateKey<T: Storable>(key: String) -> T? { | ||
| guard let object: T = unsecureStorage.fetchObjectForKey(key) else { return nil } | ||
| secureStorage.storeObject(object, forKey: key) | ||
|
|
||
| return object | ||
| } | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz to keep all my doc strings!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstrings are 3
/sThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the docstring for the protocol got lost