Add an exact search method to the Keychain adapter, and modify unit tests to...

Add an exact search method to the Keychain adapter, and modify unit tests to us that instead of the raw keychain version.
Overhaul the single-item-search test to be shorter, clearer, and more complete.
Convert more namespaced methods that now have no public callers to private helpers of the Keychain adapter, and refactor the helpers.

BUG=none
TEST=none; no behavioral changes
Review URL: http://codereview.chromium.org/149160

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19964 0039d316-1c4b-4281-b951-d872f2087c98
parent ce500831
...@@ -22,11 +22,18 @@ class MacKeychainPasswordFormAdapter { ...@@ -22,11 +22,18 @@ class MacKeychainPasswordFormAdapter {
// created object. // created object.
explicit MacKeychainPasswordFormAdapter(MacKeychain* keychain); explicit MacKeychainPasswordFormAdapter(MacKeychain* keychain);
// Returns PasswordForms for each keychain entry matching |form|. // Returns PasswordForms for each keychain entry that could be used to fill
// Caller is responsible for deleting the returned forms. // |form|. Caller is responsible for deleting the returned forms.
std::vector<webkit_glue::PasswordForm*> PasswordsMatchingForm( std::vector<webkit_glue::PasswordForm*> PasswordsMatchingForm(
const webkit_glue::PasswordForm& query_form); const webkit_glue::PasswordForm& query_form);
// Returns the PasswordForm for the Keychain entry that matches |form| on all
// of the fields that uniquely identify a Keychain item, or NULL if there is
// no such entry.
// Caller is responsible for deleting the returned form.
webkit_glue::PasswordForm* PasswordExactlyMatchingForm(
const webkit_glue::PasswordForm& query_form);
// Creates a new keychain entry from |form|, or updates the password of an // Creates a new keychain entry from |form|, or updates the password of an
// existing keychain entry if there is a collision. Returns true if a keychain // existing keychain entry if there is a collision. Returns true if a keychain
// entry was successfully added/updated. // entry was successfully added/updated.
...@@ -38,11 +45,38 @@ class MacKeychainPasswordFormAdapter { ...@@ -38,11 +45,38 @@ class MacKeychainPasswordFormAdapter {
std::vector<webkit_glue::PasswordForm*> CreateFormsFromKeychainItems( std::vector<webkit_glue::PasswordForm*> CreateFormsFromKeychainItems(
const std::vector<SecKeychainItemRef>& items); const std::vector<SecKeychainItemRef>& items);
// Searches |keychain| for all items usable for the given signon_realm, and // Searches |keychain| for all items usable for the given form, and returns
// puts them in |items|. The caller is responsible for calling keychain->Free // them. The caller is responsible for calling MacKeychain::Free on the
// on each of them when it is finished with them. // returned items.
std::vector<SecKeychainItemRef> KeychainItemsForFillingForm(
const webkit_glue::PasswordForm& form);
// Searches |keychain| for the specific keychain entry that corresponds to the
// given form, and returns it (or NULL if no match is found). The caller is
// responsible for calling MacKeychain::Free on on the returned item.
SecKeychainItemRef KeychainItemForForm(
const webkit_glue::PasswordForm& form);
// Returns the Keychain items matching the given signon_realm, scheme, and
// optionally path and username (either of both can be NULL).
// them. The caller is responsible for calling MacKeychain::Free on the
// returned items.
std::vector<SecKeychainItemRef> MatchingKeychainItems( std::vector<SecKeychainItemRef> MatchingKeychainItems(
const std::string& signon_realm, const std::string& signon_realm, webkit_glue::PasswordForm::Scheme scheme,
const char* path, const char* username);
// Takes a PasswordForm's signon_realm and parses it into its component parts,
// which are returned though the appropriate out parameters.
// Returns true if it can be successfully parsed, in which case all out params
// that are non-NULL will be set. If there is no port, port will be 0.
// If the return value is false, the state of the out params is undefined.
bool ExtractSignonRealmComponents(const std::string& signon_realm,
std::string* server, int* port,
bool* is_secure,
std::string* security_domain);
// Returns the Keychain SecAuthenticationType type corresponding to |scheme|.
SecAuthenticationType AuthTypeForScheme(
webkit_glue::PasswordForm::Scheme scheme); webkit_glue::PasswordForm::Scheme scheme);
// Changes the password for keychain_item to |password|; returns true if the // Changes the password for keychain_item to |password|; returns true if the
...@@ -62,12 +96,6 @@ class MacKeychainPasswordFormAdapter { ...@@ -62,12 +96,6 @@ class MacKeychainPasswordFormAdapter {
namespace internal_keychain_helpers { namespace internal_keychain_helpers {
// Searches |keychain| for the specific keychain entry matching the given form,
// and returns it (or NULL if no match is found).
// The caller is responsible for calling keychain->Free on the returned item.
SecKeychainItemRef MatchingKeychainItem(const MacKeychain& keychain,
const webkit_glue::PasswordForm& form);
// Sets the fields of |form| based on the keychain data from |keychain_item|. // Sets the fields of |form| based on the keychain data from |keychain_item|.
// Fields that can't be determined from |keychain_item| will be unchanged. // Fields that can't be determined from |keychain_item| will be unchanged.
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment