Skip to content

Commit

Permalink
#10 refactor: 코드 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
SunwoongH committed Dec 5, 2024
1 parent 5200430 commit ed7a37a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ object Versions {
const val SPRING_BOOT = "3.2.5"
const val SPRING_DEPENDENCY_MANAGEMENT = "1.1.5"
const val MYSQL = "8.0.33"
const val JJWT = "0.12.5"
const val JJWT = "0.12.6"
const val JDK = 17
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import java.security.Key
class JwtSecretKey(
private val secret: String,
) : SignatureKey {

override val key: Key by lazy {
Keys.hmacShaKeyFor(secret.toByteArray())
}
Expand Down
23 changes: 14 additions & 9 deletions support/jwt/src/main/kotlin/org/doorip/support/jwt/RSAPublicKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@ class RSAPublicKey(
private val e: String,
private val type: String,
) : SignatureKey {
override val key: Key by lazy {
val decoder = Base64.getUrlDecoder()

val nBytes = decoder.decode(n)
val eBytes = decoder.decode(e)
override val key: Key? by lazy {
try {
val decoder = Base64.getUrlDecoder()

val n = BigInteger(1, nBytes)
val e = BigInteger(1, eBytes)
val nBytes = decoder.decode(n)
val eBytes = decoder.decode(e)

val rsaPublicKeySpec = RSAPublicKeySpec(n, e)
val n = BigInteger(1, nBytes)
val e = BigInteger(1, eBytes)

val keyFactory = KeyFactory.getInstance(type)
val rsaPublicKeySpec = RSAPublicKeySpec(n, e)

keyFactory.generatePublic(rsaPublicKeySpec)
val keyFactory = KeyFactory.getInstance(type)

keyFactory.generatePublic(rsaPublicKeySpec)
} catch (e: Exception) {
null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package org.doorip.support.jwt
import java.security.Key

interface SignatureKey {
val key: Key
val key: Key?
}

0 comments on commit ed7a37a

Please sign in to comment.