Class AdminUserValidator
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AdminPrivilegeServiceprotected StringprefixWithEntityValidationMessageKey(String errorCode) voidsetAdminPrivilegeService(AdminPrivilegeService adminPrivilegeService) Lazy injection since this validator is itself a service component.booleansupports(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) voidvalidate(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected voidvalidateEmail(org.springframework.validation.Errors errors) protected voidvalidateName(org.springframework.validation.Errors errors) protected voidvalidateRoleAndPermissionReferences(AdminUser user, org.springframework.validation.Errors errors) Validates that all roles have an id and are non-null.protected voidvalidateUsername(org.springframework.validation.Errors errors) protected voidvalidateUserPrivileges(AdminUser user, org.springframework.validation.Errors errors) Validates that the created/updated user is equally or more restrictive as the currently authenticatedAdminUserbased on their restrictions at the very least.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.mapping.validation.EntityValidator
validateForCreate, validateForReplace, validateForUpdate
-
Constructor Details
-
AdminUserValidator
public AdminUserValidator()
-
-
Method Details
-
setAdminPrivilegeService
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:
supportsin interfacecom.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:
validatein interfacecom.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 validateerrors- The errors object
-
validateUserPrivileges
Validates that the created/updated user is equally or more restrictive as the currently authenticatedAdminUserbased on their restrictions at the very least. However, if the authenticated user cannot grant any authority, which is set by theAdminUser.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
-
getAdminPrivilegeService
-