Interface SecurityService

All Known Implementing Classes:
DefaultSecurityService

public interface SecurityService
Provides a set of convenient methods related to authentication and authorization.
Since:
1.0
Author:
Sergio del Amo
  • Method Details

    • username

      Optional<String> username()
      Get the username of the current user.
      Returns:
      the username of the current user or Optional.empty if not authenticated
    • getAuthentication

      Optional<Authentication> getAuthentication()
      Retrieves Authentication if authenticated.
      Returns:
      the Authentication of the current user
    • isAuthenticated

      boolean isAuthenticated()
      Check if a user is authenticated.
      Returns:
      true if the user is authenticated, false otherwise
    • hasRole

      boolean hasRole(String role)
      If the current user has a specific role.
      Parameters:
      role - the role to check
      Returns:
      true if the current user has the role, false otherwise