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

eu.europa.esig.dss.asic.signature.asics.DataToSignASiCSWithCAdESFromArchive Maven / Gradle / Ivy

Go to download

DSS ASiC with CAdES contains the code for the creation and validation of ASiC containers with CAdES signature(s).

There is a newer version: 6.0.d4j.2
Show newest version
package eu.europa.esig.dss.asic.signature.asics;

import java.util.Collections;
import java.util.List;

import eu.europa.esig.dss.DSSDocument;
import eu.europa.esig.dss.DSSException;
import eu.europa.esig.dss.asic.ASiCParameters;
import eu.europa.esig.dss.asic.signature.GetDataToSignASiCWithCAdESHelper;
import eu.europa.esig.dss.utils.Utils;

public class DataToSignASiCSWithCAdESFromArchive extends AbstractGetDataToSignASiCSWithCAdES implements GetDataToSignASiCWithCAdESHelper {

	private final List embeddedSignatures;
	private final List embeddedSignedFiles;
	private final ASiCParameters asicParameters;

	public DataToSignASiCSWithCAdESFromArchive(List embeddedSignatures, List embeddedSignedFiles, ASiCParameters asicParameters) {
		this.embeddedSignatures = embeddedSignatures;
		this.embeddedSignedFiles = embeddedSignedFiles;
		this.asicParameters = asicParameters;
	}

	@Override
	public String getSignatureFilename() {
		return getSignatureFileName(asicParameters);
	}

	@Override
	public DSSDocument getToBeSigned() {
		int nbEmbeddedSignatures = Utils.collectionSize(embeddedSignatures);
		if (nbEmbeddedSignatures != 1) {
			throw new DSSException("Unable to select the embedded signature (nb found:" + nbEmbeddedSignatures + ")");
		}
		return embeddedSignatures.get(0);
	}

	@Override
	public List getDetachedContents() {
		return getSignedDocuments();
	}

	@Override
	public List getSignedDocuments() {
		int nbSignedFiles = Utils.collectionSize(embeddedSignedFiles);
		if (nbSignedFiles != 1) {
			throw new DSSException("Unable to select the document to be signed (nb found:" + nbSignedFiles + ")");
		}
		return embeddedSignedFiles;
	}

	@Override
	public List getManifestFiles() {
		// No manifest file in ASiC-S
		return Collections.emptyList();
	}

	@Override
	public List getSignatures() {
		return embeddedSignatures;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy