EncryptionUtils - added support for passing key and certificate as bytes array#99
Merged
karen-avetisyan-mc merged 4 commits intoMastercard:mainfrom Sep 11, 2024
Merged
Conversation
added 2 commits
September 2, 2024 16:23
… along with existing support.
Contributor
|
What is a use case for this scenario? |
jaaufauvre
reviewed
Sep 3, 2024
| /** | ||
| * Populate a X509 encryption certificate object with the certificate data at the given certificate data in bytes. | ||
| */ | ||
| public static Certificate loadEncryptionCertificate(byte[] certificateBytes) throws CertificateException { |
Member
There was a problem hiding this comment.
For more flexibility we could use a InputStream instead of a byte[]. This way we can handle data from various sources, files, network, etc.
This is the choice that was made here: https://github.com/Mastercard/oauth1-signer-java/blob/main/src/main/java/com/mastercard/developer/utils/AuthenticationUtils.java#L28
Contributor
There was a problem hiding this comment.
I agree, with that change, we still have a single interface and better flexibility
| /** | ||
| * Load a RSA decryption key from key data in bytes. | ||
| */ | ||
| public static PrivateKey loadDecryptionKey(byte[] keyDataBytes) throws GeneralSecurityException { |
Member
There was a problem hiding this comment.
Don't forget to add tests to the EncryptionUtilsTest class, all public methods should be tested.
added 2 commits
September 4, 2024 09:26
…byte[] certificateBytes), loadEncryptionCertificate(byte[] certificateBytes)
jaaufauvre
approved these changes
Sep 11, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EncryptionUtils.loadDecryptionKey and EncryptionUtils.loadEncryptionCertificate now supports bytes array for populating respective object along with existing support for filepath.
mainbranchLink to issue/feature request:
Description
EncryptionUtils now allow loading Certificate and PrivateKey by passing the data in bytes. Existing functions are still valid and continues to support loading certificate and key using file path.