diff --git a/ariesframework/src/androidTest/java/org/hyperledger/ariesframework/agent/AgentTest.kt b/ariesframework/src/androidTest/java/org/hyperledger/ariesframework/agent/AgentTest.kt index 4ae10fd..0da3842 100644 --- a/ariesframework/src/androidTest/java/org/hyperledger/ariesframework/agent/AgentTest.kt +++ b/ariesframework/src/androidTest/java/org/hyperledger/ariesframework/agent/AgentTest.kt @@ -184,7 +184,7 @@ class AgentTest { agent = alice alice.initialize() - val faberConfig = TestHelper.getBaseConfig() + val faberConfig = TestHelper.getBaseConfig("faber") faberConfig.mediatorPickupStrategy = MediatorPickupStrategy.Implicit faberConfig.mediatorConnectionsInvite = publicMediatorUrl faberConfig.mediatorPollingInterval = 1 @@ -192,7 +192,7 @@ class AgentTest { val faber = Agent(context, faberConfig) faber.initialize() - val (aliceConnection, faberConnection) = TestHelper.makeConnection(alice, faber, 2.seconds) + val (aliceConnection, faberConnection) = TestHelper.makeConnection(alice, faber, 3.seconds) assertEquals(aliceConnection.state, ConnectionState.Complete) assertEquals(faberConnection.state, ConnectionState.Complete) diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/MessageSender.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/MessageSender.kt index f73a380..23fca0d 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/MessageSender.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/MessageSender.kt @@ -116,7 +116,7 @@ class MessageSender(val agent: Agent) { return listOf(service) } if (connection.outOfBandInvitation != null) { - return connection.outOfBandInvitation!!.services.mapNotNull { it.asDidDocService() as DidComm } + return connection.outOfBandInvitation!!.services.mapNotNull { it.asDidCommService() } } } diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/WsOutboundTransport.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/WsOutboundTransport.kt index 835aac5..e61def3 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/WsOutboundTransport.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/agent/WsOutboundTransport.kt @@ -56,7 +56,7 @@ class WsOutboundTransport(val agent: Agent) : OutboundTransport, WebSocketListen } override fun onMessage(webSocket: WebSocket, text: String) { - logger.debug("Received message: {}", text) + logger.debug("Agent ${agent.agentConfig.label} received a message string") val encryptedMessage = Json.decodeFromString(text) GlobalScope.launch { agent.receiveMessage(encryptedMessage) @@ -64,7 +64,7 @@ class WsOutboundTransport(val agent: Agent) : OutboundTransport, WebSocketListen } override fun onMessage(webSocket: WebSocket, bytes: ByteString) { - logger.debug("Received message: {}", bytes.utf8()) + logger.debug("Agent ${agent.agentConfig.label} received a message bytes.") val encryptedMessage = Json.decodeFromString(bytes.utf8()) GlobalScope.launch { agent.receiveMessage(encryptedMessage) diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidCommService.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidCommService.kt index 14004d4..5d5755e 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidCommService.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidCommService.kt @@ -12,4 +12,4 @@ open class DidCommService( override val routingKeys: List? = null, override val priority: Int? = 0, override val accept: List? = null, -) : DidComm +) : DidDocService(), DidComm diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocService.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocService.kt index baaf1f3..1ac5f62 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocService.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocService.kt @@ -1,15 +1,19 @@ package org.hyperledger.ariesframework.connection.models.didauth +import kotlinx.serialization.Serializable import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.polymorphic import kotlinx.serialization.modules.subclass -interface DidDocService { - val id: String - val serviceEndpoint: String +@Serializable +sealed class DidDocService { + abstract val id: String + abstract val serviceEndpoint: String } -interface DidComm : DidDocService { +interface DidComm { + val id: String + val serviceEndpoint: String val recipientKeys: List val routingKeys: List? val priority: Int? diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocumentService.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocumentService.kt index 3a1966d..380c415 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocumentService.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/DidDocumentService.kt @@ -8,4 +8,4 @@ import kotlinx.serialization.Serializable class DidDocumentService( override val id: String, override val serviceEndpoint: String, -) : DidDocService +) : DidDocService() diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/IndyAgentService.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/IndyAgentService.kt index 6c3c91f..fdedea2 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/IndyAgentService.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/connection/models/didauth/IndyAgentService.kt @@ -12,4 +12,4 @@ class IndyAgentService( override val routingKeys: List? = null, override val priority: Int? = 0, override val accept: List? = null, -) : DidComm +) : DidDocService(), DidComm diff --git a/ariesframework/src/main/java/org/hyperledger/ariesframework/oob/models/OutOfBandDidCommService.kt b/ariesframework/src/main/java/org/hyperledger/ariesframework/oob/models/OutOfBandDidCommService.kt index 18296e7..0001d7c 100644 --- a/ariesframework/src/main/java/org/hyperledger/ariesframework/oob/models/OutOfBandDidCommService.kt +++ b/ariesframework/src/main/java/org/hyperledger/ariesframework/oob/models/OutOfBandDidCommService.kt @@ -16,7 +16,7 @@ import org.hyperledger.ariesframework.util.DIDParser @Serializable(with = OutOfBandDidCommServiceSerializer::class) abstract class OutOfBandDidCommService { - abstract fun asDidDocService(): DidDocService? + abstract fun asDidCommService(): DidCommService? } object OutOfBandDidCommServiceSerializer : JsonContentPolymorphicSerializer(OutOfBandDidCommService::class) { @@ -35,7 +35,7 @@ class OutOfBandDidDocumentService( val routingKeys: List? = null, val accept: List? = null, ) : OutOfBandDidCommService() { - override fun asDidDocService(): DidDocService? { + override fun asDidCommService(): DidCommService? { return DidCommService( id, serviceEndpoint, @@ -49,7 +49,7 @@ class OutOfBandDidDocumentService( class PublicDidService( val did: String, ) : OutOfBandDidCommService() { - override fun asDidDocService(): DidDocService? { + override fun asDidCommService(): DidCommService? { return null } } diff --git a/ariesframework/src/test/java/org/hyperledger/ariesframework/SerializationTest.kt b/ariesframework/src/test/java/org/hyperledger/ariesframework/SerializationTest.kt index c7d596d..b754bd2 100644 --- a/ariesframework/src/test/java/org/hyperledger/ariesframework/SerializationTest.kt +++ b/ariesframework/src/test/java/org/hyperledger/ariesframework/SerializationTest.kt @@ -11,6 +11,7 @@ import kotlinx.serialization.json.jsonPrimitive import kotlinx.serialization.modules.SerializersModule import kotlinx.serialization.modules.polymorphic import kotlinx.serialization.modules.subclass +import org.hyperledger.ariesframework.connection.models.didauth.DidDocService import org.hyperledger.ariesframework.proofs.models.RequestedCredentials import org.hyperledger.ariesframework.util.concurrentForEach import org.hyperledger.ariesframework.util.concurrentMap @@ -29,6 +30,14 @@ sealed class Service { abstract val id: String } +interface DidComm { + val id: String + val serviceEndpoint: String + val recipientKeys: List + val routingKeys: List? + val priority: Int? +} + @Serializable @SerialName("DidDocumentService") data class Service1( @@ -40,11 +49,11 @@ data class Service1( @SerialName("IndyAgent") data class Service2( override val id: String, - val serviceEndpoint: String, - val recipientKeys: List, - val routingKeys: List, - val priority: Int, -) : Service() + override val serviceEndpoint: String, + override val recipientKeys: List, + override val routingKeys: List, + override val priority: Int, +) : Service(), DidComm @Serializable @SerialName("did-communication")