-
Notifications
You must be signed in to change notification settings - Fork 408
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
Added OPAQUE text encoding, using base64 #676
Added OPAQUE text encoding, using base64 #676
Conversation
Some doubts:
|
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.
Do we need to handle null values?
This is not possible to create a LwM2mSingleResource
with a null value : see code
It is correct to assume that the value is a byte[]? Casting ((byte[])val) is safe?
The LwM2mResource javadoc says : "If getType() returns Type.OPAQUE, the value is a byte array."
So I think we're good :)
Thx for this, did you plan to push the decoder in this PR or in another one ?
leshan-core/src/main/java/org/eclipse/leshan/core/node/codec/text/LwM2mNodeTextEncoder.java
Outdated
Show resolved
Hide resolved
leshan-core/src/test/java/org/eclipse/leshan/core/node/codec/LwM2mNodeEncoderTest.java
Outdated
Show resolved
Hide resolved
b35dddf
to
76ef3b4
Compare
I will now have a look at the decoder. I think to add it here if for you is ok. |
👍 |
9f4a9e5
to
5dc6242
Compare
Added decoder and test. I have squashed all commits ... Do you think that we need a try/catch inside the decoder? |
I would say we should handle the case where the string is not a valid base64 payload and so raise a CodecException ! But the So reading the code, it seems that IllegalStateException could be raised ?
We should add some test with bad payload, we will see how base64 behave and you could try several solutions and choose the best one ? |
I have tried to write a test with an input that cause the I have added a test to ensure this behaviour, see We can probably use In any case I'm open to suggestions, I will follow you ;-) |
With this implementation, Invalid characters is ignored. As I was a bit lost with all of this ... I read the RFC4648.
By the way the LWM2M specification does not talk about url safe alphabet. So a perfect solution should be to have a default base64 decoder which :
by raising a CodecException.
So, we can :
|
Thanks! Good investigation! If for you is ok I will proceed with:
I will first call Ok? |
👍 |
Signed-off-by: Davide Icardi <davide.icardi@gmail.com>
96b3108
to
bff1ab4
Compare
Ok done! let met know if you see problems ... |
Sounds good, I will integrate this in master. (I create a new issue about issue we discover here, see #678 ) |
Thx @davideicardi ! 🙏 |
Great! Thank you @sbernard31 ! |
We have a jenkins build : https://hudson.eclipse.org/leshan/job/leshan/, but jars are not deployed ... 😞 But building jars locally is pretty easy, doing this you will have a leshan-*-SNAPSHOT available in your local maven repository and so you could test it easily just adding SNAPSHOT version to you dependencies. Last point, if you need a release just let me know :) |
The problem is that we have some build pipelines running with the Leshan dependency ... so building it locally can be a little difficult ... Taking it from a maven repo is easier... |
I will try, but maybe doing some validation before could be a good idea 🤔 |
@davideicardi did you made some tests ? |
Good news! I have used a local compiled version during these days and for now it is working fine. Green light for me! |
You probably don't care but finally #657 will not be integrated in this release. (next one) |
Signed-off-by: Davide Icardi davide.icardi@gmail.com
See #675