Return sector 3 payload blocks in card prepare
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
This commit is contained in:
@@ -74,9 +74,9 @@ class IssuedCards(
|
||||
timeData = payload.timeData,
|
||||
issuedAt = issuedAt.toString(),
|
||||
expiresAt = expiresAt.toString(),
|
||||
issuerUserId = actor.id,
|
||||
issuerFirebaseUid = actor.firebaseUid,
|
||||
issuerName = actor.name
|
||||
sector3Block0 = encodeBlock(actor.name),
|
||||
sector3Block1 = encodeBlock(actor.id?.toString()),
|
||||
sector3Block2 = encodeBlock(null)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -183,6 +183,16 @@ class IssuedCards(
|
||||
return OffsetDateTime.now(zone)
|
||||
}
|
||||
|
||||
private fun encodeBlock(value: String?): String {
|
||||
val raw = (value ?: "").padEnd(16).take(16)
|
||||
val bytes = raw.toByteArray(Charsets.UTF_8)
|
||||
val sb = StringBuilder(bytes.size * 2)
|
||||
for (b in bytes) {
|
||||
sb.append(String.format("%02X", b))
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
private fun requireMember(propertyId: UUID, principal: MyPrincipal?) {
|
||||
if (principal == null) {
|
||||
throw ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing principal")
|
||||
|
||||
Reference in New Issue
Block a user