[R9] Get token subject method in Token Service class
This commit is contained in:
parent
82f0c58d5e
commit
52fc1655f3
@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.mirna.hospitalmanagementapi.application.usecase.auth.jwt.CreateJWTUseCase;
|
import com.mirna.hospitalmanagementapi.application.usecase.auth.jwt.CreateJWTUseCase;
|
||||||
|
import com.mirna.hospitalmanagementapi.application.usecase.auth.jwt.GetJWTSubjectUseCase;
|
||||||
import com.mirna.hospitalmanagementapi.domain.entities.auth.User;
|
import com.mirna.hospitalmanagementapi.domain.entities.auth.User;
|
||||||
import com.mirna.hospitalmanagementapi.domain.services.auth.jwt.TokenService;
|
import com.mirna.hospitalmanagementapi.domain.services.auth.jwt.TokenService;
|
||||||
|
|
||||||
@ -21,6 +22,9 @@ public class TokenServiceImpl implements TokenService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CreateJWTUseCase createJWT;
|
private CreateJWTUseCase createJWT;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GetJWTSubjectUseCase getJWTSubject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the authorization token
|
* Generates the authorization token
|
||||||
*
|
*
|
||||||
@ -31,5 +35,16 @@ public class TokenServiceImpl implements TokenService {
|
|||||||
public String generateToken(User user) {
|
public String generateToken(User user) {
|
||||||
return createJWT.execute(user);
|
return createJWT.execute(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the jwt subject
|
||||||
|
*
|
||||||
|
* @param token The json web token on request header
|
||||||
|
* @return A string containing the subject from the decoded jwt
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTokenSubject(String token) {
|
||||||
|
return getJWTSubject.execute(token);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,5 +17,13 @@ public interface TokenService {
|
|||||||
* @returns A string containing the authorization token
|
* @returns A string containing the authorization token
|
||||||
*/
|
*/
|
||||||
public String generateToken(User user);
|
public String generateToken(User user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the jwt subject
|
||||||
|
*
|
||||||
|
* @param token The json web token on request header
|
||||||
|
* @return A string containing the subject from the decoded jwt
|
||||||
|
*/
|
||||||
|
public String getTokenSubject(String token);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user