eu.europa.esig.dss.asic.signature.asics.DataToSignASiCSWithCAdESFromArchive Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dss-asic-cades Show documentation
Show all versions of dss-asic-cades Show documentation
DSS ASiC with CAdES contains the code for the creation and validation of ASiC containers with CAdES signature(s).
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;
}
}