Package com.mastercard.developer.utils
Class EncryptionUtils
- java.lang.Object
-
- com.mastercard.developer.utils.EncryptionUtils
-
public final class EncryptionUtils extends Object
Utility class for loading certificates and keys.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PrivateKey
loadDecryptionKey(InputStream keyDataStream)
Load a RSA decryption key from key data in bytes.static PrivateKey
loadDecryptionKey(String keyFilePath)
Load a RSA decryption key from a file (PEM or DER).static PrivateKey
loadDecryptionKey(String pkcs12KeyFilePath, String decryptionKeyAlias, String decryptionKeyPassword)
Load a RSA decryption key out of a PKCS#12 container.static Certificate
loadEncryptionCertificate(InputStream certificateStream)
Populate a X509 encryption certificate object with the certificate data at the given certificate data in bytes.static Certificate
loadEncryptionCertificate(String certificatePath)
Populate a X509 encryption certificate object with the certificate data at the given file path.static String
sanitizeJson(String json)
-
-
-
Method Detail
-
loadEncryptionCertificate
public static Certificate loadEncryptionCertificate(String certificatePath) throws CertificateException, IOException
Populate a X509 encryption certificate object with the certificate data at the given file path.- Throws:
CertificateException
IOException
-
loadEncryptionCertificate
public static Certificate loadEncryptionCertificate(InputStream certificateStream) throws CertificateException
Populate a X509 encryption certificate object with the certificate data at the given certificate data in bytes.- Throws:
CertificateException
-
loadDecryptionKey
public static PrivateKey loadDecryptionKey(String keyFilePath) throws GeneralSecurityException, IOException
Load a RSA decryption key from a file (PEM or DER).- Throws:
GeneralSecurityException
IOException
-
loadDecryptionKey
public static PrivateKey loadDecryptionKey(InputStream keyDataStream) throws GeneralSecurityException, IOException
Load a RSA decryption key from key data in bytes.- Throws:
GeneralSecurityException
IOException
-
loadDecryptionKey
public static PrivateKey loadDecryptionKey(String pkcs12KeyFilePath, String decryptionKeyAlias, String decryptionKeyPassword) throws GeneralSecurityException, IOException
Load a RSA decryption key out of a PKCS#12 container.- Throws:
GeneralSecurityException
IOException
-
-