Class PaymentCallbackSecurityTokenUtil

java.lang.Object
com.broadleafcommerce.paymentgateway.util.PaymentCallbackSecurityTokenUtil

public class PaymentCallbackSecurityTokenUtil extends Object
Utility class to create, validate, and manage payment callback tokens.
Author:
mariestandeven
  • Field Details

    • RANDOM

      protected static final Random 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

      protected boolean containsCallbackUrl(@NonNull @NonNull Map<String,String> paymentMethodProperties, @NonNull @NonNull Set<String> urlKeys)
    • 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

      protected String encodePaymentCallbackToken(@NonNull @NonNull String token, @Nullable String applicationId, @Nullable String tenantId)
    • 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

      protected boolean tokenMatches(String token, @Nullable String encodedToken)
    • isTokenExpired

      protected boolean isTokenExpired(@Nullable String serializedCreationDate, PaymentInfo paymentInfo, @Nullable String applicationId, @Nullable String tenantId)
    • getDeserializedCreationDate

      @Nullable protected Instant getDeserializedCreationDate(@Nullable String creationDate, @Nullable String applicationId, @Nullable String tenantId)
    • getSerializedCreationDate

      @Nullable protected String getSerializedCreationDate(Instant creationDate, @Nullable String applicationId, @Nullable String tenantId)
    • getTokenDuration

      protected Duration getTokenDuration(@NonNull @NonNull String gatewayType, @Nullable String applicationId, @Nullable String tenantId)
    • getSecureTokenQueryParam

      protected String getSecureTokenQueryParam(@NonNull @NonNull PaymentInfo paymentInfo, @NonNull @NonNull String tokenId, @Nullable String applicationId, @Nullable String tenantId)
    • getBaseUri

      protected org.springframework.web.util.UriComponentsBuilder getBaseUri(String url)
    • getPaymentCallbackTokenEncoder

      protected org.springframework.security.crypto.password.PasswordEncoder getPaymentCallbackTokenEncoder()
    • getPaymentCallbackTokenProperties

      protected PaymentCallbackTokenProperties getPaymentCallbackTokenProperties()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()