Interface SecurityService

All Known Implementing Classes:
SecurityServiceImpl

public interface SecurityService
General interface for work with shiro api.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.shiro.subject.Subject
     
    boolean
     
    boolean
     
    boolean
     
    boolean
    Return true if the current user has any of the roles specified.
    boolean
    hasPermission(String permission)
     
    boolean
     
    <T> T
    Temporarily disable security before invocation of Callable.
    boolean
    Return true only if the current user has executed a successful authentication attempt during their current session.
    boolean
    Return true if the current user is not known to the system, either because they haven't logged in yet, or because they have no 'RememberMe' identity.
    boolean
     
    boolean
     
    boolean
    Return true only if the current user has not executed a successful authentication attempt during their current session.
    boolean
    Return true if the current user known to the system, either from a successful login attempt (not necessarily during the current session) or from 'RememberMe' services.
  • Method Details

    • getSubject

      org.apache.shiro.subject.Subject getSubject()
    • isAuthenticated

      boolean isAuthenticated()
      Return true only if the current user has executed a successful authentication attempt during their current session.

      This is more restrictive than the isUser(), which only ensures the current user is known to the system, either via a current login or from Remember Me services, which only makes the assumption that the current user is who they say they are, and does not guarantee it like this method does.

    • isNotAuthenticated

      boolean isNotAuthenticated()
      Return true only if the current user has not executed a successful authentication attempt during their current session.

      The logically opposite tag of this one is the isAuthenticated().

    • isUser

      boolean isUser()
      Return true if the current user known to the system, either from a successful login attempt (not necessarily during the current session) or from 'RememberMe' services.

      Note: This is less restrictive than the isAuthenticated() since it only assumes the user is who they say they are, either via a current session login or via Remember Me services, which makes no guarantee the user is who they say they are. The isAuthenticated() however guarantees that the current user has logged in during their current session, proving they really are who they say they are.

      The logically opposite method of this one is the isGuest().

    • isGuest

      boolean isGuest()
      Return true if the current user is not known to the system, either because they haven't logged in yet, or because they have no 'RememberMe' identity.

      The logically opposite method of this one is the isUser(). Please read that class's JavaDoc as it explains more about the differences between Authenticated/Unauthenticated and User/Guest semantic differences.

    • hasAnyRoles

      boolean hasAnyRoles(String roles)
      Return true if the current user has any of the roles specified.
    • hasAllRoles

      boolean hasAllRoles(String roles)
    • hasPermission

      boolean hasPermission(String permission)
    • hasAnyPermissions

      boolean hasAnyPermissions(String permissions)
    • hasAllPermissions

      boolean hasAllPermissions(String permissions)
    • hasRole

      boolean hasRole(String role)
    • isLacksPermission

      boolean isLacksPermission(String permission)
    • isLacksRole

      boolean isLacksRole(String role)
    • invokeWithSecurityDisabled

      <T> T invokeWithSecurityDisabled(Callable<T> callable) throws Exception
      Temporarily disable security before invocation of Callable.
      Parameters:
      callable - A callable that will be invoked with security disabled
      Returns:
      Throws:
      Exception