Class TokenPairGeneratorImpl

java.lang.Object
com.example.blogs.app.api.auth.service.TokenPairGeneratorImpl
All Implemented Interfaces:
TokenPairGenerator

@Component public class TokenPairGeneratorImpl extends Object implements TokenPairGenerator
Creates JWT token pairs with embedded user claims for access and refresh authentication flows.
  • Constructor Details

    • TokenPairGeneratorImpl

      public TokenPairGeneratorImpl()
  • Method Details

    • generateTokens

      public TokenPair generateTokens(UserEntity user)
      Generates a complete token pair containing access and refresh tokens for the user. Uses UUID-based JTI as the JWT subject claim for token identification.
      Specified by:
      generateTokens in interface TokenPairGenerator
      Parameters:
      user - the user entity to generate tokens for
      Returns:
      token pair with access and refresh tokens containing user claims
    • createClaims

      public Map<String,Object> createClaims(UserEntity user, String type)
      Creates JWT claims map from user entity data with token type.
      Specified by:
      createClaims in interface TokenPairGenerator
      Parameters:
      user - the user entity to extract claims from
      type - the token type ("access" or "refresh")
      Returns:
      map of claims including id, username, email, profilePictureUrl, and type