Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2710997
commit 9971eba
Showing
13 changed files
with
230 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...n/io/iohk/atala/prism/walletsdk/prismagent/protocols/revocation/RevocationNotification.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.iohk.atala.prism.walletsdk.prismagent.protocols.revocation | ||
|
||
import io.iohk.atala.prism.walletsdk.domain.models.DID | ||
import io.iohk.atala.prism.walletsdk.domain.models.Message | ||
import io.iohk.atala.prism.walletsdk.prismagent.PrismAgentError | ||
import io.iohk.atala.prism.walletsdk.prismagent.protocols.ProtocolType | ||
import kotlinx.serialization.SerialName | ||
import java.util.UUID | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.encodeToString | ||
import kotlinx.serialization.json.Json | ||
|
||
class RevocationNotification( | ||
val id: String = UUID.randomUUID().toString(), | ||
val body: Body, | ||
val from: DID, | ||
val to: DID | ||
) { | ||
val type = ProtocolType.PrismRevocation | ||
|
||
fun makeMessage(): Message { | ||
return Message( | ||
id = id, | ||
piuri = type.value, | ||
from = from, | ||
to = to, | ||
body = Json.encodeToString(body) | ||
) | ||
} | ||
|
||
@Serializable | ||
data class Body @JvmOverloads constructor( | ||
@SerialName("issueCredentialProtocolThreadId") | ||
val threadId: String, | ||
val comment: String? | ||
) | ||
|
||
companion object { | ||
fun fromMessage(message: Message): RevocationNotification { | ||
require( | ||
message.piuri == ProtocolType.PrismRevocation.value && | ||
message.from != null && | ||
message.to != null | ||
) { | ||
throw PrismAgentError.InvalidMessageType( | ||
type = message.piuri, | ||
shouldBe = ProtocolType.PrismRevocation.value | ||
) | ||
} | ||
return RevocationNotification( | ||
body = Json.decodeFromString(message.body), | ||
from = message.from, | ||
to = message.to | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.