You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/08/02 04:44:12 UTC
[camel] branch main updated: CAMEL-18332: [camel-hyperledger-aries] Upgrade to nessus-aries-0.2.0 (#8088)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 5f4ef404355 CAMEL-18332: [camel-hyperledger-aries] Upgrade to nessus-aries-0.2.0 (#8088)
5f4ef404355 is described below
commit 5f4ef404355e1f87a16f7eb123b8d418e6c29c7d
Author: Thomas Diesler <td...@redhat.com>
AuthorDate: Tue Aug 2 06:44:06 2022 +0200
CAMEL-18332: [camel-hyperledger-aries] Upgrade to nessus-aries-0.2.0 (#8088)
---
camel-dependencies/pom.xml | 2 +-
.../apache/camel/catalog/schemas/camel-spring.xsd | 2 +-
.../component/aries/HyperledgerAriesComponent.java | 47 ++--
.../component/aries/HyperledgerAriesEndpoint.java | 5 +-
.../aries/handler/AbstractServiceHandler.java | 5 -
.../aries/handler/MultitenancyServiceHandler.java | 20 +-
.../aries/processor/AbstractAriesProcessor.java | 57 -----
.../aries/processor/ConnectionProcessor.java | 88 -------
.../processor/V1CredentialEventProcessor.java | 89 -------
.../component/aries/AbstractCamelAriesTest.java | 15 +-
.../component/aries/CamelGettingStartedTest.java | 260 ++++++++++++---------
.../aries/CredentialOfferRequestIssueTest.java | 125 ----------
.../camel/component/aries/PeerConnectionTest.java | 89 -------
.../src/test/resources/log4j2.properties | 2 +-
parent/pom.xml | 2 +-
15 files changed, 185 insertions(+), 623 deletions(-)
diff --git a/camel-dependencies/pom.xml b/camel-dependencies/pom.xml
index 0f52dfcbe62..5fb29c69bec 100644
--- a/camel-dependencies/pom.xml
+++ b/camel-dependencies/pom.xml
@@ -422,7 +422,7 @@
<mybatis-version>3.5.10</mybatis-version>
<narayana-version>5.12.7.Final</narayana-version>
<neoscada-version>0.4.0</neoscada-version>
- <nessus-hyperledger-aries-version>0.1.1</nessus-hyperledger-aries-version>
+ <nessus-hyperledger-aries-version>0.2.0</nessus-hyperledger-aries-version>
<nessus-ipfs-version>1.0.0.Beta4</nessus-ipfs-version>
<nessus-weka-version>1.0.1</nessus-weka-version>
<netty-reactive-streams-version>2.0.5</netty-reactive-streams-version>
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 72a58fdca1b..b8ea5569626 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -392,7 +392,7 @@ Enriches a message with data from a secondary resource
<xs:element name="errorHandler" nillable="true" type="xs:anyType">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
-Camel error handling.
+Error handler settings
]]></xs:documentation>
</xs:annotation>
</xs:element>
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesComponent.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesComponent.java
index a50d1b73b6d..ff6f2c30256 100644
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesComponent.java
+++ b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesComponent.java
@@ -22,26 +22,21 @@ import java.util.Map;
import io.nessus.aries.AgentConfiguration;
import io.nessus.aries.AriesClientFactory;
-import io.nessus.aries.util.AssertArg;
import io.nessus.aries.util.AssertState;
-import io.nessus.aries.wallet.DefaultEventHandler;
import io.nessus.aries.wallet.NessusWallet;
import io.nessus.aries.wallet.WalletRegistry;
+import io.nessus.aries.websocket.WebSocketClient;
+import io.nessus.aries.websocket.WebSocketListener;
import org.apache.camel.Endpoint;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
import org.hyperledger.aries.AriesClient;
-import org.hyperledger.aries.AriesWebSocketClient;
-import org.hyperledger.aries.api.multitenancy.WalletRecord;
-import org.hyperledger.aries.api.multitenancy.WalletRecord.WalletSettings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
@Component("hyperledger-aries")
public class HyperledgerAriesComponent extends DefaultComponent {
- private static final Logger LOG = LoggerFactory.getLogger(HyperledgerAriesComponent.class);
+ // private static final Logger LOG = LoggerFactory.getLogger(HyperledgerAriesComponent.class);
private final WalletRegistry walletRegistry = new WalletRegistry();
private AgentConfiguration agentConfig;
@@ -50,7 +45,7 @@ public class HyperledgerAriesComponent extends DefaultComponent {
private boolean removeWalletsOnShutdown;
private AriesClient adminClient;
- private AriesWebSocketClient adminWebSocketClient;
+ private WebSocketClient adminWebSocketClient;
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
@@ -125,34 +120,22 @@ public class HyperledgerAriesComponent extends DefaultComponent {
return adminClient;
}
- public AriesWebSocketClient adminWebSocketClient() {
+ public AriesClient createClient(String walletName) throws IOException {
+ NessusWallet wallet = assertWallet(walletName);
+ AgentConfiguration agentConfig = getAgentConfiguration();
+ return AriesClientFactory.createClient(agentConfig, wallet);
+ }
+
+ public WebSocketClient adminWebSocketClient(WebSocketListener wslistener) {
if (adminWebSocketClient == null) {
- WalletSettings settings = new WalletSettings();
- settings.setWalletName("admin");
- WalletRecord adminRecord = NessusWallet.builder()
- .walletId("00000000")
- .settings(settings)
- .build();
- NessusWallet adminWallet = NessusWallet.build(adminRecord);
- String webSocketUrl = agentConfig.getWebSocketUrl();
- LOG.info("WebSocket connecting to {} ...", webSocketUrl);
- adminWebSocketClient = AriesWebSocketClient.builder()
- .url(webSocketUrl)
- .handler(new DefaultEventHandler(adminWallet, walletRegistry))
- .apiKey(agentConfig.getApiKey())
- .build();
+ adminWebSocketClient = new WebSocketClient(agentConfig, null);
+ adminWebSocketClient.openWebSocket(wslistener);
}
return adminWebSocketClient;
}
- public AriesClient createClient(WalletRecord walletRecord) throws IOException {
- AssertArg.notNull(walletRecord, "No WalletRecord");
- AgentConfiguration agentConfig = getAgentConfiguration();
- return AriesClientFactory.createClient(walletRecord, agentConfig);
- }
-
- public AriesWebSocketClient getWebSocketClient(String walletName) {
+ public WebSocketClient createWebSocketClient(String walletName, WebSocketListener wslistener) {
NessusWallet wallet = assertWallet(walletName);
- return wallet.getWebSocketClient();
+ return wallet.createWebSocketClient(getAgentConfiguration(), wslistener);
}
}
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesEndpoint.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesEndpoint.java
index ca70a69303c..0fccfb659ab 100644
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesEndpoint.java
+++ b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/HyperledgerAriesEndpoint.java
@@ -69,12 +69,11 @@ public class HyperledgerAriesEndpoint extends DefaultEndpoint {
}
public AriesClient createClient() throws IOException {
- NessusWallet wallet = getWallet();
String walletName = getWalletName();
- if (wallet == null && "admin".equals(walletName)) {
+ if (getWallet() == null && "admin".equals(walletName)) {
return getComponent().adminClient();
} else {
- return getComponent().createClient(wallet);
+ return getComponent().createClient(walletName);
}
}
}
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/AbstractServiceHandler.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/AbstractServiceHandler.java
index 8e16888a3b6..d3439b3aedb 100644
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/AbstractServiceHandler.java
+++ b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/AbstractServiceHandler.java
@@ -25,7 +25,6 @@ import org.apache.camel.component.aries.HyperledgerAriesComponent;
import org.apache.camel.component.aries.HyperledgerAriesConfiguration;
import org.apache.camel.component.aries.HyperledgerAriesEndpoint;
import org.hyperledger.aries.AriesClient;
-import org.hyperledger.aries.api.multitenancy.WalletRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -119,8 +118,4 @@ public abstract class AbstractServiceHandler implements ServiceHandler {
public AriesClient createClient() throws IOException {
return endpoint.createClient();
}
-
- public AriesClient createClient(WalletRecord walletRecord) throws IOException {
- return getComponent().createClient(walletRecord);
- }
}
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/MultitenancyServiceHandler.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/MultitenancyServiceHandler.java
index a2406b6dc21..97b17549cd7 100644
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/MultitenancyServiceHandler.java
+++ b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/handler/MultitenancyServiceHandler.java
@@ -55,12 +55,12 @@ public class MultitenancyServiceHandler extends AbstractServiceHandler {
String trusteeName = maybeHeader(exchange, HEADER_MULTITENANCY_TRUSTEE_WALLET, String.class);
WalletRegistry walletRegistry = getComponent().getWalletRegistry();
- WalletRecord walletResponse = adminClient().multitenancyWalletCreate(walletRequest).get();
- NessusWallet walletRecord = NessusWallet.build(walletResponse).withWalletRegistry(walletRegistry);
- getComponent().addWallet(walletRecord);
+ WalletRecord walletRecord = adminClient().multitenancyWalletCreate(walletRequest).get();
+ NessusWallet wallet = NessusWallet.build(walletRecord).withWalletRegistry(walletRegistry);
+ getComponent().addWallet(wallet);
- String walletId = walletRecord.getWalletId();
- log.info("{}: [{}] {}", walletName, walletId, walletRecord);
+ String walletId = wallet.getWalletId();
+ log.info("{}: [{}] {}", walletName, walletId, wallet);
if (ledgerRole != null) {
@@ -68,16 +68,13 @@ public class MultitenancyServiceHandler extends AbstractServiceHandler {
"LedgerRole " + ledgerRole + " requires selfRegister or trusteeWallet");
// Create a local DID for the wallet
- AriesClient client = createClient(walletRecord);
+ AriesClient client = getComponent().createClient(walletName);
DID did = client.walletDidCreate(WalletDIDCreate.builder().build()).get();
log.info("{}: {}", walletName, did);
if (trusteeName != null) {
- NessusWallet trusteeWallet = getComponent().getWallet(trusteeName);
- AssertState.notNull(trusteeWallet, "Cannot obtain trustee wallet: " + trusteeName);
-
- AriesClient trustee = createClient(trusteeWallet);
+ AriesClient trustee = getComponent().createClient(trusteeName);
TxnOrRegisterLedgerNymResponse nymResponse = trustee.ledgerRegisterNym(RegisterNymFilter.builder()
.did(did.getDid())
.verkey(did.getVerkey())
@@ -91,12 +88,13 @@ public class MultitenancyServiceHandler extends AbstractServiceHandler {
// Set the public DID for the wallet
client.walletDidPublic(did.getDid());
+ wallet.setPublicDid(did);
DIDEndpoint didEndpoint = client.walletGetDidEndpoint(did.getDid()).get();
log.info("{}: {}", walletName, didEndpoint);
}
- exchange.getIn().setBody(walletRecord);
+ exchange.getIn().setBody(wallet);
} else {
throw new UnsupportedServiceException(service);
}
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/AbstractAriesProcessor.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/AbstractAriesProcessor.java
deleted file mode 100644
index 9c266b2477e..00000000000
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/AbstractAriesProcessor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aries.processor;
-
-import io.nessus.aries.util.AssertState;
-import io.nessus.aries.wallet.NessusWallet;
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.component.aries.HyperledgerAriesComponent;
-
-import static org.apache.camel.component.aries.Constants.HEADER_WALLET_NAME;
-import static org.apache.camel.component.aries.Constants.HEADER_WALLET_RECORD;
-import static org.apache.camel.component.aries.Constants.PROPERTY_HYPERLEDGER_ARIES_COMPONENT;
-
-public abstract class AbstractAriesProcessor implements Processor {
-
- public static HyperledgerAriesComponent getAriesComponent(Exchange exchange) {
- HyperledgerAriesComponent component
- = exchange.getProperty(PROPERTY_HYPERLEDGER_ARIES_COMPONENT, HyperledgerAriesComponent.class);
- AssertState.notNull(component, "Cannot find exchange property: " + PROPERTY_HYPERLEDGER_ARIES_COMPONENT);
- return component;
- }
-
- public static String assertWalletName(Exchange exchange) {
- String walletName = exchange.getIn().getHeader(HEADER_WALLET_NAME, String.class);
- AssertState.notNull(walletName, "Cannot find exchange property: " + HEADER_WALLET_NAME);
- return walletName;
- }
-
- public static NessusWallet assertWallet(Exchange exchange) {
- NessusWallet walletRecord = exchange.getIn().getHeader(HEADER_WALLET_RECORD, NessusWallet.class);
- AssertState.notNull(walletRecord, "Cannot find exchange property: " + HEADER_WALLET_RECORD);
- return walletRecord;
- }
-
- public static <T> T getHeader(Exchange exchange, String prefix, Class<T> type) {
- return exchange.getIn().getHeader(prefix + type.getSimpleName(), type);
- }
-
- public static <T> T getHeader(Exchange exchange, Class<T> type) {
- return exchange.getIn().getHeader(type.getSimpleName(), type);
- }
-}
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/ConnectionProcessor.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/ConnectionProcessor.java
deleted file mode 100644
index 3c61c64813d..00000000000
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/ConnectionProcessor.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aries.processor;
-
-import java.time.Duration;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.Exchange;
-import org.hyperledger.aries.AriesWebSocketClient;
-import org.hyperledger.aries.api.connection.ConnectionRecord;
-import org.hyperledger.aries.api.connection.ConnectionTheirRole;
-
-import static org.hyperledger.aries.api.connection.ConnectionTheirRole.INVITEE;
-import static org.hyperledger.aries.api.connection.ConnectionTheirRole.INVITER;
-
-/**
- * Test RFC 0160: Connection Protocol with multitenant wallets
- *
- * https://github.com/hyperledger/aries-rfcs/tree/main/features/0160-connection-protocol
- */
-public class ConnectionProcessor extends AbstractAriesProcessor {
-
- private final String inviterName;
- private final String inviteeName;
-
- public ConnectionProcessor(String inviterName, String inviteeName) {
- this.inviterName = inviterName;
- this.inviteeName = inviteeName;
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- AriesWebSocketClient inviterEvents = getAriesComponent(exchange).getWebSocketClient(inviterName);
- AriesWebSocketClient inviteeEvents = getAriesComponent(exchange).getWebSocketClient(inviteeName);
- exchange.getIn().setHeader(ConnectionProcessor.class.getSimpleName(), this);
- exchange.getIn().setHeader(getHeaderKey(INVITER), inviterEvents);
- exchange.getIn().setHeader(getHeaderKey(INVITEE), inviteeEvents);
- }
-
- public static String getHeaderKey(ConnectionTheirRole role) {
- return role + AriesWebSocketClient.class.getSimpleName();
- }
-
- public static AriesWebSocketClient getWebSocketClient(Exchange exchange, ConnectionTheirRole role) {
- return exchange.getIn().getHeader(getHeaderKey(role), AriesWebSocketClient.class);
- }
-
- public static boolean awaitConnected(Exchange exchange, long timeout, TimeUnit unit) {
- ConnectionRecord inviterRecord = getWebSocketClient(exchange, INVITER).connection()
- .filter(ConnectionRecord::stateIsActive)
- .blockFirst(Duration.ofMillis(unit.toMillis(timeout)));
- ConnectionRecord inviteeRecord = getWebSocketClient(exchange, INVITEE).connection()
- .filter(ConnectionRecord::stateIsActive)
- .blockFirst(Duration.ofMillis(unit.toMillis(timeout)));
- ConnectionProcessor proc = getHeader(exchange, ConnectionProcessor.class);
- ConnectionResult connectionResult = new ConnectionResult(inviterRecord, inviteeRecord);
- exchange.getIn().setHeader(proc.inviterName + proc.inviteeName + "ConnectionRecord",
- connectionResult.inviterConnection);
- exchange.getIn().setHeader(proc.inviteeName + proc.inviterName + "ConnectionRecord",
- connectionResult.inviteeConnection);
- exchange.getIn().setBody(connectionResult);
- return true;
- }
-
- public static class ConnectionResult {
- public final ConnectionRecord inviterConnection;
- public final ConnectionRecord inviteeConnection;
-
- public ConnectionResult(ConnectionRecord inviterConnection, ConnectionRecord inviteeConnection) {
- this.inviterConnection = inviterConnection;
- this.inviteeConnection = inviteeConnection;
- }
- }
-}
diff --git a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/V1CredentialEventProcessor.java b/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/V1CredentialEventProcessor.java
deleted file mode 100644
index d6398e0d8b0..00000000000
--- a/components/camel-hyperledger-aries/src/main/java/org/apache/camel/component/aries/processor/V1CredentialEventProcessor.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aries.processor;
-
-import java.time.Duration;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.Exchange;
-import org.hyperledger.aries.AriesWebSocketClient;
-import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole;
-import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState;
-import org.hyperledger.aries.api.issue_credential_v1.V1CredentialExchange;
-
-import static org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole.HOLDER;
-import static org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole.ISSUER;
-
-public class V1CredentialEventProcessor extends AbstractAriesProcessor {
-
- private final String issuerName;
- private final String holderName;
-
- public V1CredentialEventProcessor(String issuerName, String holderName) {
- this.issuerName = issuerName;
- this.holderName = holderName;
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
- AriesWebSocketClient issuerEvents = getAriesComponent(exchange).getWebSocketClient(issuerName);
- AriesWebSocketClient holderEvents = getAriesComponent(exchange).getWebSocketClient(holderName);
- exchange.getIn().setHeader(V1CredentialEventProcessor.class.getSimpleName(), this);
- exchange.getIn().setHeader(getHeaderKey(ISSUER), issuerEvents);
- exchange.getIn().setHeader(getHeaderKey(HOLDER), holderEvents);
- }
-
- public static String getHeaderKey(CredentialExchangeRole role) {
- return role + AriesWebSocketClient.class.getSimpleName();
- }
-
- public static AriesWebSocketClient getWebSocketClient(Exchange exchange, CredentialExchangeRole role) {
- return exchange.getIn().getHeader(getHeaderKey(role), AriesWebSocketClient.class);
- }
-
- public static boolean awaitIssuerRequestReceived(Exchange exchange, long timeout, TimeUnit unit) {
- V1CredentialExchange credExchange = getWebSocketClient(exchange, ISSUER).credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.REQUEST_RECEIVED)
- .blockFirst(Duration.ofMillis(unit.toMillis(timeout)));
- exchange.getIn().setHeader(ISSUER + "CredentialExchange", credExchange);
- return true;
- }
-
- public static boolean awaitHolderOfferReceived(Exchange exchange, long timeout, TimeUnit unit) {
- V1CredentialExchange credExchange = getWebSocketClient(exchange, HOLDER).credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.OFFER_RECEIVED)
- .blockFirst(Duration.ofMillis(unit.toMillis(timeout)));
- exchange.getIn().setHeader(HOLDER + "CredentialExchange", credExchange);
- return true;
- }
-
- public static boolean awaitHolderCredentialReceived(Exchange exchange, long timeout, TimeUnit unit) {
- V1CredentialExchange credExchange = getWebSocketClient(exchange, HOLDER).credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_RECEIVED)
- .blockFirst(Duration.ofMillis(unit.toMillis(timeout)));
- exchange.getIn().setHeader(HOLDER + "CredentialExchange", credExchange);
- return true;
- }
-
- public static boolean awaitHolderCredentialAcked(Exchange exchange, long timeout, TimeUnit unit) {
- V1CredentialExchange credExchange = getWebSocketClient(exchange, HOLDER).credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_ACKED)
- .blockFirst(Duration.ofMillis(unit.toMillis(timeout)));
- exchange.getIn().setHeader(HOLDER + "CredentialExchange", credExchange);
- return true;
- }
-}
diff --git a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/AbstractCamelAriesTest.java b/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/AbstractCamelAriesTest.java
index 7aa029d618e..e60fdc27fd8 100644
--- a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/AbstractCamelAriesTest.java
+++ b/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/AbstractCamelAriesTest.java
@@ -20,16 +20,15 @@ import java.io.IOException;
import java.util.Arrays;
import com.google.gson.Gson;
+import io.nessus.aries.AgentConfiguration;
import io.nessus.aries.util.AttachmentKey;
import io.nessus.aries.util.AttachmentSupport;
import io.nessus.aries.wallet.NessusWallet;
import io.nessus.aries.wallet.WalletBuilder;
import io.nessus.aries.wallet.WalletRegistry;
import org.apache.camel.test.junit5.CamelTestSupport;
-import org.hyperledger.aries.AriesClient;
import org.hyperledger.aries.api.connection.ConnectionRecord;
import org.hyperledger.aries.api.ledger.IndyLedgerRoles;
-import org.hyperledger.aries.api.multitenancy.WalletRecord;
import org.hyperledger.aries.config.GsonConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,10 +51,18 @@ public abstract class AbstractCamelAriesTest extends CamelTestSupport {
return context.getComponent("hyperledger-aries", HyperledgerAriesComponent.class);
}
+ public AgentConfiguration getAgentConfiguration() {
+ return getAriesComponent().getAgentConfiguration();
+ }
+
public void setRemoveWalletsOnShutdown(boolean flag) {
getAriesComponent().setRemoveWalletsOnShutdown(flag);
}
+ public NessusWallet assertWallet(String walletName) {
+ return getAriesComponent().assertWallet(walletName);
+ }
+
public NessusWallet getWallet(String walletName) {
return getAriesComponent().getWallet(walletName);
}
@@ -90,10 +97,6 @@ public abstract class AbstractCamelAriesTest extends CamelTestSupport {
return walletRecord;
}
- public AriesClient createClient(WalletRecord walletRecord) throws IOException {
- return getAriesComponent().createClient(walletRecord);
- }
-
// Attachment Support ===============================================================
public static class AttachmentContext extends AttachmentSupport {
diff --git a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CamelGettingStartedTest.java b/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CamelGettingStartedTest.java
index a6915058851..a1aefe6f190 100644
--- a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CamelGettingStartedTest.java
+++ b/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CamelGettingStartedTest.java
@@ -17,12 +17,12 @@
package org.apache.camel.component.aries;
import java.io.IOException;
-import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.UnaryOperator;
@@ -30,12 +30,12 @@ import java.util.function.UnaryOperator;
import com.google.gson.JsonObject;
import io.nessus.aries.wallet.CredentialProposalHelper;
import io.nessus.aries.wallet.NessusWallet;
+import io.nessus.aries.websocket.WebSocketClient;
import org.apache.camel.builder.RouteBuilder;
import org.hyperledger.acy_py.generated.model.ConnectionInvitation;
import org.hyperledger.acy_py.generated.model.DID;
import org.hyperledger.acy_py.generated.model.IndyProofReqPredSpec.PTypeEnum;
import org.hyperledger.acy_py.generated.model.IssuerRevRegRecord;
-import org.hyperledger.aries.AriesWebSocketClient;
import org.hyperledger.aries.api.connection.ConnectionReceiveInvitationFilter;
import org.hyperledger.aries.api.connection.ConnectionRecord;
import org.hyperledger.aries.api.connection.CreateInvitationRequest;
@@ -75,6 +75,7 @@ import org.hyperledger.aries.api.revocation.RevocationEvent.RevocationEventState
import org.hyperledger.aries.api.revocation.RevokeRequest;
import org.hyperledger.aries.api.schema.SchemaSendRequest;
import org.hyperledger.aries.api.schema.SchemaSendResponse;
+import org.hyperledger.aries.webhook.EventType;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
@@ -342,9 +343,12 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_MULTITENANCY_SELF_REGISTER_NYM, true),
WalletRecord.class);
- DID publicDid = template.requestBodyAndHeaders("direct:government", null, Map.of(HEADER_SERVICE, "/wallet/did/public"),
- DID.class);
- Assertions.assertNotNull(publicDid, "Public DID not null");
+ template.requestBodyAndHeaders("direct:government", null,
+ Map.of(HEADER_SERVICE, "/wallet/did/public"), DID.class);
+
+ NessusWallet wallet = assertWallet(walletName);
+ wallet.createWebSocketClient(getAgentConfiguration());
+ Assertions.assertNotNull(wallet.getPublicDid(), "Public DID not null");
}
public void onboardFaberCollege(AttachmentContext ctx) throws IOException {
@@ -364,9 +368,12 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_MULTITENANCY_LEDGER_ROLE, ENDORSER),
WalletRecord.class);
- DID publicDid
- = template.requestBodyAndHeaders("direct:faber", null, Map.of(HEADER_SERVICE, "/wallet/did/public"), DID.class);
- Assertions.assertNotNull(publicDid, "Public DID not null");
+ template.requestBodyAndHeaders("direct:faber", null,
+ Map.of(HEADER_SERVICE, "/wallet/did/public"), DID.class);
+
+ NessusWallet wallet = assertWallet(walletName);
+ wallet.createWebSocketClient(getAgentConfiguration());
+ Assertions.assertNotNull(wallet.getPublicDid(), "Public DID not null");
}
public void onboardAcmeCorp(AttachmentContext ctx) throws IOException {
@@ -386,9 +393,12 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_MULTITENANCY_LEDGER_ROLE, ENDORSER),
WalletRecord.class);
- DID publicDid
- = template.requestBodyAndHeaders("direct:acme", null, Map.of(HEADER_SERVICE, "/wallet/did/public"), DID.class);
- Assertions.assertNotNull(publicDid, "Public DID not null");
+ template.requestBodyAndHeaders("direct:acme", null,
+ Map.of(HEADER_SERVICE, "/wallet/did/public"), DID.class);
+
+ NessusWallet wallet = assertWallet(walletName);
+ wallet.createWebSocketClient(getAgentConfiguration());
+ Assertions.assertNotNull(wallet.getPublicDid(), "Public DID not null");
}
public void onboardThriftBank(AttachmentContext ctx) throws IOException {
@@ -408,9 +418,12 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_MULTITENANCY_LEDGER_ROLE, ENDORSER),
WalletRecord.class);
- DID publicDid = template.requestBodyAndHeaders("direct:thrift", null, Map.of(HEADER_SERVICE, "/wallet/did/public"),
- DID.class);
- Assertions.assertNotNull(publicDid, "Public DID not null");
+ template.requestBodyAndHeaders("direct:thrift", null,
+ Map.of(HEADER_SERVICE, "/wallet/did/public"), DID.class);
+
+ NessusWallet wallet = assertWallet(walletName);
+ wallet.createWebSocketClient(getAgentConfiguration());
+ Assertions.assertNotNull(wallet.getPublicDid(), "Public DID not null");
}
public void onboardAlice(AttachmentContext ctx) throws IOException {
@@ -426,17 +439,20 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
.build();
template.requestBody("direct:admin", walletRequest, WalletRecord.class);
+
+ NessusWallet wallet = getWallet(walletName);
+ wallet.createWebSocketClient(getAgentConfiguration());
}
void connectPeers(AttachmentContext ctx, String inviter, String invitee) throws Exception {
logSection(String.format("Connect %s to %s", inviter, invitee));
- NessusWallet inviterWallet = getAriesComponent().getWallet(inviter);
- NessusWallet inviteeWallet = getAriesComponent().getWallet(invitee);
+ NessusWallet inviterWallet = getAriesComponent().assertWallet(inviter);
+ NessusWallet inviteeWallet = getAriesComponent().assertWallet(invitee);
- AriesWebSocketClient inviterEvents = inviterWallet.getWebSocketClient();
- AriesWebSocketClient inviteeEvents = inviteeWallet.getWebSocketClient();
+ WebSocketClient inviterEvents = inviterWallet.getWebSocketClient().startRecording(EventType.CONNECTIONS);
+ WebSocketClient inviteeEvents = inviteeWallet.getWebSocketClient().startRecording(EventType.CONNECTIONS);
// Inviter creates an invitation (/connections/create-invitation)
UnaryOperator<String> uri = wn -> "direct:" + wn.toLowerCase();
@@ -463,13 +479,13 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
ConnectionReceiveInvitationFilter.class.getName(), receiveParams),
ConnectionRecord.class);
- ConnectionRecord inviterConnectionRecord = inviterEvents.connection()
- .filter(ConnectionRecord::stateIsActive)
- .blockFirst(Duration.ofSeconds(10));
+ ConnectionRecord inviterConnectionRecord = inviterEvents
+ .awaitConnection(ConnectionRecord::stateIsActive, 10, TimeUnit.SECONDS)
+ .findAny().get();
- ConnectionRecord inviteeConnectionRecord = inviteeEvents.connection()
- .filter(ConnectionRecord::stateIsActive)
- .blockFirst(Duration.ofSeconds(10));
+ ConnectionRecord inviteeConnectionRecord = inviteeEvents
+ .awaitConnection(ConnectionRecord::stateIsActive, 10, TimeUnit.SECONDS)
+ .findAny().get();
ctx.putAttachment(inviter + invitee + "Connection", inviterConnectionRecord);
ctx.putAttachment(invitee + inviter + "Connection", inviteeConnectionRecord);
@@ -591,8 +607,8 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
String faberAliceConnectionId = ctx.getConnection(FABER, ALICE).getConnectionId();
- AriesWebSocketClient issuerEvents = getWallet(FABER).getWebSocketClient();
- AriesWebSocketClient holderEvents = getWallet(ALICE).getWebSocketClient();
+ WebSocketClient issuerEvents = getWallet(FABER).getWebSocketClient().startRecording(EventType.ISSUE_CREDENTIAL);
+ WebSocketClient holderEvents = getWallet(ALICE).getWebSocketClient().startRecording(EventType.ISSUE_CREDENTIAL);
/* 1. Faber sends the Transcript Credential Offer
*
@@ -622,9 +638,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
*
*/
- V1CredentialExchange holderExchange = holderEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.OFFER_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ V1CredentialExchange holderExchange = holderEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(transcriptCredDefId) &&
+ cex.getState() == CredentialExchangeState.OFFER_RECEIVED, 10, TimeUnit.SECONDS)
+ .findAny().get();
CredentialProposal credentialProposal = holderExchange.getCredentialProposalDict().getCredentialProposal();
CredentialProposalHelper credentialHelper = new CredentialProposalHelper(credentialProposal);
@@ -646,9 +663,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
*
*/
- V1CredentialExchange issuerExchange = issuerEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.REQUEST_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ V1CredentialExchange issuerExchange = issuerEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(transcriptCredDefId) &&
+ cex.getState() == CredentialExchangeState.REQUEST_RECEIVED, 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 5. Faber issues the Transcript Credential
*
@@ -665,9 +683,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
*
*/
- holderExchange = holderEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ holderExchange = holderEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(transcriptCredDefId) &&
+ cex.getState() == CredentialExchangeState.CREDENTIAL_RECEIVED, 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 7. Alice stores the Transcript Credential
*
@@ -683,9 +702,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/issue-credential/records/" + holderCredentialExchangeId + "/store"),
V1CredentialExchange.class);
- holderExchange = holderEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_ACKED)
- .blockFirst(Duration.ofSeconds(10));
+ holderExchange = holderEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(transcriptCredDefId) &&
+ cex.getState() == CredentialExchangeState.CREDENTIAL_ACKED, 10, TimeUnit.SECONDS)
+ .findAny().get();
}
void applyForJobWithAcme(AttachmentContext ctx) throws Exception {
@@ -694,8 +714,8 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
String acmeAliceConnectionId = ctx.getConnection(ACME, ALICE).getConnectionId();
- AriesWebSocketClient verifierEvents = getWallet(ACME).getWebSocketClient();
- AriesWebSocketClient proverEvents = getWallet(ALICE).getWebSocketClient();
+ WebSocketClient verifierEvents = getWallet(ACME).getWebSocketClient().startRecording(EventType.PRESENT_PROOF);
+ WebSocketClient proverEvents = getWallet(ALICE).getWebSocketClient().startRecording(EventType.PRESENT_PROOF);
/* 1. Acme creates a Job Application Proof Request
*
@@ -741,13 +761,15 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
.build())
.build();
- template.requestBodyAndHeaders("direct:acme", proofRequest, Map.of(
+ PresentationExchangeRecord verifierExchangeRecord = template.requestBodyAndHeaders("direct:acme", proofRequest, Map.of(
HEADER_SERVICE, "/present-proof/send-request"),
PresentationExchangeRecord.class);
- PresentationExchangeRecord proverExchangeRecord = proverEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.REQUEST_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ String threadId = verifierExchangeRecord.getThreadId();
+ PresentationExchangeRecord proverExchangeRecord = proverEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.REQUEST_RECEIVED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
// 2. Alice searches her Wallet for Credentials that she can use for the creating of Proof for the Job-Application Proof Request
@@ -812,9 +834,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/present-proof/records/" + proverExchangeId + "/send-presentation"),
PresentationExchangeRecord.class);
- PresentationExchangeRecord verifierExchangeRecord = verifierEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ verifierExchangeRecord = verifierEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_RECEIVED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 4. Acme verifies the Job Application Proof from Alice
*
@@ -826,15 +849,16 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/present-proof/records/" + verifierExchangeId + "/verify-presentation"),
PresentationExchangeRecord.class);
- verifierExchangeRecord = verifierEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.VERIFIED)
- .blockFirst(Duration.ofSeconds(10));
+ verifierExchangeRecord = verifierEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.VERIFIED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
Assertions.assertTrue(verifierExchangeRecord.isVerified(), "Not VERIFIED");
- proverEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_ACKED)
- .blockFirst(Duration.ofSeconds(10));
+ proverEvents.awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_ACKED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
// [#1754] Prover cannot know verification outcome from PRESENTATION_ACKED
// https://github.com/hyperledger/aries-cloudagent-python/issues/1754
@@ -847,8 +871,8 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
String acmeAliceConnectionId = ctx.getConnection(ACME, ALICE).getConnectionId();
- AriesWebSocketClient issuerEvents = getWallet(ACME).getWebSocketClient();
- AriesWebSocketClient holderEvents = getWallet(ALICE).getWebSocketClient();
+ WebSocketClient issuerEvents = getWallet(ACME).getWebSocketClient().startRecording(EventType.ISSUE_CREDENTIAL);
+ WebSocketClient holderEvents = getWallet(ALICE).getWebSocketClient().startRecording(EventType.ISSUE_CREDENTIAL);
/* 1. Acme sends the JobCertificate Credential Offer
*
@@ -877,9 +901,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
*
*/
- V1CredentialExchange holderExchange = holderEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.OFFER_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ V1CredentialExchange holderExchange = holderEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(jobCertificateCredDefId) &&
+ cex.getState() == CredentialExchangeState.OFFER_RECEIVED, 10, TimeUnit.SECONDS)
+ .findAny().get();
CredentialProposal credentialProposal = holderExchange.getCredentialProposalDict().getCredentialProposal();
CredentialProposalHelper credentialHelper = new CredentialProposalHelper(credentialProposal);
@@ -901,9 +926,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
*
*/
- V1CredentialExchange issuerExchange = issuerEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.REQUEST_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ V1CredentialExchange issuerExchange = issuerEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(jobCertificateCredDefId) &&
+ cex.getState() == CredentialExchangeState.REQUEST_RECEIVED, 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 5. Acme issues the JobCertificate Credential
*
@@ -920,9 +946,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
*
*/
- holderExchange = holderEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ holderExchange = holderEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(jobCertificateCredDefId) &&
+ cex.getState() == CredentialExchangeState.CREDENTIAL_RECEIVED, 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 7. Alice stores the Transcript Credential
*
@@ -938,9 +965,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/issue-credential/records/" + holderCredentialExchangeId + "/store"),
V1CredentialExchange.class);
- holderExchange = holderEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_ACKED)
- .blockFirst(Duration.ofSeconds(10));
+ holderExchange = holderEvents
+ .awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(jobCertificateCredDefId) &&
+ cex.getState() == CredentialExchangeState.CREDENTIAL_ACKED, 10, TimeUnit.SECONDS)
+ .findAny().get();
}
void applyForLoanWithThrift(AttachmentContext ctx, boolean expectedOutcome) throws Exception {
@@ -949,8 +977,8 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
String thriftAliceConnectionId = ctx.getConnection(THRIFT, ALICE).getConnectionId();
- AriesWebSocketClient verifierEvents = getWallet(THRIFT).getWebSocketClient();
- AriesWebSocketClient proverEvents = getWallet(ALICE).getWebSocketClient();
+ WebSocketClient verifierEvents = getWallet(THRIFT).getWebSocketClient().startRecording(EventType.PRESENT_PROOF);
+ WebSocketClient proverEvents = getWallet(ALICE).getWebSocketClient().startRecording(EventType.PRESENT_PROOF);
/* 1. Alice gets a Loan-Application Proof Request from Thrift Bank
*
@@ -992,13 +1020,16 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
.build())
.build();
- template.requestBodyAndHeaders("direct:thrift", proofRequest, Map.of(
- HEADER_SERVICE, "/present-proof/send-request"),
+ PresentationExchangeRecord verifierExchangeRecord = template.requestBodyAndHeaders("direct:thrift", proofRequest,
+ Map.of(
+ HEADER_SERVICE, "/present-proof/send-request"),
PresentationExchangeRecord.class);
- PresentationExchangeRecord proverExchangeRecord = proverEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.REQUEST_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ String threadId = verifierExchangeRecord.getThreadId();
+ PresentationExchangeRecord proverExchangeRecord = proverEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.REQUEST_RECEIVED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
// 2. Alice searches her Wallet for Credentials that she can use for the creating of Proof for the Loan-Application Proof Request
@@ -1058,9 +1089,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/present-proof/records/" + proverExchangeId + "/send-presentation"),
PresentationExchangeRecord.class);
- PresentationExchangeRecord verifierExchangeRecord = verifierEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ verifierExchangeRecord = verifierEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_RECEIVED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 4. Thrift verifies the Loan-Application Proof from Alice
*
@@ -1072,15 +1104,16 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/present-proof/records/" + verifierExchangeId + "/verify-presentation"),
PresentationExchangeRecord.class);
- verifierExchangeRecord = verifierEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.VERIFIED)
- .blockFirst(Duration.ofSeconds(10));
+ verifierExchangeRecord = verifierEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.VERIFIED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
Assertions.assertEquals(expectedOutcome, verifierExchangeRecord.isVerified(), "Unexpected verification outcome");
- proverEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_ACKED)
- .blockFirst(Duration.ofSeconds(10));
+ proverEvents.awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_ACKED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
// [#1754] Prover cannot know verification outcome from PRESENTATION_ACKED
// https://github.com/hyperledger/aries-cloudagent-python/issues/1754
@@ -1093,8 +1126,8 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
String thriftAliceConnectionId = ctx.getConnection(THRIFT, ALICE).getConnectionId();
- AriesWebSocketClient verifierEvents = getWallet(THRIFT).getWebSocketClient();
- AriesWebSocketClient proverEvents = getWallet(ALICE).getWebSocketClient();
+ WebSocketClient verifierEvents = getWallet(THRIFT).getWebSocketClient().startRecording(EventType.PRESENT_PROOF);
+ WebSocketClient proverEvents = getWallet(ALICE).getWebSocketClient().startRecording(EventType.PRESENT_PROOF);
/* 1. Alice gets a second Proof Request from Thrift Bank
*
@@ -1121,13 +1154,16 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
.build())
.build();
- template.requestBodyAndHeaders("direct:thrift", proofRequest, Map.of(
- HEADER_SERVICE, "/present-proof/send-request"),
+ PresentationExchangeRecord verifierExchangeRecord = template.requestBodyAndHeaders("direct:thrift", proofRequest,
+ Map.of(
+ HEADER_SERVICE, "/present-proof/send-request"),
PresentationExchangeRecord.class);
- PresentationExchangeRecord proverExchangeRecord = proverEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.REQUEST_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ String threadId = verifierExchangeRecord.getThreadId();
+ PresentationExchangeRecord proverExchangeRecord = proverEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.REQUEST_RECEIVED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
// 2. Alice searches her Wallet for Credentials that she can use for the creating of Proof for the KYC Proof Request
@@ -1183,9 +1219,10 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/present-proof/records/" + proverExchangeId + "/send-presentation"),
PresentationExchangeRecord.class);
- PresentationExchangeRecord verifierExchangeRecord = verifierEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_RECEIVED)
- .blockFirst(Duration.ofSeconds(10));
+ verifierExchangeRecord = verifierEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_RECEIVED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
/* 4. Thrift verifies the KYC-Application Proof from Alice
*
@@ -1197,14 +1234,15 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/present-proof/records/" + verifierExchangeId + "/verify-presentation"),
PresentationExchangeRecord.class);
- verifierExchangeRecord = verifierEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.VERIFIED)
- .blockFirst(Duration.ofSeconds(10));
+ verifierExchangeRecord = verifierEvents
+ .awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.VERIFIED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
Assertions.assertTrue(verifierExchangeRecord.isVerified(), "Not VERIFIED");
- proverEvents.presentationEx()
- .filter(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_ACKED)
- .blockFirst(Duration.ofSeconds(10));
+ proverEvents.awaitPresentProofV1(pex -> pex.getState() == PresentationExchangeState.PRESENTATION_ACKED &&
+ pex.getThreadId().equals(threadId), 10, TimeUnit.SECONDS)
+ .findAny().get();
// [#1754] Prover cannot know verification outcome from PRESENTATION_ACKED
// https://github.com/hyperledger/aries-cloudagent-python/issues/1754
@@ -1217,10 +1255,11 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
String acmeAliceConnectionId = ctx.getConnection(ACME, ALICE).getConnectionId();
- AriesWebSocketClient issuerEvents = getWallet(ACME).getWebSocketClient();
+ WebSocketClient issuerEvents
+ = getWallet(ACME).getWebSocketClient().startRecording(EventType.ISSUER_CRED_REV, EventType.ISSUE_CREDENTIAL);
// [TODO] There is currently no event that the Holder could listen to
- // AriesWebSocketClient holderEvents = getWallet(Alice).getWebSocketClient();
+ // WebSocketClient holderEvents = assertWallet(Alice).getWebSocketClient();
// 1. Acme searches the Job-Certificate Credential
@@ -1248,19 +1287,12 @@ public class CamelGettingStartedTest extends AbstractCamelAriesTest {
HEADER_SERVICE, "/revocation/revoke"),
RevocationModuleResponse.class);
- issuerEvents.issuerRevocation()
- .filter(rev -> rev.getState() == RevocationEventState.ISSUED)
- .blockFirst(Duration.ofSeconds(10));
-
- // [#1828] Issuer no longer receives revocation event [state=REVOKED]
- // https://github.com/hyperledger/aries-cloudagent-python/issues/1828
- //
- // issuerEvents.issuerRevocation()
- // .filter(rev -> rev.getState() == RevocationEventState.REVOKED)
- // .blockFirst(Duration.ofSeconds(10));
+ issuerEvents.awaitIssuerRevocation(rev -> rev.getCredDefId().equals(jobCertificateCredDefId) &&
+ rev.getState() == RevocationEventState.REVOKED, 10, TimeUnit.SECONDS)
+ .findAny().get();
- issuerEvents.credentialEx()
- .filter(cex -> cex.getState() == CredentialExchangeState.CREDENTIAL_REVOKED)
- .blockFirst(Duration.ofSeconds(10));
+ issuerEvents.awaitIssueCredentialV1(cex -> cex.getCredentialDefinitionId().equals(jobCertificateCredDefId) &&
+ cex.getState() == CredentialExchangeState.CREDENTIAL_REVOKED, 10, TimeUnit.SECONDS)
+ .findAny().get();
}
}
diff --git a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CredentialOfferRequestIssueTest.java b/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CredentialOfferRequestIssueTest.java
deleted file mode 100644
index cd433ecc4f2..00000000000
--- a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/CredentialOfferRequestIssueTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aries;
-
-import java.util.Arrays;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.aries.processor.ConnectionProcessor;
-import org.apache.camel.component.aries.processor.V1CredentialEventProcessor;
-import org.hyperledger.aries.api.connection.ConnectionRecord;
-import org.hyperledger.aries.api.credentials.CredentialAttributes;
-import org.hyperledger.aries.api.credentials.CredentialPreview;
-import org.hyperledger.aries.api.issue_credential_v1.V1CredentialExchange;
-import org.hyperledger.aries.api.issue_credential_v1.V1CredentialOfferRequest;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-
-import static org.apache.camel.component.aries.processor.ConnectionProcessor.awaitConnected;
-import static org.apache.camel.component.aries.processor.V1CredentialEventProcessor.awaitHolderCredentialAcked;
-import static org.apache.camel.component.aries.processor.V1CredentialEventProcessor.awaitHolderCredentialReceived;
-import static org.apache.camel.component.aries.processor.V1CredentialEventProcessor.awaitHolderOfferReceived;
-import static org.apache.camel.component.aries.processor.V1CredentialEventProcessor.awaitIssuerRequestReceived;
-import static org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole.HOLDER;
-import static org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState.CREDENTIAL_ACKED;
-import static org.hyperledger.aries.api.ledger.IndyLedgerRoles.ENDORSER;
-
-/**
- * docker compose up --detach && docker compose logs -f acapy
- */
-@EnabledIfSystemProperty(named = "enable.hyperledger.aries.itests", matches = "true",
- disabledReason = "Requires distributed ledger (i.e. blockchain)")
-public class CredentialOfferRequestIssueTest extends AbstractCamelAriesTest {
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
-
- // Faber creates a Transscript Credential Definition
- // Note, the Schema is created on-demand
- from("direct:transscript-credential-definition")
- .to("hyperledger-aries:faber?service=/credential-definitions&schemaName=Transscript&autoSchema=true")
- .setHeader("CredentialDefinitionId", simple("${body.credentialDefinitionId}"))
- .to("direct:faber-alice-connect");
-
- // Faber connects to Alice
- from("direct:faber-alice-connect")
- .to("hyperledger-aries:faber?service=/connections/create-invitation")
- .transform(simple("${body.invitation}"))
- .setHeader("ConnectionReceiveInvitationFilter", () -> Map.of("auto_accept", true))
- .process(new ConnectionProcessor(FABER, ALICE))
- .to("hyperledger-aries:alice?service=/connections/receive-invitation")
- .process(ex -> awaitConnected(ex, 10, TimeUnit.SECONDS))
- .to("direct:transscript-credential-offer");
-
- // Faber sends the Transcript Credential Offer
- from("direct:transscript-credential-offer")
- .setBody(ex -> V1CredentialOfferRequest.builder()
- .connectionId(ex.getIn().getHeader("FaberAliceConnectionRecord", ConnectionRecord.class)
- .getConnectionId())
- .credentialDefinitionId(ex.getIn().getHeader("CredentialDefinitionId", String.class))
- .credentialPreview(new CredentialPreview(
- CredentialAttributes.from(Map.of(
- "first_name", "Alice",
- "last_name", "Garcia",
- "ssn", "123-45-6789",
- "degree", "Bachelor of Science, Marketing",
- "status", "graduated",
- "year", "2015",
- "average", "5"))))
- .build())
- .process(new V1CredentialEventProcessor(FABER, ALICE))
- .to("hyperledger-aries:faber?service=/issue-credential/send-offer")
- .to("direct:send-credential-request");
-
- // Faber issues the Transcript Credential
- from("direct:send-credential-request")
- .process(ex -> awaitHolderOfferReceived(ex, 10, TimeUnit.SECONDS))
- .toD("hyperledger-aries:alice?service=/issue-credential/records/${header.holderCredentialExchange.credentialExchangeId}/send-request")
- .process(ex -> awaitIssuerRequestReceived(ex, 10, TimeUnit.SECONDS))
- .toD("hyperledger-aries:faber?service=/issue-credential/records/${header.issuerCredentialExchange.credentialExchangeId}/issue")
- .process(ex -> awaitHolderCredentialReceived(ex, 10, TimeUnit.SECONDS))
- .toD("hyperledger-aries:alice?service=/issue-credential/records/${header.holderCredentialExchange.credentialExchangeId}/store")
- .process(ex -> awaitHolderCredentialAcked(ex, 10, TimeUnit.SECONDS));
- }
- };
- }
-
- @Test
- public void testWorkflow() throws Exception {
-
- setRemoveWalletsOnShutdown(true);
-
- onboardWallet(FABER, ENDORSER);
- onboardWallet(ALICE);
-
- Map<String, Object> reqBody = Map.of(
- "schemaVersion", "1.2",
- "attributes", Arrays.asList("first_name", "last_name", "ssn", "degree", "status", "year", "average"),
- "supportRevocation", "false");
-
- V1CredentialExchange resObj
- = template.requestBody("direct:transscript-credential-definition", reqBody, V1CredentialExchange.class);
- Assertions.assertEquals(HOLDER, resObj.getRole());
- Assertions.assertEquals(CREDENTIAL_ACKED, resObj.getState());
- }
-}
diff --git a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/PeerConnectionTest.java b/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/PeerConnectionTest.java
deleted file mode 100644
index 75b7ce6125d..00000000000
--- a/components/camel-hyperledger-aries/src/test/java/org/apache/camel/component/aries/PeerConnectionTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.aries;
-
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.aries.processor.ConnectionProcessor;
-import org.apache.camel.component.aries.processor.ConnectionProcessor.ConnectionResult;
-import org.hyperledger.aries.api.connection.ConnectionState;
-import org.hyperledger.aries.api.connection.CreateInvitationRequest;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
-
-import static org.apache.camel.component.aries.processor.ConnectionProcessor.awaitConnected;
-import static org.hyperledger.aries.api.ledger.IndyLedgerRoles.ENDORSER;
-
-/**
- * docker compose up --detach && docker compose logs -f acapy
- */
-@EnabledIfSystemProperty(named = "enable.hyperledger.aries.itests", matches = "true",
- disabledReason = "Requires distributed ledger (i.e. blockchain)")
-public class PeerConnectionTest extends AbstractCamelAriesTest {
-
- @Override
- protected RouteBuilder createRouteBuilder() {
- return new RouteBuilder() {
- @Override
- public void configure() {
-
- from("direct:faber-alice-connect")
-
- // Faber creates the connection Invitation
- .to("hyperledger-aries:faber?service=/connections/create-invitation")
-
- // Transform CreateInvitationResponse => ConnectionInvitation
- .transform(simple("${body.invitation}"))
-
- // Set an additional message header for Inivitation auto accept
- // We could also have done this when initiating the route
- .setHeader("ConnectionReceiveInvitationFilter", () -> Map.of("auto_accept", true))
-
- // Setup WebSocket event handling for the Inviter/Invitee
- .process(new ConnectionProcessor(FABER, ALICE))
-
- // Alice consumes the Invitation
- .to("hyperledger-aries:alice?service=/connections/receive-invitation")
-
- // Await connection ACTIVE for the Inviter/Invitee
- .process(ex -> awaitConnected(ex, 10, TimeUnit.SECONDS));
- }
- };
- }
-
- @Test
- public void testWorkflow() throws Exception {
-
- setRemoveWalletsOnShutdown(true);
-
- onboardWallet(FABER, ENDORSER);
- onboardWallet(ALICE);
-
- CreateInvitationRequest reqBody = CreateInvitationRequest.builder().build();
-
- ConnectionResult resObj = template.requestBody("direct:faber-alice-connect", reqBody, ConnectionResult.class);
-
- log.info("Inviter: [{}] {}", resObj.inviterConnection.getState(), resObj.inviterConnection);
- log.info("Invitee: [{}] {}", resObj.inviteeConnection.getState(), resObj.inviteeConnection);
-
- Assertions.assertEquals(ConnectionState.ACTIVE, resObj.inviterConnection.getState());
- Assertions.assertEquals(ConnectionState.ACTIVE, resObj.inviteeConnection.getState());
- }
-}
diff --git a/components/camel-hyperledger-aries/src/test/resources/log4j2.properties b/components/camel-hyperledger-aries/src/test/resources/log4j2.properties
index ee5f33d302f..99e5aa74c3f 100644
--- a/components/camel-hyperledger-aries/src/test/resources/log4j2.properties
+++ b/components/camel-hyperledger-aries/src/test/resources/log4j2.properties
@@ -33,4 +33,4 @@ appender.stdout.name = console
appender.stdout.layout.type = PatternLayout
appender.stdout.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p [%c] (%t) - %m%n
appender.stdout.filter.threshold.type = ThresholdFilter
-appender.stdout.filter.threshold.level = WARN
\ No newline at end of file
+appender.stdout.filter.threshold.level = INFO
\ No newline at end of file
diff --git a/parent/pom.xml b/parent/pom.xml
index 31445046a64..c526e1f2c00 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -408,7 +408,7 @@
<mvel-version>2.4.14.Final</mvel-version>
<mybatis-version>3.5.10</mybatis-version>
<narayana-version>5.12.7.Final</narayana-version>
- <nessus-hyperledger-aries-version>0.1.1</nessus-hyperledger-aries-version>
+ <nessus-hyperledger-aries-version>0.2.0</nessus-hyperledger-aries-version>
<nessus-ipfs-version>1.0.0.Beta4</nessus-ipfs-version>
<nessus-weka-version>1.0.1</nessus-weka-version>
<neoscada-version>0.4.0</neoscada-version>