Interface CurrentAuthentication

All Known Implementing Classes:
CurrentAuthenticationImpl

public interface CurrentAuthentication
Provides information about the currently authenticated user.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.security.core.Authentication
    Returns current authentication object.
     
     
    org.springframework.security.core.userdetails.UserDetails
    Returns the authenticated user.
    org.springframework.security.core.userdetails.UserDetails
    Returns the authenticated user using hints.
    boolean
     
  • Method Details

    • getAuthentication

      org.springframework.security.core.Authentication getAuthentication()
      Returns current authentication object.
      Throws:
      IllegalStateException - if Authentication is not set to SecurityContext
    • getUser

      org.springframework.security.core.userdetails.UserDetails getUser()
      Returns the authenticated user. If you need to get the user substitution information use the CurrentUserSubstitution.
      Returns:
      currently authenticated user
      Throws:
      RuntimeException - if Authentication is not set to SecurityContext or user information cannot be extracted from current authentication
    • getUser

      org.springframework.security.core.userdetails.UserDetails getUser(Map<String,Object> hints)
      Returns the authenticated user using hints. If you need to get the user substitution information use the CurrentUserSubstitution. See supported hints in the CurrentUserHints.
      Parameters:
      hints - hints with user retrieval instructions
      Returns:
      currently authenticated user
      Throws:
      RuntimeException - if Authentication is not set to SecurityContext or user information cannot be extracted from current authentication
      See Also:
    • getLocale

      Locale getLocale()
      Returns:
      locale of the current authentication or default locale if current authentication doesn't contain locale information
      Throws:
      RuntimeException - if Authentication is not set to SecurityContext
    • getTimeZone

      TimeZone getTimeZone()
      Returns:
      time zone of the current authentication or default time zone if current authentication doesn't contain time zone information
      Throws:
      RuntimeException - if Authentication is not set to SecurityContext
    • isSet

      boolean isSet()
      Returns:
      true if authentication is set to SecurityContext