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

dev.fitko.fitconnect.client.sender.model.SendableEncryptedSubmission Maven / Gradle / Ivy

Go to download

Library that provides client access to the FIT-Connect api-endpoints for sending, subscribing and routing

There is a newer version: 2.3.5
Show newest version
package dev.fitko.fitconnect.client.sender.model;

import dev.fitko.fitconnect.client.sender.steps.encrypted.EncryptedAttachmentsStep;
import dev.fitko.fitconnect.client.sender.steps.encrypted.EncryptedBuildStep;
import dev.fitko.fitconnect.client.sender.steps.encrypted.EncryptedDataStep;
import dev.fitko.fitconnect.client.sender.steps.encrypted.EncryptedDestinationStep;
import dev.fitko.fitconnect.client.sender.steps.encrypted.EncryptedMetadataStep;
import dev.fitko.fitconnect.client.sender.steps.encrypted.EncryptedServiceTypeStep;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Getter
public class SendableEncryptedSubmission {

    private final UUID destinationId;
    private final Map attachments;
    private final String data;
    private final String metadata;
    private final String serviceName;
    private final String serviceIdentifier;

    private SendableEncryptedSubmission(final Builder builder) {
        destinationId = builder.getDestinationId();
        attachments = Collections.unmodifiableMap(builder.getEncryptedAttachments());
        data = builder.getEncryptedData();
        metadata = builder.getEncryptedMetadata();
        serviceName = builder.getServiceName();
        serviceIdentifier = builder.getServiceIdentifier();
    }

    public static EncryptedDestinationStep Builder() {
        return new Builder();
    }

    @Getter
    private static final class Builder implements EncryptedDestinationStep,
            EncryptedServiceTypeStep,
            EncryptedMetadataStep,
            EncryptedDataStep,
            EncryptedAttachmentsStep,
            EncryptedBuildStep {

        private static final Logger LOGGER = LoggerFactory.getLogger(Builder.class);

        private UUID destinationId;
        private String serviceName;
        private String serviceIdentifier;
        private String encryptedData;
        private String encryptedMetadata;
        private final Map encryptedAttachments = new HashMap<>();

        private Builder() {
        }

        @Override
        public EncryptedServiceTypeStep setDestination(final UUID destinationId) {
            this.destinationId = destinationId;
            return this;
        }

        @Override
        public EncryptedAttachmentsStep addEncryptedAttachments(final Map attachments) {
            if (attachments != null) {
                encryptedAttachments.putAll(attachments);
            }
            return this;
        }

        @Override
        public EncryptedAttachmentsStep addEncryptedAttachment(final UUID id, final String content) {
            addEncryptedAttachments(Map.of(id, content));
            return this;
        }

        @Override
        public EncryptedAttachmentsStep setEncryptedData(final String data) {
            encryptedData = data;
            return this;
        }

        @Override
        public EncryptedDataStep setEncryptedMetadata(final String encryptedMetadata) {
            this.encryptedMetadata = encryptedMetadata;
            return this;
        }

        @Override
        public EncryptedMetadataStep setServiceType(final String serviceIdentifier, final String serviceName) {
            this.serviceIdentifier = serviceIdentifier;
            this.serviceName = serviceName;
            return this;
        }

        @Override
        public SendableEncryptedSubmission build() {
            return new SendableEncryptedSubmission(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy