Class TmaUserAccessValidator

  • All Implemented Interfaces:
    org.springframework.validation.Validator

    public class TmaUserAccessValidator
    extends java.lang.Object
    implements org.springframework.validation.Validator
    Validates if the authenticated user is authorized to access a resource
    Since:
    1907
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.springframework.security.core.Authentication getAuth()  
      protected TmaUserFacade getUserFacade()  
      protected boolean hasRole​(java.lang.String role, org.springframework.security.core.Authentication authentication)
      Checks if the user has given role.
      boolean isResourceOwner​(org.springframework.security.core.Authentication authentication, java.lang.String userId)
      Checks if the user isResourceOwner.
      void setUserFacade​(TmaUserFacade userFacade)  
      boolean supports​(java.lang.Class<?> arg0)  
      void validate​(java.lang.Object target, org.springframework.validation.Errors errors)
      Validates if the given User is valid to see customer details
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TmaUserAccessValidator

        public TmaUserAccessValidator()
    • Method Detail

      • supports

        public boolean supports​(java.lang.Class<?> arg0)
        Specified by:
        supports in interface org.springframework.validation.Validator
      • validate

        public void validate​(java.lang.Object target,
                             org.springframework.validation.Errors errors)
        Validates if the given User is valid to see customer details
        Specified by:
        validate in interface org.springframework.validation.Validator
        Parameters:
        target - the User ID
        errors - the list of errors
      • getAuth

        protected org.springframework.security.core.Authentication getAuth()
      • isResourceOwner

        public boolean isResourceOwner​(org.springframework.security.core.Authentication authentication,
                                       java.lang.String userId)
        Checks if the user isResourceOwner.
        Parameters:
        userId - The userId provided.
        Returns:
        False if user is not logged in user, otherwise true.
      • hasRole

        protected boolean hasRole​(java.lang.String role,
                                  org.springframework.security.core.Authentication authentication)
        Checks if the user has given role.
        Parameters:
        role - The role is provided as string
        Returns:
        False if logged in user doesn't have given role, otherwise true.
      • setUserFacade

        public void setUserFacade​(TmaUserFacade userFacade)