diff --git a/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java b/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java
index 529f9a101..1a7baf2d6 100644
--- a/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java
+++ b/backend/business-partner-agent-core/src/main/java/org/hyperledger/bpa/core/WebhookEvent.java
@@ -17,12 +17,11 @@
*/
package org.hyperledger.bpa.core;
-import org.hyperledger.bpa.core.RegisteredWebhook.WebhookEventType;
-
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
+import org.hyperledger.bpa.core.RegisteredWebhook.WebhookEventType;
@Data
@Builder
diff --git a/backend/business-partner-agent/pom.xml b/backend/business-partner-agent/pom.xml
index 439ac71fc..2f8e51259 100644
--- a/backend/business-partner-agent/pom.xml
+++ b/backend/business-partner-agent/pom.xml
@@ -149,7 +149,7 @@
network.idu.acapy
aries-client-python
- 0.7.29
+ 0.7.30-SNAPSHOT
org.hyperledger.business-partner-agent
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java
index 5ccc10251..5cebc3b8a 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/MyDocumentAPI.java
@@ -17,14 +17,15 @@
*/
package org.hyperledger.bpa.api;
-import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.bpa.controller.api.wallet.WalletDocumentRequest;
+import java.util.List;
import java.util.UUID;
@Data
@@ -41,7 +42,7 @@ public class MyDocumentAPI {
private Boolean isPublic;
private String label;
@Schema(example = "{}")
- private JsonNode documentData; // TODO rename to document
+ private List documentData; // TODO rename to document
public static MyDocumentAPI fromRequest(WalletDocumentRequest req) {
return DocumentMapper.INSTANCE.requestToDocumentApi(req);
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java
index f3e77019c..72e4fcd0a 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/api/aries/AriesCredential.java
@@ -21,12 +21,13 @@
import lombok.*;
import org.apache.commons.lang3.StringUtils;
import org.hyperledger.aries.api.ExchangeVersion;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState;
import org.hyperledger.bpa.api.CredentialType;
import org.hyperledger.bpa.impl.aries.jsonld.LDContextHelper;
import org.hyperledger.bpa.persistence.model.BPACredentialExchange;
-import java.util.Map;
+import java.util.List;
import java.util.UUID;
@Data
@@ -50,7 +51,7 @@ public class AriesCredential {
private String label;
private String typeLabel;
- private Map credentialData;
+ private List credentialData;
public static AriesCredential fromBPACredentialExchange(@NonNull BPACredentialExchange c,
@Nullable String typeLabel) {
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java
index f41f29da2..9fc86b51f 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredEx.java
@@ -21,6 +21,7 @@
import org.apache.commons.lang3.StringUtils;
import org.hyperledger.aries.api.ExchangeVersion;
import org.hyperledger.aries.api.credentials.Credential;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole;
import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState;
import org.hyperledger.bpa.api.CredentialType;
@@ -29,6 +30,7 @@
import org.hyperledger.bpa.controller.api.ExchangeVersionTranslator;
import org.hyperledger.bpa.persistence.model.BPACredentialExchange;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -44,7 +46,7 @@ public class CredEx implements ExchangeVersionTranslator {
private PartnerAPI partner;
private String schemaId; // TODO UI should use this id instead the one from the credential
private String credentialDefinitionId; // TODO UI should use this id instead the one from the credential
- private Map proposal;
+ private List proposal;
private Credential credential; // TODO should also be Map
private CredentialExchangeRole role;
private CredentialExchangeState state;
@@ -81,18 +83,18 @@ public static CredEx from(@NonNull BPACredentialExchange db, PartnerAPI partner)
} else if (StringUtils.isNotEmpty(db.getErrorMsg())) {
displayText = db.getErrorMsg();
}
- Map credentialAttrs;
+ List credentialAttrs;
if (db.stateIsProposalReceived()
|| db.stateIsProposalSent()
|| db.roleIsHolder() && db.stateIsProblem()
|| db.roleIsIssuer() && db.stateIsDeclined()) {
- credentialAttrs = db.proposalAttributesToMap();
+ credentialAttrs = db.proposalAttributesToCredentialAttributesList();
} else if (db.stateIsOfferReceived()
|| db.stateIsRequestSent()
|| db.roleIsHolder() && db.stateIsDeclined()) {
- credentialAttrs = db.offerAttributesToMap();
+ credentialAttrs = db.offerAttributesToCredentialAttributesList();
} else {
- credentialAttrs = db.credentialAttributesToMap();
+ credentialAttrs = db.credentialAttributesToCredentialAttributesList();
}
return builder
.id(db.getId())
@@ -101,7 +103,7 @@ public static CredEx from(@NonNull BPACredentialExchange db, PartnerAPI partner)
.partner(partner)
.schemaId(db.getSchema() != null ? db.getSchema().getSchemaId() : null)
.credentialDefinitionId(db.getCredDef() != null ? db.getCredDef().getCredentialDefinitionId() : null)
- .proposal(db.proposalAttributesToMap())
+ .proposal(db.proposalAttributesToCredentialAttributesList())
.credential(Credential
.builder()
.schemaId(db.getSchema() != null ? db.getSchema().getSchemaId() : null)
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java
index f6dc0f30a..1efa5f8cf 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/CredentialOfferRequest.java
@@ -24,7 +24,6 @@
import javax.validation.constraints.NotEmpty;
import java.util.List;
-import java.util.Map;
@Data
@NoArgsConstructor
@@ -34,16 +33,9 @@ public class CredentialOfferRequest {
private String credDefId;
private String schemaId;
@NotEmpty
- private Map attributes;
+ private List attributes;
public boolean acceptAll() {
return acceptProposal != null && acceptProposal;
}
-
- public List toCredentialAttributes() {
- if (attributes != null) {
- return CredentialAttributes.fromMap(attributes);
- }
- return List.of();
- }
}
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java
index 1ae5133fb..cdb059d65 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueCredentialRequest.java
@@ -17,19 +17,19 @@
*/
package org.hyperledger.bpa.controller.api.issuer;
-import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.databind.JsonNode;
import io.micronaut.core.annotation.Introspected;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.hyperledger.aries.api.ExchangeVersion;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.bpa.api.CredentialType;
import org.hyperledger.bpa.controller.api.ExchangeVersionTranslator;
import javax.validation.constraints.NotBlank;
+import java.util.List;
import java.util.UUID;
@Introspected
@@ -58,10 +58,8 @@ public abstract class IssueCredentialRequest {
/** credential exchange type */
private CredentialType type;
- /** credential body key value pairs */
- @JsonRawValue
- @Schema(example = "{}")
- private JsonNode document;
+ /** Attribute array with name, value, mime-type */
+ private List document;
@Introspected
@Data
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java
index ba89c3b6d..bab595a73 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/issuer/IssueOOBCredentialRequest.java
@@ -18,12 +18,12 @@
package org.hyperledger.bpa.controller.api.issuer;
import com.fasterxml.jackson.annotation.JsonRawValue;
-import com.fasterxml.jackson.databind.JsonNode;
import io.micronaut.core.annotation.Introspected;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hyperledger.aries.api.ExchangeVersion;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.bpa.controller.api.ExchangeVersionTranslator;
import org.hyperledger.bpa.persistence.model.Tag;
@@ -48,7 +48,7 @@ public class IssueOOBCredentialRequest implements ExchangeVersionTranslator {
/** credential body key value pairs */
@JsonRawValue
@Schema(example = "{}")
- private JsonNode document;
+ private List document;
private ExchangeVersion exchangeVersion;
}
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java
index 5819bac35..b72903d19 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/proof/PresentationRequestCredentialsIndy.java
@@ -18,11 +18,11 @@
package org.hyperledger.bpa.controller.api.proof;
import lombok.*;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.bpa.api.aries.AriesCredential;
import org.hyperledger.bpa.persistence.model.BPACredentialExchange;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
@Data
@@ -52,7 +52,7 @@ public static final class CredentialInfo {
private String referent;
private Boolean revoked;
- private Map attrs;
+ private List attrs;
private String schemaId;
private String schemaLabel;
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java
index daaebf0c5..bdee671f4 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/controller/api/wallet/WalletDocumentRequest.java
@@ -18,11 +18,13 @@
package org.hyperledger.bpa.controller.api.wallet;
import com.fasterxml.jackson.annotation.JsonRawValue;
-import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.bpa.api.CredentialType;
+import java.util.List;
+
@Data
public class WalletDocumentRequest {
private CredentialType type;
@@ -31,5 +33,5 @@ public class WalletDocumentRequest {
private String label;
@JsonRawValue
@Schema(example = "{}")
- private JsonNode document;
+ private List document;
}
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java
index d9f400dc1..b04ee2dad 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/TagService.java
@@ -31,7 +31,10 @@
import org.hyperledger.bpa.persistence.model.Tag;
import org.hyperledger.bpa.persistence.repository.TagRepository;
-import java.util.*;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java
index e353cbf19..071f084c0 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/DocumentValidator.java
@@ -17,12 +17,12 @@
*/
package org.hyperledger.bpa.impl.activity;
-import com.fasterxml.jackson.databind.JsonNode;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import lombok.NonNull;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.bpa.api.CredentialType;
import org.hyperledger.bpa.api.MyDocumentAPI;
import org.hyperledger.bpa.api.exception.WrongApiUsageException;
@@ -34,10 +34,7 @@
import org.hyperledger.bpa.persistence.repository.MyDocumentRepository;
import org.jetbrains.annotations.NotNull;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
-import java.util.SortedSet;
+import java.util.*;
/**
* Does some validation on incoming {@link MyDocumentAPI} objects. Like this we
@@ -77,16 +74,17 @@ public void validateExisting(@NonNull Optional existing, @NonNull My
validateInternal(newDocument);
}
- public void validateAttributesAgainstIndySchema(@NonNull JsonNode attributes, @NonNull String schemaId) {
+ public void validateAttributesAgainstIndySchema(@NonNull List attributes,
+ @NonNull String schemaId) {
// validate document data against schema
BPASchema schema = findSchema(schemaId);
Set attributeNames = schema.getSchemaAttributeNames();
// assuming flat structure
- attributes.fieldNames().forEachRemaining(fn -> {
- if (!attributeNames.contains(fn)) {
+ attributes.forEach(attr -> {
+ if (!attributeNames.contains(attr.getName())) {
throw new WrongApiUsageException(
ms.getMessage("api.document.validation.attribute.not.in.schema",
- Map.of("attr", fn)));
+ Map.of("attr", attr)));
}
});
}
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java
index e826bfa9f..4c9bd4ead 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/activity/LabelStrategy.java
@@ -17,7 +17,6 @@
*/
package org.hyperledger.bpa.impl.activity;
-import com.fasterxml.jackson.databind.JsonNode;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.micronaut.core.annotation.Nullable;
@@ -27,6 +26,7 @@
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.hyperledger.aries.api.credentials.Credential;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.aries.api.issue_credential_v1.V1CredentialExchange;
import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat;
import org.hyperledger.bpa.api.MyDocumentAPI;
@@ -37,7 +37,7 @@
import org.hyperledger.bpa.persistence.model.BPASchema;
import org.hyperledger.bpa.persistence.model.converter.ExchangePayload;
-import java.util.Map;
+import java.util.List;
import java.util.Optional;
/**
@@ -59,11 +59,10 @@ public class LabelStrategy {
public void apply(@NonNull MyDocumentAPI document) {
if (StringUtils.isBlank(document.getLabel())) {
findDefaultAttribute(document.getSchemaId()).ifPresent(attr -> {
- JsonNode documentData = document.getDocumentData();
- JsonNode value = documentData.findValue(attr);
+ List documentData = document.getDocumentData();
+ String value = documentData.stream().filter(a -> a.getName().equals(attr)).findFirst().get().getValue();
if (value != null) {
- String label = value.asText();
- document.setLabel(label);
+ document.setLabel(value);
}
});
}
@@ -73,8 +72,8 @@ public void apply(@NonNull MyDocumentAPI document) {
if (ariesCredential != null) {
Optional attr = findDefaultAttribute(ariesCredential.getSchemaId());
if (attr.isPresent() && ariesCredential.getAttrs() != null) {
- Map attrs = ariesCredential.getAttrs();
- return attrs.get(attr.get());
+ List attrs = (List) ariesCredential.getAttrs();
+ return attrs.stream().filter(a -> a.getName().equals(attr.get())).findFirst().get().getValue();
}
}
return null;
@@ -87,8 +86,8 @@ public void apply(@NonNull MyDocumentAPI document) {
} else {
Optional attr = findDefaultAttribute(ariesCredential.getSchemaId());
if (attr.isPresent() && ariesCredential.getCredentialData() != null) {
- Map attrs = ariesCredential.getCredentialData();
- mergedLabel = attrs.get(attr.get());
+ List attrs = ariesCredential.getCredentialData();
+ mergedLabel = attrs.stream().filter(a -> a.getName().equals(attr.get())).findFirst().get().getValue();
}
}
return mergedLabel;
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java
index 2e5b87969..49d5acc42 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/CredentialInfoResolver.java
@@ -98,7 +98,7 @@ public PresentationRequestCredentialsIndy.CredentialInfo populateCredentialInfo(
holderCredExRepo.findByReferent(matchingVC.getRecordId()).ifPresent(cred -> {
builder.credentialId(cred.getId());
builder.credentialLabel(cred.getLabel());
- builder.attrs(cred.credentialAttributesToMap());
+ builder.attrs(cred.credentialAttributesToCredentialAttributesList());
builder.referent(matchingVC.getRecordId());
});
}
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java
index 0b77d0d11..a52d312e4 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderIndyManager.java
@@ -50,7 +50,7 @@
import java.io.IOException;
import java.time.Instant;
-import java.util.Map;
+import java.util.List;
import java.util.Objects;
/**
@@ -77,7 +77,7 @@ public class HolderIndyManager {
public void sendCredentialProposal(
@NonNull String connectionId,
@NonNull String schemaId,
- @NonNull Map document,
+ @NonNull List document,
@NonNull BPACredentialExchange.BPACredentialExchangeBuilder dbCredEx,
@Nullable ExchangeVersion version)
throws IOException {
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java
index 5f5f021aa..694529a28 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderLDManager.java
@@ -17,7 +17,6 @@
*/
package org.hyperledger.bpa.impl.aries.credential;
-import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
@@ -26,6 +25,7 @@
import lombok.Setter;
import org.hyperledger.aries.AriesClient;
import org.hyperledger.aries.api.ExchangeVersion;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.aries.api.issue_credential_v1.BaseCredExRecord;
import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecord;
import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat;
@@ -43,7 +43,6 @@
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
import java.util.UUID;
@@ -78,13 +77,12 @@ public class HolderLDManager {
public void sendCredentialProposal(
@NonNull String connectionId,
@NonNull BPASchema s,
- @NonNull Map document,
+ @NonNull List document,
@NonNull BPACredentialExchange.BPACredentialExchangeBuilder dbCredEx)
throws IOException {
- JsonNode jsonNode = mapper.valueToTree(document);
V2CredentialExchangeFree v2Request = V2CredentialExchangeFree.builder()
.connectionId(UUID.fromString(connectionId))
- .filter(ldHelper.buildVC(s, jsonNode, Boolean.FALSE))
+ .filter(ldHelper.buildVC(s, document, Boolean.FALSE))
.build();
ac.issueCredentialV2SendProposal(v2Request).ifPresent(v2 -> dbCredEx
.threadId(v2.getThreadId())
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java
index 347e1bd0c..423bc0abe 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/HolderManager.java
@@ -29,6 +29,7 @@
import org.apache.commons.lang3.StringUtils;
import org.hyperledger.acy_py.generated.model.V20CredRequestRequest;
import org.hyperledger.aries.api.ExchangeVersion;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.aries.api.issue_credential_v1.BaseCredExRecord;
import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeRole;
import org.hyperledger.aries.api.issue_credential_v1.CredentialExchangeState;
@@ -136,7 +137,7 @@ public void sendCredentialProposal(@NonNull UUID partnerId, @NonNull UUID myDocI
.pushStateChange(CredentialExchangeState.PROPOSAL_SENT, Instant.now())
.role(CredentialExchangeRole.HOLDER);
String connectionId = Objects.requireNonNull(dbPartner.getConnectionId());
- Map document = Objects.requireNonNull(dbDoc.getDocument());
+ List document = Objects.requireNonNull(dbDoc.getDocument());
if (dbDoc.typeIsIndy()) {
indy.sendCredentialProposal(connectionId, s.getSchemaId(), document, dbCredEx, version);
} else {
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java
index d734cc306..093cca60b 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerIndyManager.java
@@ -55,9 +55,7 @@
import java.io.IOException;
import java.time.Instant;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -104,7 +102,8 @@ public BPACredentialExchange issueIndyCredential(
.orElseThrow(() -> new IssuerException(
msg.getMessage("api.issuer.creddef.not.found", Map.of("id", request.getCredDefId()))));
- Map document = conv.toStringMap(request.getDocument());
+ // TODO: Use object array with name, value and mime-type instead of Map
+ List document = request.getDocument();
checkCredentialAttributes(document, dbCredDef);
@@ -119,7 +118,7 @@ public BPACredentialExchange issueIndyCredential(
.builder()
.connectionId(Objects.requireNonNull(connectionId))
.schemaId(schemaId)
- .credentialProposal(new CredentialPreview(CredentialAttributes.fromMap(document)))
+ .credentialProposal(new CredentialPreview(request.getDocument()))
.credentialDefinitionId(credentialDefinitionId)
.build();
@@ -156,7 +155,7 @@ public void reIssueIndyCredential(@NonNull BPACredentialExchange credEx) {
issueIndyCredential(IssueCredentialRequest.IssueIndyCredentialRequest.builder()
.partnerId(credEx.getPartner() != null ? credEx.getPartner().getId() : null)
.credDefId(credEx.getCredDef() != null ? credEx.getCredDef().getId() : null)
- .document(conv.mapToNode(Objects.requireNonNull(credEx.getIndyCredential()).getAttrs()))
+ .document(new ArrayList<>(Objects.requireNonNull(credEx.getIndyCredential()).getAttrs()))
.exchangeVersion(credEx.getExchangeVersion())
.build());
} else {
@@ -187,7 +186,7 @@ public CredEx revokeIndyCredential(BPACredentialExchange credEx) {
}
}
- public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map attributes,
+ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull List attributes,
@NonNull IssuerManager.IdWrapper ids) throws IOException {
String credDefId = credEx.getCredDef() != null ? credEx.getCredDef().getCredentialDefinitionId() : null;
if (StringUtils.isNotEmpty(ids.credDefId()) && !StringUtils.equals(credDefId, ids.credDefId())) {
@@ -207,9 +206,11 @@ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map CredAttrSpec
+ .attributes(attributes.stream().map(attr -> CredAttrSpec
.builder()
- .name(a.getKey()).value(a.getValue())
+ .name(attr.getName())
+ .value(attr.getValue())
+ .mimeType(attr.getMimeType())
.build()).collect(Collectors.toList()))
.build())
.build())
@@ -235,8 +236,10 @@ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map document, BPACredentialDefinition dbCredDef) {
- Set documentAttributeNames = document.keySet();
+ private void checkCredentialAttributes(List document,
+ BPACredentialDefinition dbCredDef) {
+ Set documentAttributeNames = document.stream().map(CredentialAttributes::getName)
+ .collect(Collectors.toSet());
Set schemaAttributeNames = dbCredDef.getSchema().getSchemaAttributeNames();
if (!documentAttributeNames.equals(schemaAttributeNames)) {
throw new IssuerException(msg.getMessage("api.issuer.credential.document.mismatch",
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java
index 3cfbceef3..844f84ae2 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/credential/IssuerLDManager.java
@@ -17,7 +17,6 @@
*/
package org.hyperledger.bpa.impl.aries.credential;
-import com.fasterxml.jackson.databind.JsonNode;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import lombok.NonNull;
@@ -49,6 +48,7 @@
import java.io.IOException;
import java.time.Instant;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
@@ -78,7 +78,8 @@ public class IssuerLDManager {
@Inject
BPAMessageSource.DefaultMessageSource msg;
- public BPACredentialExchange issueLDCredential(UUID partnerId, UUID bpaSchemaId, JsonNode document) {
+ public BPACredentialExchange issueLDCredential(UUID partnerId, UUID bpaSchemaId,
+ List document) {
Partner partner = partnerRepo.findById(partnerId).orElseThrow(EntityNotFoundException::new);
BPASchema bpaSchema = schemaRepo.findById(bpaSchemaId).orElseThrow(EntityNotFoundException::new);
try {
@@ -116,7 +117,7 @@ public CredEx revokeLDCredential() {
throw new WrongApiUsageException(msg.getMessage("api.issuer.credential.send.not.supported"));
}
- public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map attributes,
+ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull List attributes,
@NonNull IssuerManager.IdWrapper ids) throws IOException {
String schemaId = credEx.getSchema() != null ? credEx.getSchema().getSchemaId() : null;
if (StringUtils.isNotEmpty(schemaId) && !StringUtils.equals(schemaId, ids.schemaId())) {
@@ -131,7 +132,7 @@ public CredEx sendOffer(@NonNull BPACredentialExchange credEx, @NotNull Map attributes;
+ List attributes;
if (counterOffer.acceptAll()) {
- attributes = credEx.proposalAttributesToMap();
+ attributes = credEx.proposalAttributesToCredentialAttributesList();
} else {
attributes = counterOffer.getAttributes();
}
@@ -367,7 +369,8 @@ public void handleV2CredentialExchange(@NonNull V20CredExRecord ex) {
if (ex.payloadIsIndy()) {
ex.getByFormat().findValuesInIndyCredIssue().ifPresent(
attr -> issuerCredExRepo.updateCredential(bpaEx.getId(),
- Credential.builder().attrs(attr).build()));
+ // TODO: Pass mime-type
+ Credential.builder().attrs(CredentialAttributes.from(attr)).build()));
} else {
issuerCredExRepo.updateCredential(bpaEx.getId(),
ExchangePayload.jsonLD(ex.resolveLDCredential()));
diff --git a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java
index bbf70ee13..827bdd1c5 100644
--- a/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java
+++ b/backend/business-partner-agent/src/main/java/org/hyperledger/bpa/impl/aries/jsonld/LDContextHelper.java
@@ -17,13 +17,13 @@
*/
package org.hyperledger.bpa.impl.aries.jsonld;
-import com.fasterxml.jackson.databind.JsonNode;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import io.micronaut.core.annotation.Nullable;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import lombok.NonNull;
+import org.hyperledger.aries.api.credentials.CredentialAttributes;
import org.hyperledger.aries.api.issue_credential_v2.V20CredExRecordByFormat;
import org.hyperledger.aries.api.issue_credential_v2.V2CredentialExchangeFree;
import org.hyperledger.aries.api.jsonld.ProofType;
@@ -79,7 +79,7 @@ public static String findSchemaId(@NonNull List