Skip to content

Commit

Permalink
fix: subordinate jwks
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Oct 20, 2024
1 parent 9f1d298 commit ec4d470
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.sphereon.oid.fed.server.admin.controllers

import com.sphereon.oid.fed.openapi.models.CreateSubordinateDTO
import com.sphereon.oid.fed.openapi.models.SubordinateAdminDTO
import com.sphereon.oid.fed.openapi.models.SubordinateAdminJwkDto
import com.sphereon.oid.fed.openapi.models.SubordinateJwkDto
import com.sphereon.oid.fed.openapi.models.SubordinateStatement
import com.sphereon.oid.fed.persistence.models.Subordinate
import com.sphereon.oid.fed.services.SubordinateService
Expand Down Expand Up @@ -40,15 +40,15 @@ class SubordinateController {
@PathVariable accountUsername: String,
@PathVariable id: Int,
@RequestBody jwk: JsonObject
): SubordinateAdminJwkDto {
): SubordinateJwkDto {
return subordinateService.createSubordinateJwk(accountUsername, id, jwk)
}

@GetMapping("/{id}/jwks")
fun getSubordinateJwks(
@PathVariable accountUsername: String,
@PathVariable id: Int
): Array<SubordinateAdminJwkDto> {
): Array<SubordinateJwkDto> {
return subordinateService.getSubordinateJwks(accountUsername, id)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.sphereon.oid.fed.services
import com.sphereon.oid.fed.common.builder.SubordinateStatementBuilder
import com.sphereon.oid.fed.openapi.models.CreateSubordinateDTO
import com.sphereon.oid.fed.openapi.models.JWTHeader
import com.sphereon.oid.fed.openapi.models.SubordinateAdminJwkDto
import com.sphereon.oid.fed.openapi.models.SubordinateJwkDto
import com.sphereon.oid.fed.openapi.models.SubordinateMetadataDTO
import com.sphereon.oid.fed.openapi.models.SubordinateStatement
import com.sphereon.oid.fed.persistence.Persistence
Expand Down Expand Up @@ -123,7 +123,7 @@ class SubordinateService {
return jwt
}

fun createSubordinateJwk(accountUsername: String, id: Int, jwk: JsonObject): SubordinateAdminJwkDto {
fun createSubordinateJwk(accountUsername: String, id: Int, jwk: JsonObject): SubordinateJwkDto {
val account = accountQueries.findByUsername(accountUsername).executeAsOneOrNull()
?: throw IllegalArgumentException(Constants.ACCOUNT_NOT_FOUND)

Expand All @@ -138,7 +138,7 @@ class SubordinateService {
.toSubordinateAdminJwkDTO()
}

fun getSubordinateJwks(accountUsername: String, id: Int): Array<SubordinateAdminJwkDto> {
fun getSubordinateJwks(accountUsername: String, id: Int): Array<SubordinateJwkDto> {
val account = accountQueries.findByUsername(accountUsername).executeAsOneOrNull()
?: throw IllegalArgumentException(Constants.ACCOUNT_NOT_FOUND)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.sphereon.oid.fed.services.extensions

import com.sphereon.oid.fed.openapi.models.Jwk
import com.sphereon.oid.fed.openapi.models.JwkDTO
import com.sphereon.oid.fed.openapi.models.SubordinateAdminJwkDto
import com.sphereon.oid.fed.openapi.models.SubordinateJwkDto
import com.sphereon.oid.fed.persistence.models.SubordinateJwk
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.jsonObject
Expand All @@ -15,13 +14,13 @@ fun SubordinateJwk.toJwk(): Jwk {
return json.decodeFromString<Jwk>(this.key)
}

fun SubordinateJwk.toJwkDto(): JwkDTO {
return json.decodeFromString<JwkDTO>(this.key)
fun SubordinateJwk.toSubordinateJwkDto(): SubordinateJwkDto {
return json.decodeFromString<SubordinateJwkDto>(this.key)
}


fun SubordinateJwk.toSubordinateAdminJwkDTO(): SubordinateAdminJwkDto {
return SubordinateAdminJwkDto(
fun SubordinateJwk.toSubordinateAdminJwkDTO(): SubordinateJwkDto {
return SubordinateJwkDto(
id = this.id,
subordinateId = this.subordinate_id,
key = Json.parseToJsonElement(this.key).jsonObject,
Expand Down

0 comments on commit ec4d470

Please sign in to comment.