-
Notifications
You must be signed in to change notification settings - Fork 43
[OR-219] Enable send API to accept privacy group Id #235
[OR-219] Enable send API to accept privacy group Id #235
Conversation
@@ -117,6 +118,7 @@ public static void configureRoutes( | |||
ConcurrentNetworkNodes networkNodes, | |||
Enclave enclave, | |||
Storage<EncryptedPayload> storage, | |||
Storage<String[]> privacyGroupStorage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the EncryptedPayload
encrypted at rest? If so, then leaking the privacy group mapping is not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not encrypted at rest so ignore this
@@ -78,7 +82,7 @@ public void handle(RoutingContext routingContext) { | |||
} | |||
log.debug(sendRequest); | |||
|
|||
if (sendRequest.to().length == 0) { | |||
if (sendRequest.to() == null && !sendRequest.privacyGroupId().isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, we should propagate this change to pantheon when it is released
final List<Box.PublicKey> toKeys = | ||
Arrays.stream(sendRequest.to()).map(enclave::readKey).collect(Collectors.toList()); | ||
if (!sendRequest.privacyGroupId().isPresent()) { | ||
List<Box.PublicKey> toKeys = Arrays.stream(sendRequest.to()).map(enclave::readKey).collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need to stream the to
keys twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, you do. Ignore this.
@@ -53,6 +60,13 @@ public SendRequest( | |||
this(decodePayload(payload), from, to); | |||
} | |||
|
|||
@JsonAnySetter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use a dedicated @JsonSetter("privacyGroupId")
if it is possible. It is much cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact you should create another constructor with a @JsonProperty("privacyGroupId")
instead of @JsonProperty("to")
.
I am also tempted to make to
an Optional
here because you will either get the to
array or a privacyGroupId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure about making to
optional as - if there is a case where they pass null
aa a third parameter, it will conflict when trying to resolve to either String
or String[]
.
Send API can be invoked in 2 ways, with the following arguments -
from
,to
andpayload
from
,privacyGroupId
andpayload
.Both invocations return
key
.When /send is called with
from
andto
, the privacy group Id is stored. It is also stored when we call /privacyGroupId.Assumptions: