Interface AdvancedAuthentication

  • All Superinterfaces:
    org.springframework.security.core.Authentication, Principal, Serializable
    All Known Implementing Classes:
    DefaultAuthentication

    public interface AdvancedAuthentication
    extends org.springframework.security.core.Authentication
    Extends Authentication with advanced features.
    Since:
    2020.04.001
    • Method Detail

      • getAttribute

        default <T> T getAttribute​(String key)
        Type Parameters:
        T - type of the expected return type.
        Parameters:
        key - the key of the requested attribute.
        Returns:
        the attribute for the given key or null if not present.
      • setAttribute

        default void setAttribute​(String key,
                                  Object value)
        Parameters:
        key - the key to set. May not be null.
        value - the value to set. May not be null.
      • getPermissions

        Set<String> getPermissions()
        Returns:
        the authorities as a Set of flat Strings. Allows to improve performance of of checks if permissions are present or not.
        See Also:
        hasPermission(String)
      • hasPermission

        default boolean hasPermission​(String permission)
        Parameters:
        permission - the identifier of the permission to check.
        Returns:
        true if the current user represented by this Authentication has the given permission, false otherwise.
      • hasPermission

        static boolean hasPermission​(org.springframework.security.core.Authentication authentication,
                                     String permission)
        Parameters:
        authentication - the Authentication to check.
        permission - the identifier of the permission to check.
        Returns:
        true if the current user represented by the given Authentication has the given permission, false otherwise.
      • getPermissions

        static Set<String> getPermissions​(org.springframework.security.core.Authentication authentication)
        Parameters:
        authentication - the Authentication.
        Returns:
        the permissions.