Package org.localify.auth.jwt
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 Summary
ConstructorsConstructorDescriptionJwtAuthenticationProvider(JwtService jwtService) Constructs a new JwtAuthenticationProvider. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.core.Authenticationauthenticate(org.springframework.security.core.Authentication auth) Authenticates the givenAuthenticationobject.static UUIDParses a string to a UUID.boolean
-
Constructor Details
-
JwtAuthenticationProvider
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 givenAuthenticationobject.- Specified by:
authenticatein interfaceorg.springframework.security.authentication.AuthenticationProvider- Parameters:
auth- The authentication request.- Returns:
- An authenticated
Authenticationobject if successful. - Throws:
org.springframework.security.core.AuthenticationException- if authentication fails.
-
parseUUID
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
- Specified by:
supportsin interfaceorg.springframework.security.authentication.AuthenticationProvider
-