Class SignedMessage
java.lang.Object
org.drasyl.peer.connection.message.SignedMessage
Represents a container with a signature for the
The
payload
. The signature
must be
valid under the supplied public key
.
The
signature
does not give any guarantees about the logical integrity of the payload
, but only guarantees that the payload
was sent by the identity with the public key
(as the last node in a relay chain).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected short
protected final MessageId
protected final int
protected final ProofOfWork
protected final CompressedPublicKey
protected final CompressedPublicKey
protected final String
-
Constructor Summary
ConstructorsConstructorDescriptionSignedMessage
(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, Message payload) -
Method Summary
Modifier and TypeMethodDescriptionboolean
short
Returns this message's hop count.getId()
Returns the unique id of this message.int
Returns the network the sender belongs to.Returns this message sender's proof of work.Returns this message's recipient.Returns this message's sender.Returns the signature this signable object was signed with.Returns the user agent of the sender's node.int
hashCode()
void
Increases the message's hop count.void
setSignature
(Signature signature) Signs the object with the specified signature.toString()
void
writeFieldsTo
(OutputStream outstream) Write any content into the passed output-stream to have them included in the signing process.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.drasyl.crypto.Signable
getSignableBytes
-
Field Details
-
defaultUserAgentGenerator
-
userAgentGenerator
-
id
-
userAgent
-
networkId
protected final int networkId -
sender
-
proofOfWork
-
recipient
-
hopCount
protected short hopCount
-
-
Constructor Details
-
SignedMessage
public SignedMessage(int networkId, CompressedPublicKey sender, ProofOfWork proofOfWork, CompressedPublicKey recipient, Message payload)
-
-
Method Details
-
getPayload
-
writeFieldsTo
Description copied from interface:Signable
Write any content into the passed output-stream to have them included in the signing process.
Only use this with the default-implementation of
Signable.getSignableBytes()
- Specified by:
writeFieldsTo
in interfaceSignable
- Parameters:
outstream
- an outputstream to write to- Throws:
IOException
-
getSignature
Description copied from interface:Signable
Returns the signature this signable object was signed with.- Specified by:
getSignature
in interfaceSignable
-
setSignature
Description copied from interface:Signable
Signs the object with the specified signature. After this method was invoked subsequent calls toSignable.getSignature()
should return aSignature
object that is equal to the specifiedsignature
.- Specified by:
setSignature
in interfaceSignable
-
toString
-
equals
-
hashCode
public int hashCode() -
getId
Description copied from interface:Message
Returns the unique id of this message. Each message generates a random id when it is created. -
getUserAgent
Description copied from interface:Message
Returns the user agent of the sender's node.- Specified by:
getUserAgent
in interfaceMessage
- Returns:
- the user agent of the sender's node.
-
getNetworkId
public int getNetworkId()Description copied from interface:Message
Returns the network the sender belongs to.- Specified by:
getNetworkId
in interfaceMessage
- Returns:
- the network the sender belongs to
-
getSender
Description copied from interface:Message
Returns this message's sender. -
getProofOfWork
Description copied from interface:Message
Returns this message sender's proof of work.- Specified by:
getProofOfWork
in interfaceMessage
- Returns:
- this message sender's proof of work.
-
getRecipient
Description copied from interface:Message
Returns this message's recipient.- Specified by:
getRecipient
in interfaceMessage
- Returns:
- this message's recipient.
-
getHopCount
public short getHopCount()Description copied from interface:Message
Returns this message's hop count. Starts at 0 and is incremented every time it is sent. Once the message reaches the limit defined in configdrasyl.message.hop-limit
it will be dropped.- Specified by:
getHopCount
in interfaceMessage
- Returns:
- this message's hop count.
-
incrementHopCount
public void incrementHopCount()Description copied from interface:Message
Increases the message's hop count.- Specified by:
incrementHopCount
in interfaceMessage
-