Class DefaultCheckoutComApplePayWebClientProvider
java.lang.Object
com.broadleafcommerce.vendor.checkoutcom.service.session.DefaultCheckoutComApplePayWebClientProvider
- All Implemented Interfaces:
CheckoutComApplePayWebClientProvider
public class DefaultCheckoutComApplePayWebClientProvider
extends Object
implements CheckoutComApplePayWebClientProvider
Default implementation for
CheckoutComApplePayWebClientProvider.- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCheckoutComApplePayWebClientProvider(CheckoutComApplePayCertificateAndKeyProvider certificatesProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgenerateCacheKey(String applicationId, String tenantId) org.springframework.web.reactive.function.client.WebClientgetApplePayWebClient(String applicationId, String tenantId) Create and return theWebClientwith the Apple Pay certificates.protected io.netty.handler.ssl.SslContextgetSslContext(String applicationId, String tenantId) Builds theSslContextfor web client with the Apple Pay certificates.protected StringgetUniqueApplePayClientCertificateAlias(String applicationId, String tenantId) protected StringgetUniqueApplePayClientKeyAlias(String applicationId, String tenantId) protected org.apache.commons.lang3.tuple.Pair<PrivateKey,Certificate> handleReadKeyAndCertForCustomFormat(String certAndKeyFormat, InputStream keyInputStream, InputStream certificateInputStream) Hook point for clients to handle cert and key formats that are not supported out-of-box.protected CertificateloadCertificate(InputStream inputStream) Reads certificate from the input stream.protected CertificateloadCertificateFromString(InputStream inputStream) Reads certificate from the input stream.protected byte[]readPemContent(InputStream inputStream) protected PrivateKeyreadPrivateKey(InputStream inputStream) Reads a private key from the input stream.protected PrivateKeyreadPrivateKeyFromString(InputStream inputStream) Reads a private key from the input stream.
-
Constructor Details
-
DefaultCheckoutComApplePayWebClientProvider
public DefaultCheckoutComApplePayWebClientProvider(CheckoutComApplePayCertificateAndKeyProvider certificatesProvider)
-
-
Method Details
-
getApplePayWebClient
public org.springframework.web.reactive.function.client.WebClient getApplePayWebClient(@Nullable String applicationId, @Nullable String tenantId) Description copied from interface:CheckoutComApplePayWebClientProviderCreate and return theWebClientwith the Apple Pay certificates.- Specified by:
getApplePayWebClientin interfaceCheckoutComApplePayWebClientProvider- Parameters:
applicationId- the application idtenantId- the tenant id- Returns:
- the web client with the Apple Pay certificates
-
generateCacheKey
-
getSslContext
protected io.netty.handler.ssl.SslContext getSslContext(@Nullable String applicationId, @Nullable String tenantId) Builds theSslContextfor web client with the Apple Pay certificates. This is required to execute the secure request to the Apple Pay API.- Parameters:
applicationId- the application idtenantId- the tenant id- Returns:
- the
SslContextfor web client with the Apple Pay certificates - See Also:
-
handleReadKeyAndCertForCustomFormat
protected org.apache.commons.lang3.tuple.Pair<PrivateKey,Certificate> handleReadKeyAndCertForCustomFormat(String certAndKeyFormat, InputStream keyInputStream, InputStream certificateInputStream) Hook point for clients to handle cert and key formats that are not supported out-of-box. By default, this just throws an exception.- Parameters:
certAndKeyFormat- theCheckoutComApplePayCertificateAndKeyProvider.getCertAndKeyFormat()keyInputStream- theCheckoutComApplePayCertificateAndKeyProvider.getPrivateKeyInputStream(String, String)certificateInputStream- theCheckoutComApplePayCertificateAndKeyProvider.getCertificateInputStream(String, String)- Returns:
- the read/parsed representations of the private key and certificate
-
getUniqueApplePayClientCertificateAlias
-
getUniqueApplePayClientKeyAlias
-
loadCertificate
protected Certificate loadCertificate(InputStream inputStream) throws IOException, GeneralSecurityException Reads certificate from the input stream. It expects that a certificate is in PEM format- Parameters:
inputStream- the input stream of a PEM file with a certificate.- Returns:
- a
Certificate - Throws:
IOExceptionGeneralSecurityException
-
readPrivateKey
protected PrivateKey readPrivateKey(InputStream inputStream) throws NoSuchAlgorithmException, IOException, InvalidKeySpecException Reads a private key from the input stream. It expects that a key is in PEM format- Parameters:
inputStream- the input stream of a PEM file with a private key.- Returns:
- a
PrivateKey - Throws:
NoSuchAlgorithmExceptionIOExceptionInvalidKeySpecException
-
loadCertificateFromString
protected Certificate loadCertificateFromString(InputStream inputStream) throws IOException, GeneralSecurityException Reads certificate from the input stream. It expects that a certificate is in DER format base64 encoded- Parameters:
inputStream- the input stream of a base64 encoded certificate in DER format.- Returns:
- a
Certificate - Throws:
IOExceptionGeneralSecurityException
-
readPrivateKeyFromString
protected PrivateKey readPrivateKeyFromString(InputStream inputStream) throws NoSuchAlgorithmException, IOException, InvalidKeySpecException Reads a private key from the input stream. It expects that a key is in DER format base64 encoded- Parameters:
inputStream- the input stream of a base64 encoded private key in DER format.- Returns:
- a
PrivateKey - Throws:
NoSuchAlgorithmExceptionIOExceptionInvalidKeySpecException
-
readPemContent
- Throws:
IOException
-