Skip to content

Commit

Permalink
add additional data to credential request parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
iaik-jheher committed Aug 31, 2023
1 parent d408fa4 commit 14dc500
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ data class CredentialRequestParameters(
@SerialName("claims")
val claims: Map<String, Map<String, RequestedCredentialClaimSpecification>>? = null,

@SerialName("additionalData")
val additionalData: Map<String, String> = emptyMap(),

/**
* OID4VCI:
* OPTIONAL. JSON object containing proof of possession of the key material the issued Credential shall be bound to.
Expand All @@ -69,6 +72,7 @@ data class CredentialRequestParameters(
if (!types.contentEquals(other.types)) return false
if (docType != other.docType) return false
if (claims != other.claims) return false
if (additionalData != other.additionalData) return false
return proof == other.proof
}

Expand All @@ -77,6 +81,7 @@ data class CredentialRequestParameters(
result = 31 * result + types.contentHashCode()
result = 31 * result + (docType?.hashCode() ?: 0)
result = 31 * result + (claims?.hashCode() ?: 0)
result = 31 * result + (additionalData?.hashCode() ?: 0)
result = 31 * result + (proof?.hashCode() ?: 0)
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class IssuerService(
CoseEllipticCurve.P256,
subjectPublicKey.toAnsiX963ByteArray().getOrThrow()
),
attributeTypes = params.types.toList()
attributeTypes = params.types.toList(),
additionalData = params.additionalData
)
if (issuedCredentialResult.successful.isEmpty()) {
throw OAuth2Exception(Errors.INVALID_REQUEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ interface Issuer {
suspend fun issueCredentialWithTypes(
subjectId: String,
subjectPublicKey: CoseKey? = null,
attributeTypes: Collection<String>
attributeTypes: Collection<String>,
additionalData: Map<String, String> = emptyMap()
): IssuedCredentialResult

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ class IssuerAgent(
override suspend fun issueCredentialWithTypes(
subjectId: String,
subjectPublicKey: CoseKey?,
attributeTypes: Collection<String>
attributeTypes: Collection<String>,
additionalData: Map<String, String>
): Issuer.IssuedCredentialResult {
val result = dataProvider.getCredentialWithType(subjectId, subjectPublicKey, attributeTypes)
val result = dataProvider.getCredentialWithType(subjectId, subjectPublicKey, attributeTypes, additionalData)
result.exceptionOrNull()?.let { failure ->
return Issuer.IssuedCredentialResult(failed = attributeTypes.map { Issuer.FailedAttribute(it, failure) })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ interface IssuerCredentialDataProvider {
fun getCredentialWithType(
subjectId: String,
subjectPublicKey: CoseKey? = null,
attributeTypes: Collection<String>
attributeTypes: Collection<String>,
additionalData: Map<String, String> = emptyMap()
): KmmResult<List<CredentialToBeIssued>>

}
Expand Down

0 comments on commit 14dc500

Please sign in to comment.