Skip to content

Commit

Permalink
update for new JWT API
Browse files Browse the repository at this point in the history
  • Loading branch information
ekoby committed Feb 16, 2024
1 parent c0a7fdc commit 2aa4c0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ziti/src/main/kotlin/org/openziti/identity/ZitiJWT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ZitiJWT(cl: Claims, val serverKey: Key) {
fun fromJWT(jwt: String): ZitiJWT {
val tm = JwtTrustManager()

val jwtParser = Jwts.parserBuilder()
val jwtParser = Jwts.parser()
.setSigningKeyResolver(KeyResolver(tm)).build()

val claims = jwtParser.parse(jwt).body as Claims
Expand All @@ -74,12 +74,12 @@ class ZitiJWT(cl: Claims, val serverKey: Key) {

class KeyResolver(val tm: JwtTrustManager) : SigningKeyResolver {

override fun resolveSigningKey(header: JwsHeader<*>, claims: Claims): Key? {
override fun resolveSigningKey(header: JwsHeader, claims: Claims): Key {
val ssl = SSLContext.getInstance("TLSv1.2").apply {
init(null, arrayOf(tm), SecureRandom())
}

val url = URI.create(claims.get("iss").toString()).toURL()
val url = URI.create(claims["iss"].toString()).toURL()
val conn = url.openConnection() as HttpsURLConnection
conn.sslSocketFactory = ssl.socketFactory

Expand All @@ -92,6 +92,6 @@ class ZitiJWT(cl: Claims, val serverKey: Key) {
}

// this is not used
override fun resolveSigningKey(header: JwsHeader<*>, plaintext: String) = TODO()
override fun resolveSigningKey(header: JwsHeader?, content: ByteArray?) = TODO()
}
}
3 changes: 3 additions & 0 deletions ziti/src/test/kotlin/org/openziti/identity/EnrollTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class EnrollTest {
kotlin.runCatching {
ZitiTestHelper.init()
}.onSuccess { initSuccess = true }
.onFailure { ex ->
ex.printStackTrace()
}
}

@AfterClass
Expand Down

0 comments on commit 2aa4c0e

Please sign in to comment.