}
}
+void
+NotePairs::replaceOrAddOrAppend(const NotePairs *src, const NotePairs::Names &appendables)
+{
+ for (const auto e: src->entries) {
+ if (std::find(appendables.begin(), appendables.end(), e->name()) == appendables.end())
+ remove(e->name());
+ }
+ append(src);
+}
+
void
NotePairs::replaceOrAdd(const NotePairs *src)
{
SBuf theValue;
};
typedef std::vector<Entry::Pointer> Entries; ///< The key/value pair entries
+ typedef std::vector<SBuf> Names;
NotePairs() {}
NotePairs &operator=(NotePairs const &) = delete;
/// Append the entries of the src NotePairs list to our list.
void append(const NotePairs *src);
+ /// Replace existing list entries with the src NotePairs entries.
+ /// Do not replace but append entries named in the appendables
+ /// Entries which do not exist in the destination set are added.
+ void replaceOrAddOrAppend(const NotePairs *src, const Names &appendables);
+
/// Replace existing list entries with the src NotePairs entries.
/// Entries which do not exist in the destination set are added.
void replaceOrAdd(const NotePairs *src);
// add new helper kv-pair notes to the credentials object
// so that any transaction using those credentials can access them
- r->auth_user_request->user()->notes.appendNewOnly(&reply.notes);
+ static const NotePairs::Names appendables = { SBuf("group"), SBuf("tag") };
+ r->auth_user_request->user()->notes.replaceOrAddOrAppend(&reply.notes, appendables);
/* this is okay since we only play with the Auth::Basic::User child fields below
* and do not pass the pointer itself anywhere */
// add new helper kv-pair notes to the credentials object
// so that any transaction using those credentials can access them
- auth_user_request->user()->notes.appendNewOnly(&reply.notes);
+ static const NotePairs::Names appendables = { SBuf("group"), SBuf("nonce"), SBuf("tag") };
+ auth_user_request->user()->notes.replaceOrAddOrAppend(&reply.notes, appendables);
// remove any private credentials detail which got added.
auth_user_request->user()->notes.remove("ha1");
// add new helper kv-pair notes to the credentials object
// so that any transaction using those credentials can access them
- auth_user_request->user()->notes.appendNewOnly(&reply.notes);
+ static const NotePairs::Names appendables = { SBuf("group"), SBuf("tag") };
+ auth_user_request->user()->notes.replaceOrAddOrAppend(&reply.notes, appendables);
// remove any private credentials detail which got added.
auth_user_request->user()->notes.remove("token");
// add new helper kv-pair notes to the credentials object
// so that any transaction using those credentials can access them
- auth_user_request->user()->notes.appendNewOnly(&reply.notes);
+ static const NotePairs::Names appendables = { SBuf("group"), SBuf("tag") };
+ auth_user_request->user()->notes.replaceOrAddOrAppend(&reply.notes, appendables);
// remove any private credentials detail which got added.
auth_user_request->user()->notes.remove("token");