Skip to content

Commit

Permalink
#33 [feat] : 업비트 주문 요청 Jwt 토큰 발급 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbang105 committed Jun 16, 2024
1 parent ecb4fa6 commit 808d68c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions backend/src/main/java/org/dgu/backend/util/JwtUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ public String generateUpbitToken(UpbitKey upbitKey) {
.compact();
}

// 업비트 주문 요청 위한 토큰을 발급하는 메서드
public String generateUpbitOrderToken(UpbitKey upbitKey, String queryHash) {
PrivateKey privateKey = encryptionUtil.getDecryptedPrivateKey(upbitKey.getPrivateKey());
String accessKey = encryptionUtil.decryptAndEncode(upbitKey.getAccessKey(), privateKey);
String secretKey = encryptionUtil.decryptAndEncode(upbitKey.getSecretKey(), privateKey);

log.info("업비트 주문 요청 API 토큰이 발행되었습니다.");

return Jwts.builder()
.claim("access_key", accessKey)
.claim("nonce", UUID.randomUUID().toString())
.claim("query_hash", queryHash)
.claim("query_hash_alg", "SHA512")
.signWith(getUpbitSigningKey(secretKey))
.compact();
}

// 응답 헤더에서 액세스 토큰을 반환하는 메서드
public String getTokenFromHeader(String authorizationHeader) {
return authorizationHeader.substring(7);
Expand Down

0 comments on commit 808d68c

Please sign in to comment.