public class MutualAuthUploadUtility extends Object
Supports multiple authentication mechanisms including JKS, P12/PFX, and direct private key/certificate usage. Uses OkHttp for HTTP communication and supports multipart file uploads.
| Constructor and Description |
|---|
MutualAuthUploadUtility() |
| Modifier and Type | Method and Description |
|---|---|
static ApiResponse<String> |
handleUploadOperationUsingP12orPfx(byte[] encryptedPgpBytes,
String endpointUrl,
String fileName,
String p12FilePath,
char[] p12FilePassword,
String serverTrustCertPath)
Handles file upload operation using P12/PFX keystore and PEM server certificate(s) for mutual authentication
|
static ApiResponse<String> |
handleUploadOperationUsingPrivateKeyAndCerts(byte[] encryptedPgpBytes,
String endpointUrl,
String fileName,
PrivateKey clientPrivateKey,
X509Certificate clientCert,
Collection<X509Certificate> serverTrustCerts)
Handles file upload operation using provided private key and certificates for mutual authentication.
|
static ApiResponse<String> |
handleUploadOperationWithJKS(byte[] encryptedPgpBytes,
String endpointUrl,
String fileName,
String keystorePath,
char[] keystorePassword,
String truststorePath,
char[] truststorePassword)
Handles file upload operation using JKS keystore and truststore for mutual authentication.
|
static void |
setDisableSslVerification(boolean disable)
Sets whether SSL verification should be disabled.
|
public static ApiResponse<String> handleUploadOperationWithJKS(byte[] encryptedPgpBytes, String endpointUrl, String fileName, String keystorePath, char[] keystorePassword, String truststorePath, char[] truststorePassword) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, KeyManagementException, UnrecoverableKeyException
encryptedPgpBytes - The encrypted PGP file content as byte arrayendpointUrl - The target URL endpoint for file uploadfileName - The name of the file to be uploaded (will be suffixed with .pgp)keystorePath - The file path to the JKS keystore containing client certificateskeystorePassword - The password for the JKS keystoretruststorePath - (Optional) The file path to the JKS truststore containing trusted server certificates. Can be null if not required.truststorePassword - The password for the JKS truststoreIOException - If file operations or network communication failsKeyStoreException - If keystore operations failNoSuchAlgorithmException - If required cryptographic algorithms are not availableCertificateException - If certificate processing failsKeyManagementException - If SSL key management failsUnrecoverableKeyException - If private key cannot be recovered from keystorepublic static ApiResponse<String> handleUploadOperationUsingP12orPfx(byte[] encryptedPgpBytes, String endpointUrl, String fileName, String p12FilePath, char[] p12FilePassword, String serverTrustCertPath) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException, KeyManagementException, UnrecoverableKeyException
encryptedPgpBytes - The encrypted PGP file content as a byte arrayendpointUrl - The target URL endpoint for file uploadfileName - The name of the file to be uploaded (will be suffixed with .pgp)p12FilePath - The file path to the P12/PFX keystore containing client certificatesp12FilePassword - The password for the P12/PFX keystoreserverTrustCertPath - (Optional) The file path to the PEM file containing one or more server trust certificates. Can be null if not requiredIOException - If file operations or network communication failsKeyStoreException - If keystore operations failNoSuchAlgorithmException - If required cryptographic algorithms are not availableCertificateException - If certificate processing failsKeyManagementException - If SSL key management failsUnrecoverableKeyException - If private key cannot be recovered from keystorepublic static ApiResponse<String> handleUploadOperationUsingPrivateKeyAndCerts(byte[] encryptedPgpBytes, String endpointUrl, String fileName, PrivateKey clientPrivateKey, X509Certificate clientCert, Collection<X509Certificate> serverTrustCerts) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException
encryptedPgpBytes - The encrypted PGP file content as byte arrayendpointUrl - The target URL endpoint for file uploadfileName - The name of the file to be uploaded (will be suffixed with .pgp)clientPrivateKey - The client's private key for authenticationclientCert - The client's X509 certificateserverTrustCerts - (Optional) A collection of server's trusted X509 certificates (can be a certificate chain). Can be null or empty if not required.KeyStoreException - If keystore operations failNoSuchAlgorithmException - If required cryptographic algorithms are not availableCertificateException - If certificate processing failsIOException - If file operations or network communication failsUnrecoverableKeyException - If private key cannot be recoveredKeyManagementException - If SSL key management failspublic static void setDisableSslVerification(boolean disable)
disable - true to disable SSL verification, false to enable
By default, SSL verification is enabled.Copyright © 2026. All rights reserved.