-
Notifications
You must be signed in to change notification settings - Fork 140
Add clearing of shared secret on disconnected #247
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 clearing of shared secret on disconnected #247
Conversation
Fix IndexOutOfBounds when passing all 4 args in the example app. Make the example app honour variable length of arguments array. Fix warning. Improve formatting.
|
|
||
| private String authenticate() { | ||
| @Override | ||
| public String toSubscribeMessage() { |
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.
Just moved to be first as public (high level) method, the private (low level, detail) methods come after it. Also fixed warnings too about redundant generics at the definition side.
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's a bit of a hack, but I think it will work for now :)
Why? It's using existing listener facility of |
|
You mean probably needing to set listener and unset when called back as opposed to be called on a own method like it is the case of |
Make the code more legible. That is more symmetrical when it comes to setting/removing the disconnect listener, and creating/disposing SecretBoxOpener. Make the example app exercise unsubscribe too and the two combinations (subscribed/unsubscribed) when disconnect is called.
| case 4: cluster = args[3]; | ||
| case 3: eventName = args[2]; | ||
| case 2: channelName = args[1]; | ||
| case 0: apiKey = args[0]; |
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.
0 args, or 1 arg?
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.
Oh sorry a schoolboy error 🤦♂ Good catch! Fixed: 670609e
|
Oops, sorry, didn't mean to hit "approve", though I generallly do, I think the final case fallthrough is incorrect. |
Fix accepting a single arg. Thanks Mike for catching it: #247 (comment)
| channelName = args[1]; | ||
| eventName = args[2]; | ||
| cluster = args[3]; | ||
| switch (args.length) { |
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've not seen this done before for setting a bunch of objects - is this going to go through each item setting it, or just to call it once and set only the last element?
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.
Because the break; is missing from each case, they will all "fall though". It will start at the matching case and execute all the remaining ones. I've not seen it either, but it does seem quite neat.
| pusher.connect(this); | ||
| Thread.sleep(5000); | ||
| pusher.unsubscribe(channelName); // to test clearing of shared secret (via tmp log) | ||
| if (i % 2 == 0) { // to test disconnect on both unsubscribed/subscribed |
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 don't think this Example app now models a real life use - it's trying to be a test and is not useful as the first example of Private Encrypted Channels people see. Either we need to refactor this to be clearer exactly what's happening and why we're disconnecting/reconnecting every 5 seconds, or maybe the easier solution is to make a new Private Encrypted Channel Example app that showcases how people handle disconnects - maybe this can be procedurally driven and not require a while loop.
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.
thanks! as discussed reverted to not complicate the encrypted channel example, making it more of a test app: 95d5ca3
|
|
||
| @Override | ||
| public void onConnectionStateChange(ConnectionStateChange change) { | ||
| disposeSecretBoxOpener(); |
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.
Won't this get called a lot of times? e.g. you go through CONNECTING to CONNECTED - would this not be better if it was only if the connect state was DISCONNECTING?
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's a bit... "disconnected", but you'll find your answer here: https://github.com/pusher/pusher-websocket-java/pull/247/files#diff-48ff2981ea97376b5f1cedec4b59e059R114
Consistently tidy up PrivateEncryptedChannelImplTest
Codecov Report
@@ Coverage Diff @@
## decrypt-integration #247 +/- ##
=========================================================
+ Coverage 76.72% 76.79% +0.07%
- Complexity 265 270 +5
=========================================================
Files 33 33
Lines 2337 2357 +20
Branches 115 116 +1
=========================================================
+ Hits 1793 1810 +17
- Misses 492 495 +3
Partials 52 52
Continue to review full report at Codecov.
|
No description provided.