Project

General

Profile

Actions

Task #2932

closed

Face: simplify prefix registration APIs with SigningInfo

Added by Junxiao Shi over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Base
Target version:
Start date:
07/02/2015
Due date:
% Done:

0%

Estimated time:
1.50 h

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.


Related issues 3 (1 open2 closed)

Blocked by ndn-cxx - Task #2893: Simplify CommandOptions with SigningInfoClosedJunxiao Shi

Actions
Blocks ndn-cxx - Task #2221: Face: unit test coverage for specifying signing identity/certificate in prefix registrationNew

Actions
Blocks ndn-cxx - Task #2967: Face: deprecate non-SigningInfo prefix registration methodsClosedTeng Liang

Actions
Actions #1

Updated by Junxiao Shi over 9 years ago

  • Blocked by Task #2893: Simplify CommandOptions with SigningInfo added
Actions #2

Updated by Junxiao Shi over 9 years ago

  • Blocks Task #2221: Face: unit test coverage for specifying signing identity/certificate in prefix registration added
Actions #3

Updated by Junxiao Shi over 9 years ago

  • Blocks Task #2967: Face: deprecate non-SigningInfo prefix registration methods added
Actions #4

Updated by Joao Pereira over 9 years ago

For this Issue we need to

  1. 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);
    
  2. 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);
    
  3. Add UT for the new functions

And this is it, right?

Actions #5

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:

  1. To maintain backward compatibility the new functions will not have default. Eventually we can add default when we remove the old functions
  2. Break backward compatibility and remove the default value of the old functions
  3. 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
Actions #6

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
Actions #7

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.

Actions #8

Updated by Joao Pereira over 9 years ago

http://gerrit.named-data.net/2195

Changes:

  1. Added the deprecated tag to the functions that should be deprecated
  2. Added the new functions requested
  3. Did not add UT because the UT present already tested the functions that I created because they used the default parameters
Actions #9

Updated by Joao Pereira over 9 years ago

  • Status changed from In Progress to Code review
Actions #10

Updated by Junxiao Shi over 9 years ago

  • Status changed from Code review to Feedback

To facilitate the eventual removal of deprecated functions, please:

  1. wrap deprecated items and their test cases in #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING, and define this token at the top of face.hpp
  2. ensure sufficient test coverage is obtained without relying on the test cases inside #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING
  3. upload a patchset with the #define NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING commented out
  4. use ndn-cxx-breaks or other tool to check all other projects
  5. upload patchsets to fix broken projects
  6. 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
Actions #12

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?

Actions #13

Updated by Junxiao Shi over 9 years ago

Reply to note-12:

This is irrelevant to this issue. Please discuss on #2922.

Actions #14

Updated by Joao Pereira over 9 years ago

patch set 5 is the one with the uncommented define line

Actions #15

Updated by Junxiao Shi over 9 years ago

  • Status changed from Feedback to Closed
Actions

Also available in: Atom PDF