-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add endpoint identifier. #322
Conversation
To be frank: So in my view, providing the "intended credentials or parts of the credential as identity" ahead when sending a Message, should overcome the callbacks with that information at all. The calback are only required, if you bind the matching to the "created session". For notifies received from changed addresses, the credential are also available on receive and could be used to find the proper exchange (and adjust the ip-address for future communication to that device). Again, this requires unique credentials for all devices. |
Not to change the API to much, my intention was to put that "identity" into the correlation context and add a optional correlation context also for sending a request. |
I'm not so confident. I don't think a final solution will be proposed soon :/
Callback is necessary for use case where peer don't use authentication, or where the identifier chosen could not be know by the user before (e.g. session ID)
At short term, I need it for backward compatibility. For reason exposed above, I'm not sure we will be able to remove it. But If we can I agree to remove it. (Less code we have better, it is)
That's why having a EndpoinIdentifierFactory is a good way to let users choose what they want to use as "identifier"
I rather prefer to remove the CorrelationContext to CoapStack and just let CorrelationContext at element-connector level. Unless you have strong opinion against my first step, I will continue in that way more in a POC spirit. We have this "identifier" issue for a long time ago and I would like to move forward. I'm sure I will face issue I don't think about for now. |
I agree, that it will not be proposed soon.
That's exactly the NONE use case for me. But if you want to solve that, try it. |
You mean instead of using endpoint identifier ? |
Yes. |
And we could use a partial/incomplete correlation context on send() ? |
Therefore the exchangeable correlation context matcher was introduced. My idea was to make a matcher, which uses the identity.
My idea was to use the "identity" to adjust the "address". |
That's mean you identify observation by (address+token) ? |
The So my idea (not detailed right now) was, that a correlation context may also be used for adjust addresses before this lookup. |
So you should have a kind of index {identity => keys (address+token) }? |
My basic idea is to add a "identifier" (say the psk identity) to the correlation context and pass it in with the request. The connector the decided, if the "identifier" matches using the correlation context matcher. On receiving a message, the connector adds the identity to the correlation context. |
@@ -158,7 +163,8 @@ protected final Exchange matchNotifyResponse(final Response response, final Corr | |||
final Exchange.KeyToken idByToken = Exchange.KeyToken.fromInboundMessage(response); | |||
Exchange exchange = null; | |||
|
|||
final Observation obs = observationStore.get(response.getToken()); | |||
final EndpointIdentifier sourceEndpoint = response.getSourceEndpoint(); |
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.
But, where is that "reponse source endpoint" set during receiving a response?
That's the core of my question, on what "protocol artifact" your are going to build the identity.
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.
This is set in coapEndpoint.
And the IdentifierFactory
is responsible to define what should be used as Identifier.
(For Leshan I want to use Principal)
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.
The IdentifierFactory
is responsible to translate Identifier
in context
and context
in Identifier
.
(translation is centralized in this class)
I have in mind that context
could be a connector concept and Identifier
a CoAP stack one.
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.
OK.
So the main difference seems to be, that I would just pass the CorrelationContext
into the ObserveStore
, and you would prefer to have a "IdentifierFactory" to convert that CorrelationContext
ahead into a EndpointIdentifier
.
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.
Yep.
|
||
public void onDestinationEndpointDefined(EndpointIdentifier destination) { | ||
LOG.log(Level.FINER, "registering observe request {0}", request); | ||
observationStore.add(destination, new Observation(request, exchange.getCorrelationContext())); |
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.
If we delay the add
until onDestinationEndpointDefined
, I'm not sure if we require the remove
in failed()
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'm not sure. The destination endpoint is defined just after an handshake success, but the APPLICATION _DATA sending can fail. In that case we want to remove observation from store.
This will never be merged. |
Here is a try to define an identifier for foreign endpoint.
The PR was largely inspired by this long discussion.
This is a work in progress and should not be merged now.
This first step introduces the concept of endpoint identifier and uses it to identify observation.
Next step : Adding
Principal
toCorrelationContext
to be able to definePrincipalEndpointIdentifier
to be able to test that in Leshan.While this first step, I had the feeling that maybe
CorrelationContext
could be not necessary at CoAP side anymore (only at Connector side). This is a track I would explore. This could simplify the code and also solve some questions like #311.Another point will be to change TokenProvider (replace
reserve/release
byrandom generation
) to solve issue raised by Achim in #173.Even, if this is a work in progress, I strongly advice to try to review this PR each time I add new commits. This is the only way to make this review digestible.