KeyLocator Class

The KeyLocator class represents an NDN KeyLocator which is used in a Sha256WithRsaSignature and Interest selectors.

[C++]:
#include <ndn-cpp/key-locator.hpp>
Namespace: ndn
[Python]:Module: pyndn
[Java]:Package: net.named_data.jndn

KeyLocator Constructors

KeyLocator Constructor (default)

Create a new KeyLocator with an unspecified type.

[C++]:
KeyLocator();
[Python]:
def __init__(self)
[JavaScript]:
var KeyLocator = function KeyLocator()
[Java]:
public KeyLocator()

KeyLocator Constructor (copy)

Create a new KeyLocator as a deep copy of the given key locator.

[C++]:
KeyLocator(
    const KeyLocator& keyLocator
);
[Python]:
def __init__(self,
    keyLocator  # KeyLocator
)
[JavaScript]:
var KeyLocator = function KeyLocator(
    keyLocator  // KeyLocator
)
[Java]:
public KeyLocator(
    KeyLocator keyLocator
)
Parameters:
  • keyLocator
    The KeyLocator to copy.

KeyLocator Get Methods

KeyLocator.getKeyData Method

Get the key data. This is the digest bytes if getType() is KEY_LOCATOR_DIGEST.

[C++]:
const Blob& getKeyData() const;
[Python]:
# Returns Blob
def getKeyData(self)
[JavaScript]:
// Returns Blob
KeyLocator.prototype.getKeyData = function()
[Java]:
public final Blob getKeyData()
Returns:

The key data as a Blob (only valid if getType() is KEY_LOCATOR_DIGEST).

KeyLocator.getKeyName Method

Get the key name (only valid if getType() is KEYNAME).

[C++]:
const Name& getKeyName() const;

Name& getKeyName();
[Python]:
# Returns Name
def getKeyName(self)
[JavaScript]:
// Returns Name
KeyLocator.prototype.getKeyName = function()
[Java]:
public final Name getKeyName()
Returns:

The key name (only valid if getType() is KEYNAME).

KeyLocator.getType Method

Get the key locator type. For KEYNAME, you may also call getKeyName(). For KEY_LOCATOR_DIGEST, you may also call getKeyData() to get the digest.

[C++]:
ndn_KeyLocatorType getType() const;
[Python]:
# Returns int
def getType(self)
[JavaScript]:
// Returns number
KeyLocator.prototype.getType = function()
[Java]:
public final KeyLocatorType getType()
Returns:

The key locator type which is KEYNAME or KEY_LOCATOR_DIGEST as follows:

  • C++: ndn_KeyLocatorType_KEYNAME or ndn_KeyLocatorType_KEY_LOCATOR_DIGEST
  • Python: KeyLocatorType.KEYNAME or KeyLocatorType.KEY_LOCATOR_DIGEST
  • JavaScript: KeyLocatorType.KEYNAME or KeyLocatorType.KEY_LOCATOR_DIGEST
  • Java: KeyLocatorType.KEYNAME or KeyLocatorType.KEY_LOCATOR_DIGEST

If not specified, return -1 (C++) or KeyLocatorType.NONE (Java) or None (Python) or undefined (JavaScript).

KeyLocator Set Methods

KeyLocator.setKeyData Method

Set the key data to the given value. This is the digest bytes if getType() is KEY_LOCATOR_DIGEST.

[C++]:
void setKeyData(
    const Blob& keyData
);
[Python]:
def setKeyData(self,
    keyData  # Blob
)
[JavaScript]:
Data.prototype.setKeyData = function(
    keyData  // Blob
)
[Java]:
public final void setKeyData(
    Blob keyData
)
Parameters:
  • keyData
    A Blob with the key data bytes.

KeyLocator.setKeyName Method

Set the key name to a copy of the given Name. This is the name if getType() is KEYNAME.

Note

You can also call getKeyName and change the name values directly.

[C++]:
void setKeyName(
    const Name& name
);
[Python]:
def setKeyName(self,
    name  # Name
)
[JavaScript]:
KeyLocator.prototype.setKeyName = function(
    name  // Name
)
[Java]:
public final void setKeyName(
    Name name
)
Parameters:
  • name
    The key name. This makes a copy of the name.

KeyLocator.setType Method

Set the key locator type. If the type is KEYNAME, you must also call setKeyName(). If the type is KEY_LOCATOR_DIGEST, you must also call setKeyData() to set the digest.

[C++]:
void setType(
    ndn_KeyLocatorType type
);
[Python]:
def setType(self,
    type  # int
)
[JavaScript]:
KeyLocator.prototype.setType = function(
    type  // number
)
[Java]:
public final void setType(
    KeyLocatorType type
)
Parameters:
  • type

    The key locator type which is KEYNAME or KEY_LOCATOR_DIGEST as follows:

    • C++: ndn_KeyLocatorType_KEYNAME or ndn_KeyLocatorType_KEY_LOCATOR_DIGEST
    • Python: KeyLocatorType.KEYNAME or KeyLocatorType.KEY_LOCATOR_DIGEST
    • JavaScript: KeyLocatorType.KEYNAME or KeyLocatorType.KEY_LOCATOR_DIGEST
    • Java: KeyLocatorType.KEYNAME or KeyLocatorType.KEY_LOCATOR_DIGEST

    If not specified, set to -1 (C++) or KeyLocatorType.NONE (Java) or None (Python) or undefined (JavaScript).

KeyLocator.clear Method

Clear the keyData and keyName, and set the type to unspecified.

[C++]:
void clear();
[Python]:
def clear(self)
[JavaScript]:
KeyLocator.prototype.clear = function()
[Java]:
public final void clear()