Skip to content
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

Clean up base64 processing #695

Merged
merged 1 commit into from
Nov 24, 2016
Merged

Conversation

ctron
Copy link
Contributor

@ctron ctron commented Oct 31, 2016

This change forwards base 64 encoding to the already existing
dependency commons-net.

By re-using code from commons-net the reflection based method invocation
can be replaced by a proper method call.

In addition a unit test was added to verify the same output as the old
implementation.

Signed-off-by: Jens Reimann jreimann@redhat.com

@ctron ctron added this to the KURA-2.2.0 milestone Oct 31, 2016
Copy link
Member

@amitjoy amitjoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for the PR. It would be nice to throw KuraRuntimeException instead of so generic RuntimeException as in KRE, you can specify error codes.

*/
return new String(Base64.encodeBase64(encryptedBytes, false), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of throwing generic Runtime Exception, it would be better off with KuraRuntimeException, in which you can specify the KuraErrorCode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a big difference, the exception will never ever be thrown and the whole try-catch will be gone with java 7 anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if that should be a blocker, then I don't really care.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace with String(byte[] bytes, Charset charset) which does not throw exceptions

Copy link
Member

@amitjoy amitjoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@MMaiero
Copy link
Contributor

MMaiero commented Nov 23, 2016

Since Kura 3.0.0 will only target Java 8, why not thinking of using only base64 java 8 primitives? Indirectly it was already used. And we don't need the dependency on commons.net.
Furthermore, it is available for compact profiles

@ctron
Copy link
Contributor Author

ctron commented Nov 24, 2016

Updated to use Java 8 only. Rebased.

This change re-implements base64 processing by using standard Java 8
functionality.

In addition a unit test was added to verify the same output as the old
implementation.

Signed-off-by: Jens Reimann <jreimann@redhat.com>
@cdealti
Copy link
Contributor

cdealti commented Nov 24, 2016

@MMaiero please vote

@MMaiero MMaiero merged commit dee542b into eclipse:develop Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants