Class UserWrapper

java.lang.Object
org.openwms.core.uaa.impl.UserWrapper
All Implemented Interfaces:
Serializable, UserHolder, org.springframework.security.core.userdetails.UserDetails
Direct Known Subclasses:
SystemUserWrapper

public class UserWrapper extends Object implements org.springframework.security.core.userdetails.UserDetails, UserHolder, Serializable
An UserWrapper is used as an adapter between Roles, SecurityObjects and Spring's GrantedAuthority objects.
Author:
Tina Russell
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • user

      private final User user
    • authorities

      private Collection<org.springframework.security.core.GrantedAuthority> authorities
  • Constructor Details

    • UserWrapper

      public UserWrapper(User user)
      Create a new UserWrapper.
      Parameters:
      user - The User to wrap
  • Method Details

    • addDefaultGrants

      protected void addDefaultGrants(Collection<org.springframework.security.core.GrantedAuthority> authz)
      Subclasses can set a collection of grants that are always available for an User. This is useful for administrative accounts.
      Parameters:
      authz - A collection of grants (authorities) where the default grants are added to
    • getUser

      public User getUser()
      Return the wrapped User instance.
      Specified by:
      getUser in interface UserHolder
      Returns:
      The wrapped User
    • getAuthorities

      public Collection<org.springframework.security.core.GrantedAuthority> getAuthorities()
      Specified by:
      getAuthorities in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      the authorities, sorted by natural key (never null)
    • getPassword

      public String getPassword()
      Specified by:
      getPassword in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      the password (never null)
    • getUsername

      public String getUsername()
      Specified by:
      getUsername in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      the username (never null)
    • isAccountNonExpired

      public boolean isAccountNonExpired()
      Specified by:
      isAccountNonExpired in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user's account is valid (ie non-expired), false if no longer valid (ie expired)
    • isAccountNonLocked

      public boolean isAccountNonLocked()
      Specified by:
      isAccountNonLocked in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user is not locked, false otherwise
    • isCredentialsNonExpired

      public boolean isCredentialsNonExpired()
      Specified by:
      isCredentialsNonExpired in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user's credentials are valid (ie non-expired), false if no longer valid (ie expired)
      See Also:
      • UserDetails.isCredentialsNonExpired()
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface org.springframework.security.core.userdetails.UserDetails
      Returns:
      true if the user is enabled, false otherwise
    • hashCode

      public int hashCode()

      Uses authorities and user for calculation.

      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)

      Uses authorities and user for comparison.

      Overrides:
      equals in class Object
    • toString

      public String toString()
      Return the Users username.
      Overrides:
      toString in class Object
      Returns:
      The username of the User
      See Also: