Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #824 from boschresearch/feature/self-attested
Browse files Browse the repository at this point in the history
model updates to prepare for selective disclosure and self attested attributes
  • Loading branch information
etschelp authored Oct 6, 2022
2 parents cfbb4e0 + 8da30bb commit 8caaef8
Show file tree
Hide file tree
Showing 42 changed files with 34,540 additions and 19,241 deletions.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ If you want to run in web only mode you also have to set:

5. Access the UI

Swagger UI: http://localhost:8080/swagger-ui
Swagger UI: http://localhost:8080/swagger-ui/
Frontend: http://localhost:8080

##FAQ
Expand Down
34 changes: 17 additions & 17 deletions backend/business-partner-agent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>io.micronaut.email</groupId>
<artifactId>micronaut-email-mailjet</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<exclusions>
<exclusion>
<groupId>javax.activation</groupId>
Expand All @@ -123,7 +123,7 @@
<dependency><!-- Overwrite for jakarta-annotations-api -->
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-annotations-api</artifactId>
<version>10.1.0-M17</version>
<version>10.1.0</version>
</dependency>

<!-- Logging -->
Expand All @@ -137,7 +137,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
</dependency>
<!-- .yml log files -->
<dependency>
Expand All @@ -149,7 +149,7 @@
<dependency>
<groupId>network.idu.acapy</groupId>
<artifactId>aries-client-python</artifactId>
<version>0.7.29</version>
<version>0.7.30</version>
</dependency>
<dependency>
<groupId>org.hyperledger.business-partner-agent</groupId>
Expand Down Expand Up @@ -267,7 +267,7 @@
<version>${maven.compiler.plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-J-Dmicronaut.openapi.views.spec=redoc.enabled=true,rapidoc.enabled=true,swagger-ui.enabled=true,swagger-ui.theme=flattop</arg>
<arg>-Amicronaut.openapi.views.spec=rapidoc.enabled=false,swagger-ui.enabled=true,swagger-ui.theme=flattop</arg>
<arg>-Amicronaut.processing.group=org.hyperledger.business-partner-agent</arg>
<arg>-Amicronaut.processing.module=business-partner-agent</arg>
</compilerArgs>
Expand All @@ -282,26 +282,26 @@
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>io.micronaut.openapi</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>${micronaut.openapi.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.security</groupId>
<artifactId>micronaut-security-annotations</artifactId>
<version>${micronaut.security.version}</version>
</path>
<path>
<groupId>io.micronaut.data</groupId>
<artifactId>micronaut-data-processor</artifactId>
<version>${micronaut.data.version}</version>
</path>
<path>
<groupId>io.micronaut.openapi</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>${micronaut.openapi.version}</version>
</path>
<path>
<groupId>io.micronaut.security</groupId>
<artifactId>micronaut-security-annotations</artifactId>
<version>${micronaut.security.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down Expand Up @@ -443,8 +443,8 @@
</goals>
<configuration>
<!-- See https://nodejs.org/en/download/ -->
<nodeVersion>v16.15.1</nodeVersion>
<npmVersion>8.11.0</npmVersion>
<nodeVersion>v16.17.1</nodeVersion>
<npmVersion>8.15.0</npmVersion>
</configuration>
</execution>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import lombok.*;
import org.hyperledger.aries.api.ExchangeVersion;
import org.hyperledger.aries.api.present_proof.PresentProofRequest;
import org.hyperledger.aries.api.present_proof.PresentProofRequest.ProofRequest.ProofRequestedPredicates;
import org.hyperledger.aries.api.present_proof.PresentationExchangeRecord;
import org.hyperledger.aries.api.present_proof.PresentationExchangeRole;
import org.hyperledger.aries.api.present_proof.PresentationExchangeState;
import org.hyperledger.bpa.api.CredentialType;
Expand All @@ -40,6 +42,7 @@ public class AriesProofExchange {

private UUID id;
private UUID partnerId;
private UUID proofTemplateId;

private ExchangeVersion exchangeVersion;
private PresentationExchangeState state;
Expand All @@ -62,6 +65,7 @@ public static AriesProofExchange from(@NonNull PartnerProof p) {
return b
.id(p.getId())
.partnerId(p.getPartner().getId())
.proofTemplateId(p.getProofTemplate() != null ? p.getProofTemplate().getId() : null)
.state(p.getState())
.proofRequest(p.getProofRequest() != null ? p.getProofRequest().getIndy() : null)
.role(p.getRole())
Expand Down Expand Up @@ -92,6 +96,8 @@ public static class Identifier {
public static class RevealedAttributeGroup {
@Singular
private Map<String, String> revealedAttributes;
private ProofRequestedPredicates requestedPredicates;
private Identifier identifier;
private PresentationExchangeRecord.RequestedProofType proofType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.hyperledger.bpa.config.BPAMessageSource;
import org.hyperledger.bpa.controller.api.invitation.APICreateInvitationResponse;
import org.hyperledger.bpa.controller.api.issuer.DeclineExchangeRequest;
import org.hyperledger.bpa.controller.api.partner.ApproveProofRequest;
import org.hyperledger.bpa.controller.api.proof.ApproveProofRequest;
import org.hyperledger.bpa.controller.api.partner.RequestProofRequest;
import org.hyperledger.bpa.controller.api.partner.SendProofRequest;
import org.hyperledger.bpa.controller.api.proof.PresentationRequestCredentialsIndy;
Expand Down Expand Up @@ -96,7 +96,7 @@ public HttpResponse<List<PresentationRequestCredentialsIndy>> getMatchingLDCrede
* @return HTTP status
*/
@Post("/{id}/prove")
public HttpResponse<Void> responseToProofRequest(@PathVariable UUID id, @Body @Nullable ApproveProofRequest req) {
public HttpResponse<Void> responseToProofRequest(@PathVariable UUID id, @Body @Valid ApproveProofRequest req) {
proofM.presentProof(id, req);
return HttpResponse.ok();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 - for information on the respective copyright owner
* Copyright (c) 2020-2022 - for information on the respective copyright owner
* see the NOTICE file and/or the repository at
* https://github.com/hyperledger-labs/business-partner-agent
*
Expand All @@ -17,21 +17,14 @@
*/
package org.hyperledger.bpa.controller.api.activity;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public enum ActivityRole {
@JsonProperty("connection_request_sender")
CONNECTION_REQUEST_SENDER,
@JsonProperty("connection_request_recipient")
CONNECTION_REQUEST_RECIPIENT,
@JsonProperty("credential_exchange_holder")
CREDENTIAL_EXCHANGE_HOLDER,
@JsonProperty("credential_exchange_issuer")
CREDENTIAL_EXCHANGE_ISSUER,
@JsonProperty("presentation_exchange_prover")
PRESENTATION_EXCHANGE_PROVER,
@JsonProperty("presentation_exchange_verifier")
PRESENTATION_EXCHANGE_VERIFIER,
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 - for information on the respective copyright owner
* Copyright (c) 2020-2022 - for information on the respective copyright owner
* see the NOTICE file and/or the repository at
* https://github.com/hyperledger-labs/business-partner-agent
*
Expand All @@ -17,34 +17,20 @@
*/
package org.hyperledger.bpa.controller.api.activity;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public enum ActivityState {
@JsonProperty("connection_request_received")
CONNECTION_REQUEST_RECEIVED,
@JsonProperty("connection_request_sent")
CONNECTION_REQUEST_SENT,
@JsonProperty("connection_request_accepted")
CONNECTION_REQUEST_ACCEPTED,
@JsonProperty("credential_exchange_sent")
CREDENTIAL_EXCHANGE_SENT,
@JsonProperty("credential_exchange_received")
CREDENTIAL_EXCHANGE_RECEIVED,
@JsonProperty("credential_exchange_accepted")
CREDENTIAL_EXCHANGE_ACCEPTED,
@JsonProperty("credential_exchange_declined")
CREDENTIAL_EXCHANGE_DECLINED,
@JsonProperty("credential_exchange_problem")
CREDENTIAL_EXCHANGE_PROBLEM,
@JsonProperty("presentation_exchange_sent")
PRESENTATION_EXCHANGE_SENT,
@JsonProperty("presentation_exchange_received")
PRESENTATION_EXCHANGE_RECEIVED,
@JsonProperty("presentation_exchange_accepted")
PRESENTATION_EXCHANGE_ACCEPTED,
@JsonProperty("presentation_exchange_declined")
PRESENTATION_EXCHANGE_DECLINED,

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021 - for information on the respective copyright owner
* Copyright (c) 2020-2022 - for information on the respective copyright owner
* see the NOTICE file and/or the repository at
* https://github.com/hyperledger-labs/business-partner-agent
*
Expand All @@ -17,15 +17,11 @@
*/
package org.hyperledger.bpa.controller.api.activity;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.NoArgsConstructor;

@NoArgsConstructor
public enum ActivityType {
@JsonProperty("connection_request")
CONNECTION_REQUEST,
@JsonProperty("credential_exchange")
CREDENTIAL_EXCHANGE,
@JsonProperty("presentation_exchange")
PRESENTATION_EXCHANGE
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2020-2022 - for information on the respective copyright owner
* see the NOTICE file and/or the repository at
* https://github.com/hyperledger-labs/business-partner-agent
*
* Licensed 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.hyperledger.bpa.controller.api.proof;

import io.micronaut.core.annotation.Introspected;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hyperledger.aries.api.present_proof.SendPresentationRequestHelper;

import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
@Introspected
public class ApproveProofRequest {

@NotEmpty
private Map<String, SelectedReferent> selectedReferents;

@Data
@NoArgsConstructor
public static class SelectedReferent {
private String referent;
private Boolean revealed;
private String selfAttestedValue;
}

public Map<String, SendPresentationRequestHelper.SelectedMatch.ReferentInfo> toClientAPI() {
return selectedReferents.entrySet().stream()
.map(e -> Map.entry(e.getKey(),
SendPresentationRequestHelper.SelectedMatch.ReferentInfo.builder()
.referent(e.getValue().getReferent())
.revealed(e.getValue().getRevealed())
.selfAttestedValue(e.getValue().getSelfAttestedValue())
.build()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}

public List<String> collectReferents() {
return selectedReferents.values().stream()
.map(SelectedReferent::getReferent)
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import lombok.extern.slf4j.Slf4j;
import org.hyperledger.aries.api.present_proof.BasePresExRecord;
import org.hyperledger.aries.api.present_proof.PresentProofRequest;
import org.hyperledger.aries.api.present_proof.PresentationExchangeRecord;
import org.hyperledger.aries.api.present_proof.PresentationExchangeState;
import org.hyperledger.aries.api.present_proof_v2.V20PresExRecord;
import org.hyperledger.aries.api.present_proof_v2.V2DIFProofRequest;
Expand Down Expand Up @@ -141,13 +140,11 @@ private void handleProofRequest(@NonNull BasePresExRecord proof) {
pProof.setProofRequest(ExchangePayload.buildForProofRequest(dif));
}
pProofRepo.update(pProof);
if (proof.isNotAutoPresent()) {
if (proof instanceof V20PresExRecord dif) {
proofManager.acceptDifCredentialsFromProposal(dif, pProof);
} else if (proof instanceof PresentationExchangeRecord indy) {
proofManager.acceptSelectedIndyCredentials(null, pProof.getExchangeVersion(),
indy);
}
if (proof.isNotAutoPresent() && proof instanceof V20PresExRecord dif) {
// anoncred based proposals are always set to auto-present
// this does not work for dif exchanges, so they are handled
// explicitly here
proofManager.acceptDifCredentialsFromProposal(dif, pProof);
}
}
}, () -> {
Expand Down
Loading

0 comments on commit 8caaef8

Please sign in to comment.