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 AdminPrivilegeService
protected String
prefixWithEntityValidationMessageKey
(String errorCode) void
setAdminPrivilegeService
(AdminPrivilegeService adminPrivilegeService) Lazy injection since this validator is itself a service component.boolean
supports
(Class<?> serviceClass, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) void
validate
(Object businessInstance, org.springframework.validation.Errors errors, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
validateEmail
(org.springframework.validation.Errors errors) protected void
validateName
(org.springframework.validation.Errors errors) protected void
validateRoleAndPermissionReferences
(AdminUser user, org.springframework.validation.Errors errors) Validates that all roles have an id and are non-null.protected void
validateUsername
(org.springframework.validation.Errors errors) protected void
validateUserPrivileges
(AdminUser user, org.springframework.validation.Errors errors) Validates that the created/updated user is equally or more restrictive as the currently authenticatedAdminUser
based on their restrictions at the very least.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
supports
in 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:
validate
in 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 authenticatedAdminUser
based 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
-