All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hyperledger.aries.api.present_proof.ProofRequestPresentation Maven / Gradle / Ivy

There is a newer version: 0.10.0
Show newest version
/*
 * Copyright (c) 2020-2021 - for information on the respective copyright owner
 * see the NOTICE file and/or the repository at
 * https://github.com/hyperledger-labs/acapy-java-client
 *
 * SPDX-License-Identifier: Apache-2.0
 */
package org.hyperledger.aries.api.present_proof;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * Connection less present proof request
 *
 * @see 
 * 0037-present-proof#request-presentation
 */
@Data
public class ProofRequestPresentation {

    @SerializedName("@id")
    private String id;

    @SerializedName("@type")
    private String type = "https://didcomm.org/present-proof/1.0/request-presentation";

    private String comment = "";

    @SerializedName("~service")
    private ServiceDecorator service;

    @SerializedName("request_presentations~attach")
    private List request;

    @SerializedName("~thread")
    private Thread thread;

    public ProofRequestPresentation(String ariesUri, String verkey, String threadId, String proofRequest) {
        this.id = threadId;
        this.service = new ServiceDecorator(ariesUri, verkey);
        this.request = List.of(new PresentationAttachment(proofRequest));
        this.thread = new Thread(threadId);
    }

    @Data
    public static class PresentationAttachment {
        @SerializedName("@id")
        private String id = "libindy-request-presentation-0";

        @SerializedName("mime-type")
        private String mimeType = "application/json";

        private Map data;

        public PresentationAttachment(String proofRequest) {
            this.data = Map.of("base64", proofRequest);
        }
    }

    @Data
    public static class ServiceDecorator {

        @SerializedName("recipientKeys")
        private List recipientKeys;

        @SerializedName("routingKeys")
        private List routingKeys = List.of();

        @SerializedName("serviceEndpoint")
        private String serviceEndpoint;

        public ServiceDecorator(String ariesUri, String verkey) {
            this.serviceEndpoint = ariesUri;
            this.recipientKeys = List.of(verkey);
        }
    }

    @Data
    public static class Thread {
        private String thid;
        private Integer senderOrder = 0;
        private Object receivedOrders;

        public Thread(String thid) {
            this.thid = thid;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy