java.lang.Object
com.foreach.across.modules.hibernate.business.SettableIdBasedEntity<T>
com.foreach.across.modules.hibernate.business.SettableIdAuditableEntity<Role>
com.foreach.across.modules.user.business.Role
All Implemented Interfaces:
com.foreach.across.modules.hibernate.business.Auditable<String>, com.foreach.across.modules.hibernate.business.EntityWithDto<Role>, com.foreach.across.modules.hibernate.business.IdBasedEntity, Serializable, org.springframework.data.domain.Persistable<Long>

@NotThreadSafe @Entity public class Role extends com.foreach.across.modules.hibernate.business.SettableIdAuditableEntity<Role> implements Serializable
A role represents a number of permissions that can be applied for a principal. The role is by itself also a GrantedAuthority that can be used for security checking.
See Also:
  • Field Details

  • Constructor Details

    • Role

      public Role()
    • Role

      public Role(String authority)
    • Role

      public Role(String authority, String name)
  • Method Details

    • getId

      public Long getId()
      Specified by:
      getId in interface com.foreach.across.modules.hibernate.business.IdBasedEntity
      Specified by:
      getId in interface org.springframework.data.domain.Persistable<Long>
    • setId

      public void setId(Long id)
      Specified by:
      setId in class com.foreach.across.modules.hibernate.business.SettableIdBasedEntity<Role>
    • getAuthority

      public String getAuthority()
    • setAuthority

      public void setAuthority(String authority)
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getDescription

      public String getDescription()
    • setDescription

      public void setDescription(String description)
    • getPermissions

      public Set<Permission> getPermissions()
    • setPermissions

      public void setPermissions(Collection<Permission> permissions)
    • addPermission

      public void addPermission(Permission... permissions)
    • hasPermission

      public boolean hasPermission(String authority)
      Does the user have a permission with the requested authority string.
      Parameters:
      authority - string to check
      Returns:
      true if permission is present
    • hasPermission

      public boolean hasPermission(Permission permission)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toGrantedAuthority

      public org.springframework.security.core.GrantedAuthority toGrantedAuthority()
      Convert this role to a Spring security GrantedAuthority for use in authentication.
      Returns:
      granted authority
    • authorityString

      public static String authorityString(String role)
      Generate the authority string for a role, applies the prefix if is not yet present.
      Parameters:
      role - authority name of the role
      Returns:
      authority string