Class OAuthClientRegistrationWrapperEntityValidator

java.lang.Object
com.broadleafcommerce.auth.client.validation.OAuthClientRegistrationWrapperEntityValidator
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator

public class OAuthClientRegistrationWrapperEntityValidator extends Object implements com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
Validate that a OAuthClientRegistrationWrapper has a registration id, client id, and client secret
  • Constructor Details

    • OAuthClientRegistrationWrapperEntityValidator

      public OAuthClientRegistrationWrapperEntityValidator()
  • Method Details

    • supports

      public boolean supports(@NonNull @NonNull Class<?> serviceClass, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      supports in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validate

      public void validate(@NonNull @NonNull Object businessInstance, @NonNull @NonNull org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validate in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateForReplace

      public void validateForReplace(Object businessInstance, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validateForReplace in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateForUpdate

      public void validateForUpdate(Object updatedBusinessInstance, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validateForUpdate in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateCannotMutateInstanceIfDefinedInProperties

      protected void validateCannotMutateInstanceIfDefinedInProperties(Object businessInstance, org.springframework.validation.Errors errors, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)

      As implemented in DefaultBroadleafClientRegistrationRepository, when client registrations are defined in both properties and in the database, the property-based registration will always win. This means if someone makes an API call to modify the DB representation, it will have no meaningful effect in system anyway, since the new persisted values will take a backseat to whatever is defined in properties.

      To avoid confusion around this, we implement this validation to disallow DB mutation of any client registration that is defined via properties. This gives the user a clear indication that their changes are invalid.

      Parameters:
      businessInstance - the client registration instance to validate
      errors - the errors object on which to register errors
      context - context information around multitenant state
    • setClientRegistrationPropertiesService

      @Autowired public void setClientRegistrationPropertiesService(ClientRegistrationPropertiesService<OAuthClientRegistrationWrapper> clientRegistrationPropertiesService)