Class PaymentCallbackSecurityTokenUtil
java.lang.Object
com.broadleafcommerce.paymentgateway.util.PaymentCallbackSecurityTokenUtil
Utility class to create, validate, and manage payment callback tokens.
- Author:
- mariestandeven
-
Field Summary
-
Constructor Summary
ConstructorDescriptionPaymentCallbackSecurityTokenUtil
(org.springframework.security.crypto.password.PasswordEncoder paymentCallbackTokenEncoder, PaymentCallbackTokenProperties paymentCallbackTokenProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPaymentCallbackTokenToPaymentMethodPropertyUrls
(@NonNull PaymentInfo paymentInfo, @NonNull Set<String> urlKeys, String applicationId, String tenantId) protected boolean
containsCallbackUrl
(@NonNull Map<String, String> paymentMethodProperties, @NonNull Set<String> urlKeys) protected String
encodePaymentCallbackToken
(@NonNull String token, String applicationId, String tenantId) protected String
generatePaymentCallbackToken
(@NonNull PaymentInfo paymentInfo, String applicationId, String tenantId, boolean includeSpecialCharacters) protected org.springframework.web.util.UriComponentsBuilder
getBaseUri
(String url) protected Instant
getDeserializedCreationDate
(String creationDate, String applicationId, String tenantId) protected com.fasterxml.jackson.databind.ObjectMapper
protected org.springframework.security.crypto.password.PasswordEncoder
protected PaymentCallbackTokenProperties
protected String
getSecureTokenQueryParam
(@NonNull PaymentInfo paymentInfo, @NonNull String tokenId, String applicationId, String tenantId) protected String
getSerializedCreationDate
(Instant creationDate, String applicationId, String tenantId) protected char[]
getTokenChars
(@NonNull String gatewayType, String applicationId, String tenantId) protected Duration
getTokenDuration
(@NonNull String gatewayType, String applicationId, String tenantId) protected int
getTokenLength
(@NonNull String gatewayType, String applicationId, String tenantId) protected boolean
isTokenExpired
(String serializedCreationDate, PaymentInfo paymentInfo, String applicationId, String tenantId) protected boolean
tokenMatches
(String token, String encodedToken) protected void
updateUrlsToIncludePaymentCallbackTokenParam
(@NonNull PaymentInfo paymentInfo, @NonNull String tokenId, @NonNull Set<String> urlKeys, @NonNull Map<String, String> paymentMethodProperties, @NonNull String paymentCallbackToken, String applicationId, String tenantId) boolean
verifyPaymentCallbackSecurityToken
(PaymentInfo paymentInfo, String tokenFromPaymentCallbackParam, String applicationId, String tenantId)
-
Field Details
-
RANDOM
-
-
Constructor Details
-
PaymentCallbackSecurityTokenUtil
public PaymentCallbackSecurityTokenUtil(org.springframework.security.crypto.password.PasswordEncoder paymentCallbackTokenEncoder, PaymentCallbackTokenProperties paymentCallbackTokenProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
addPaymentCallbackTokenToPaymentMethodPropertyUrls
public void addPaymentCallbackTokenToPaymentMethodPropertyUrls(@NonNull @NonNull PaymentInfo paymentInfo, @NonNull @NonNull Set<String> urlKeys, @Nullable String applicationId, @Nullable String tenantId) -
verifyPaymentCallbackSecurityToken
public boolean verifyPaymentCallbackSecurityToken(PaymentInfo paymentInfo, String tokenFromPaymentCallbackParam, @Nullable String applicationId, @Nullable String tenantId) -
containsCallbackUrl
-
generatePaymentCallbackToken
protected String generatePaymentCallbackToken(@NonNull @NonNull PaymentInfo paymentInfo, @Nullable String applicationId, @Nullable String tenantId, boolean includeSpecialCharacters) -
getTokenLength
protected int getTokenLength(@NonNull @NonNull String gatewayType, @Nullable String applicationId, @Nullable String tenantId) - Returns:
- How long of a String to generate for a token.
-
getTokenChars
protected char[] getTokenChars(@NonNull @NonNull String gatewayType, @Nullable String applicationId, @Nullable String tenantId) - Returns:
- An array of characters that can be used to generate a token.
-
encodePaymentCallbackToken
-
updateUrlsToIncludePaymentCallbackTokenParam
protected void updateUrlsToIncludePaymentCallbackTokenParam(@NonNull @NonNull PaymentInfo paymentInfo, @NonNull @NonNull String tokenId, @NonNull @NonNull Set<String> urlKeys, @NonNull @NonNull Map<String, String> paymentMethodProperties, @NonNull @NonNull String paymentCallbackToken, @Nullable String applicationId, @Nullable String tenantId) -
tokenMatches
-
isTokenExpired
protected boolean isTokenExpired(@Nullable String serializedCreationDate, PaymentInfo paymentInfo, @Nullable String applicationId, @Nullable String tenantId) -
getDeserializedCreationDate
-
getSerializedCreationDate
-
getTokenDuration
-
getSecureTokenQueryParam
protected String getSecureTokenQueryParam(@NonNull @NonNull PaymentInfo paymentInfo, @NonNull @NonNull String tokenId, @Nullable String applicationId, @Nullable String tenantId) -
getBaseUri
-
getPaymentCallbackTokenEncoder
protected org.springframework.security.crypto.password.PasswordEncoder getPaymentCallbackTokenEncoder() -
getPaymentCallbackTokenProperties
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-