Class JwtAuthenticationProvider

java.lang.Object
org.localify.auth.jwt.JwtAuthenticationProvider
All Implemented Interfaces:
org.springframework.security.authentication.AuthenticationProvider

public class JwtAuthenticationProvider extends Object implements org.springframework.security.authentication.AuthenticationProvider
An AuthenticationProvider that authenticates a JwtAuthenticationRequest. This provider uses a JwtService to validate the JWT and extract the user's details.
  • Constructor Details

    • JwtAuthenticationProvider

      public JwtAuthenticationProvider(JwtService jwtService)
      Constructs a new JwtAuthenticationProvider.
      Parameters:
      jwtService - The JWT service to use for token validation.
  • Method Details

    • authenticate

      public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication auth) throws org.springframework.security.core.AuthenticationException
      Authenticates the given Authentication object.
      Specified by:
      authenticate in interface org.springframework.security.authentication.AuthenticationProvider
      Parameters:
      auth - The authentication request.
      Returns:
      An authenticated Authentication object if successful.
      Throws:
      org.springframework.security.core.AuthenticationException - if authentication fails.
    • parseUUID

      public static UUID parseUUID(String uuid)
      Parses a string to a UUID.
      Parameters:
      uuid - The string to parse.
      Returns:
      The UUID, or null if the string is not a valid UUID.
    • supports

      public boolean supports(Class<?> authentication)
      Specified by:
      supports in interface org.springframework.security.authentication.AuthenticationProvider