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

com.adobe.pdfservices.operation.internal.dto.request.electronicseal.SealParams Maven / Gradle / Ivy

Go to download

Adobe PDF Services SDK allows you to access RESTful APIs to create, convert, and manipulate PDFs within your applications. Older versions can be found under groupId: com.adobe.documentservices, artifactId: pdftools-sdk

There is a newer version: 4.2.0
Show newest version
/*
 * Copyright 2024 Adobe
 * All Rights Reserved.
 *
 * NOTICE: Adobe permits you to use, modify, and distribute this file in
 * accordance with the terms of the Adobe license agreement accompanying
 * it. If you have received this file from a source other than Adobe,
 * then your use, modification, or distribution of it requires the prior
 * written permission of Adobe.
 */

package com.adobe.pdfservices.operation.internal.dto.request.electronicseal;

import com.adobe.pdfservices.operation.pdfjobs.params.electronicseal.AppearanceOptions;
import com.adobe.pdfservices.operation.pdfjobs.params.electronicseal.CSCCredential;
import com.adobe.pdfservices.operation.pdfjobs.params.electronicseal.DocumentLevelPermission;
import com.adobe.pdfservices.operation.pdfjobs.params.electronicseal.FieldOptions;
import com.adobe.pdfservices.operation.pdfjobs.params.electronicseal.PDFElectronicSealParams;
import com.adobe.pdfservices.operation.pdfjobs.params.electronicseal.SignatureFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class SealParams {

    @JsonProperty("signatureFormat")
    private String signatureFormat;

    @JsonProperty("cscCredentialOptions")
    private CertificateCredentialParams certificateCredentialParams;

    @JsonProperty("sealFieldOptions")
    private FieldParams fieldParams;

    @JsonProperty("documentLevelPermission")
    private String documentLevelPermission;

    @JsonProperty("tsaOptions")
    private TSAParams tsaParams;

    @JsonProperty("sealAppearanceOptions")
    private AppearanceParams appearanceParams;

    public SealParams(PDFElectronicSealParams pdfElectronicSealParams) {
        String signatureFormat = Objects.nonNull(pdfElectronicSealParams.getSignatureFormat()) ?
                                 pdfElectronicSealParams.getSignatureFormat()
                .toString() : SignatureFormat.PKCS7.toString();

        CertificateCredentialParams certificateCredentialParams =
                CertificateCredentialParams.getCSCCredentialParams((CSCCredential) pdfElectronicSealParams.getCertificateCredentials());

        FieldOptions fieldOptions = pdfElectronicSealParams.getFieldOptions();
        FieldParams fieldParams = new FieldParams(fieldOptions);

        String documentLevelPermission = Objects.nonNull(pdfElectronicSealParams.getDocumentLevelPermission()) ?
                                         pdfElectronicSealParams.getDocumentLevelPermission()
                .getValue() : DocumentLevelPermission.FORM_FILLING.getValue();

        TSAParams tsaParams = Objects.nonNull(pdfElectronicSealParams.getTSAOptions()) ?
                              new RFC3161TSAParams(pdfElectronicSealParams.getTSAOptions()) : null;

        this.appearanceParams = null;
        if (pdfElectronicSealParams.getFieldOptions().isVisible()) {
            AppearanceOptions appearanceOptions = pdfElectronicSealParams.getAppearanceOptions();
            this.appearanceParams = new AppearanceParams(appearanceOptions);
        }

        this.signatureFormat = signatureFormat;
        this.certificateCredentialParams = certificateCredentialParams;
        this.fieldParams = fieldParams;
        this.documentLevelPermission = documentLevelPermission;
        this.tsaParams = tsaParams;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy