[R9] Token service class with generate token method
This commit is contained in:
parent
616722423d
commit
723a7981ea
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user