diff --git a/src/main/java/com/mirna/hospitalmanagementapi/application/services/auth/jwt/TokenServiceImpl.java b/src/main/java/com/mirna/hospitalmanagementapi/application/services/auth/jwt/TokenServiceImpl.java new file mode 100644 index 0000000..bf0383f --- /dev/null +++ b/src/main/java/com/mirna/hospitalmanagementapi/application/services/auth/jwt/TokenServiceImpl.java @@ -0,0 +1,35 @@ +package com.mirna.hospitalmanagementapi.application.services.auth.jwt; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.mirna.hospitalmanagementapi.application.usecase.auth.jwt.CreateJWTUseCase; +import com.mirna.hospitalmanagementapi.domain.entities.auth.User; +import com.mirna.hospitalmanagementapi.domain.services.auth.jwt.TokenService; + +/** + * This class is an implementation of the TokenService interface. + * + * This class provides methods to perform operations using the jwt (json web token) feature + * + * @author Mirna Gama + * @version 1.0 + */ +@Service +public class TokenServiceImpl implements TokenService { + + @Autowired + private CreateJWTUseCase createJWT; + + /** + * Generates the authorization token + * + * @param user The authenticated user + * @returns A string containing the authorization token + */ + @Override + public String generateToken(User user) { + return createJWT.execute(user); + } + +} diff --git a/src/main/java/com/mirna/hospitalmanagementapi/domain/services/auth/jwt/TokenService.java b/src/main/java/com/mirna/hospitalmanagementapi/domain/services/auth/jwt/TokenService.java new file mode 100644 index 0000000..0dbef6c --- /dev/null +++ b/src/main/java/com/mirna/hospitalmanagementapi/domain/services/auth/jwt/TokenService.java @@ -0,0 +1,21 @@ +package com.mirna.hospitalmanagementapi.domain.services.auth.jwt; + +import com.mirna.hospitalmanagementapi.domain.entities.auth.User; + +/** + * Token service interface for managing the jwt feature + * + * @author Mirna Gama + * @version 1.0 + */ +public interface TokenService { + + /** + * Generates the authorization token + * + * @param user The authenticated user + * @returns A string containing the authorization token + */ + public String generateToken(User user); + +}