FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

EncryptionUtils - added support for passing key and certificate as bytes array by nchandran10 · Pull Request #99 · Mastercard/client-encryption-java · GitHub

EncryptionUtils - added support for passing key and certificate as bytes array - #99

Merged
karen-avetisyan-mc merged 4 commits into
Mastercard:mainfrom
nchandran10:main
Sep 11, 2024
Merged

EncryptionUtils - added support for passing key and certificate as bytes array#99
karen-avetisyan-mc merged 4 commits into
Mastercard:mainfrom
nchandran10:main

Conversation

nchandran10 commented Sep 2, 2024
edited
Loading

Copy link
Copy Markdown

EncryptionUtils.loadDecryptionKey and EncryptionUtils.loadEncryptionCertificate now supports bytes array for populating respective object along with existing support for filepath.

  • An issue/feature request has been created for this PR
  • Pull Request title clearly describes the work in the pull request and the Pull Request description provides details about how to validate the work. Missing information here may result in a delayed response.
  • File the PR against the main branch
  • The code in this PR is covered by unit tests

Link 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.

jaaufauvre added the safe The PR has been reviewed by Mastercard and has been validated to be safe label Sep 2, 2024

karen-avetisyan-mc commented Sep 2, 2024
edited
Loading

Copy link
Copy Markdown
Contributor

What is a use case for this scenario?

/**
* 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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Don't forget to add tests to the EncryptionUtilsTest class, all public methods should be tested.

e113028 added 2 commits September 4, 2024 09:26

karen-avetisyan-mc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

ShimonaR-MC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks fine

karen-avetisyan-mc merged commit bb115d9 into Mastercard:main 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

Labels

safe The PR has been reviewed by Mastercard and has been validated to be safe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL