Task #2932
closedFace: simplify prefix registration APIs with SigningInfo
0%
Description
Replace Face::registerPrefix
and Face::setInterestFilter
overloads that look like
method(.., const Name& identityName)
method(.., const IdentityCertificate& certificate = IdentityCertificate())
with an overload that looks like
method(.., const security::SigningInfo& signingInfo = security::SigningInfo())
Old APIs shall be marked as \deprecated
, and implemented as a call into the new overload.
Updated by Junxiao Shi over 9 years ago
- Blocked by Task #2893: Simplify CommandOptions with SigningInfo added
Updated by Junxiao Shi over 9 years ago
- Blocks Task #2221: Face: unit test coverage for specifying signing identity/certificate in prefix registration added
Updated by Junxiao Shi over 9 years ago
- Blocks Task #2967: Face: deprecate non-SigningInfo prefix registration methods added
Updated by Joao Pereira over 9 years ago
For this Issue we need to
Add tag deprecated to the functions:
const RegisteredPrefixId* Face::registerPrefix(const Name& prefix, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, const IdentityCertificate& certificate = IdentityCertificate(), uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::registerPrefix(const Name& prefix, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, const Name& identity, uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::setInterestFilter(const InterestFilter& interestFilter, const OnInterest& onInterest, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, const IdentityCertificate& certificate = IdentityCertificate(), uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::setInterestFilter(const InterestFilter& interestFilter, const OnInterest& onInterest, const RegisterPrefixFailureCallback& onFailure, const IdentityCertificate& certificate = IdentityCertificate(), uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::setInterestFilter(const InterestFilter& interestFilter, const OnInterest& onInterest, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, const Name& identity, uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::setInterestFilter(const InterestFilter& interestFilter, const OnInterest& onInterest, const RegisterPrefixFailureCallback& onFailure, const Name& identity, uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
Create the following functions
const RegisteredPrefixId* Face::registerPrefix(const Name& prefix, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, const security::SigningInfo& signingInfo = security::SigningInfo(),, uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::setInterestFilter(const InterestFilter& interestFilter, const OnInterest& onInterest, const RegisterPrefixSuccessCallback& onSuccess, const RegisterPrefixFailureCallback& onFailure, const security::SigningInfo& signingInfo = security::SigningInfo(), uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); const RegisteredPrefixId* Face::setInterestFilter(const InterestFilter& interestFilter, const OnInterest& onInterest, const RegisterPrefixFailureCallback& onFailure, const security::SigningInfo& signingInfo = security::SigningInfo(), uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
Add UT for the new functions
And this is it, right?
Updated by Joao Pereira over 9 years ago
Hmm this cannot be done like this. Because we will be with 2 functions with the same interface.
const RegisteredPrefixId*
setInterestFilter(const InterestFilter& interestFilter,
const OnInterest& onInterest,
const RegisterPrefixSuccessCallback& onSuccess,
const RegisterPrefixFailureCallback& onFailure,
const IdentityCertificate& certificate = IdentityCertificate(),
uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
const RegisteredPrefixId*
setInterestFilter(const InterestFilter& interestFilter,
const OnInterest& onInterest,
const RegisterPrefixSuccessCallback& onSuccess,
const RegisterPrefixFailureCallback& onFailure,
const security::SigningInfo& signingInfo = security::SigningInfo(),
uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT);
One or the other need to stop having the default parameter.
I can see some options here:
- To maintain backward compatibility the new functions will not have default. Eventually we can add default when we remove the old functions
- Break backward compatibility and remove the default value of the old functions
- Keep default in both, but change every place in the code where we call these functions using the default to start using the SigningInfo constructor as parameter
Updated by Junxiao Shi over 9 years ago
I neither confirm nor deny note-4. Please refer to issue description.
Reply to note-5: it's fine to remove the default of certificate
on old API.
- old method:
method(someArgs, const IdentityCertificate& certificate = IdentityCertificate(), moreArgs = moreDefaults)
- change to:
method(someArgs, const IdentityCertificate& certificate, moreArgs = moreDefaults)
- new method:
method(someArgs, const SigningInfo& signingInfo = SigningInfo(), moreArgs = moreDefaults)
This shouldn't break anything.
A default-constructed IdentityCertificate
is an invalid certificate.
Its semantics, when used in registerPrefix
or setInterestFilter
, is signing with the default identity and certificate.
There are three ways to call the method:
object.method(someArgs)
- previously, this calls old method, and specifies signing with the default identity and certificate
- after the change, this calls new method, and specifies signing with the default identity and certificate
- there's no semantic change
object.method(someArgs, IdentityCertificate())
- previously, this calls old method
- after the change, this still calls old method
object.method(someArgs, IdentityCertificate(), moreArgs)
- previously, this calls old method
- after the change, this still calls old method
Updated by Joao Pereira over 9 years ago
- Status changed from New to In Progress
- Assignee set to Joao Pereira
- Start date set to 07/02/2015
Ok I am going to implement it as per suggestion in note-6.
Updated by Joao Pereira over 9 years ago
http://gerrit.named-data.net/2195
Changes:
- Added the deprecated tag to the functions that should be deprecated
- Added the new functions requested
- Did not add UT because the UT present already tested the functions that I created because they used the default parameters
Updated by Joao Pereira over 9 years ago
- Status changed from In Progress to Code review
Updated by Junxiao Shi over 9 years ago
- Status changed from Code review to Feedback
To facilitate the eventual removal of deprecated functions, please:
- wrap deprecated items and their test cases in
#ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
, and define this token at the top offace.hpp
- ensure sufficient test coverage is obtained without relying on the test cases inside
#ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
- upload a patchset with the
#define NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
commented out - use ndn-cxx-breaks or other tool to check all other projects
- upload patchsets to fix broken projects
- upload another patchset (under the same Change-Id) with
#define NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
uncommented, which would be merged into ndn-cxx repository
Updated by Joao Pereira over 9 years ago
Path for NLSR http://gerrit.named-data.net/2206
Updated by Joao Pereira over 9 years ago
Answering to note in gerrit saying "use a signing-helper"
Looking into the functions of the signing-helper the interface is pretty strange. Why do they all receive a Name? The functions structure doesn't look good. The functions should be overloads and receive different things.
Instead of :
SigningInfo
signingByIdentity(const Name& identity);
SigningInfo
signingByKey(const Name& keyName);
SigningInfo
signingByCertificate(const Name& certName);
Maybe we should have:
SigningInfo
signingBy(const Name& identity);
SigningInfo
signingBy(const KeyChain& key);
SigningInfo
signingBy(const IdentityCertificate& certificate);
Because with the functions as they are now what do we win by using them? Abstraction of an enum?
Updated by Junxiao Shi over 9 years ago
Reply to note-12:
This is irrelevant to this issue. Please discuss on #2922.
Updated by Joao Pereira over 9 years ago
patch set 5 is the one with the uncommented define line