java.lang.Object
com.broadleafcommerce.adminuser.resource.service.validation.AdminUserValidator
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator

public class AdminUserValidator extends Object implements com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
Basic validations for AdminUser.

Validations related to context are performed by AdminUserContextValidator.

Author:
Samarth Dhruva (samarthd)
  • Constructor Details

    • AdminUserValidator

      public AdminUserValidator()
  • Method Details

    • setAdminPrivilegeService

      @Autowired @Lazy public void setAdminPrivilegeService(AdminPrivilegeService adminPrivilegeService)
      Lazy injection since this validator is itself a service component. This avoids circular dependency exceptions
      Parameters:
      adminPrivilegeService - the restriction service
    • supports

      public boolean supports(Class<?> serviceClass, 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 Object businessInstance, @NonNull org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      validate in interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
    • validateName

      protected void validateName(org.springframework.validation.Errors errors)
    • validateEmail

      protected void validateEmail(org.springframework.validation.Errors errors)
    • validateUsername

      protected void validateUsername(org.springframework.validation.Errors errors)
    • validateRoleAndPermissionReferences

      protected void validateRoleAndPermissionReferences(AdminUser user, org.springframework.validation.Errors errors)
      Validates that all roles have an id and are non-null.
      Parameters:
      user - The user with roles to validate
      errors - The errors object
    • validateUserPrivileges

      protected void validateUserPrivileges(AdminUser user, org.springframework.validation.Errors errors)
      Validates that the created/updated user is equally or more restrictive as the currently authenticated AdminUser based on their restrictions at the very least. However, if the authenticated user cannot grant any authority, which is set by the AdminUser.isGrantAnyAuthorityAllowed() flag, then it will validate the privileges based on flat permissions, roles, restrictions, restricted roles, and restricted permissions as well.
      Parameters:
      user - The proposed user creation or modification
      See Also:
    • prefixWithEntityValidationMessageKey

      protected String prefixWithEntityValidationMessageKey(String errorCode)
    • getAdminPrivilegeService

      protected AdminPrivilegeService getAdminPrivilegeService()