Class AuthServiceImpl
java.lang.Object
com.example.blogs.app.api.auth.service.AuthServiceImpl
- All Implemented Interfaces:
AuthService
Orchestrates user authentication operations by coordinating password hashing, user validation, and token generation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlogin(LoginRequest loginRequest) Authenticates a user and generates JWT tokens.logout(LogoutRequest logoutRequest) Revokes a refresh token and invalidates all associated sessions.refreshAccessToken(RefreshTokenRequest tokenRequest) Refreshes an access token by validating the refresh token and generating a new access token.register(RegisterRequest registerRequest) Registers a new user and returns JWT tokens for immediate authentication.
-
Constructor Details
-
AuthServiceImpl
public AuthServiceImpl()
-
-
Method Details
-
register
Description copied from interface:AuthServiceRegisters a new user and returns JWT tokens for immediate authentication.- Specified by:
registerin interfaceAuthService- Parameters:
registerRequest- user registration details- Returns:
- access and refresh token pair
-
login
Description copied from interface:AuthServiceAuthenticates a user and generates JWT tokens.- Specified by:
loginin interfaceAuthService- Parameters:
loginRequest- user login credentials- Returns:
- access and refresh token pair
-
refreshAccessToken
Refreshes an access token by validating the refresh token and generating a new access token. Verifies that the token is valid, not expired, and is of type "refresh".- Specified by:
refreshAccessTokenin interfaceAuthService- Parameters:
tokenRequest- request containing the refresh token- Returns:
- new access token with user claims and updated expiration
- Throws:
UnauthorizedException- if refresh token is invalid, expired, or not a refresh token type
-
logout
Description copied from interface:AuthServiceRevokes a refresh token and invalidates all associated sessions.- Specified by:
logoutin interfaceAuthService- Parameters:
logoutRequest- request containing the refresh token to revoke- Returns:
- persisted revoked token entity
-