Skip to content

Commit

Permalink
Merge branch 'DSS-3207' into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	dss-spi/src/main/java/eu/europa/esig/dss/spi/DSSASN1Utils.java
  • Loading branch information
bsanchezb committed Nov 7, 2024
2 parents 9d7feb5 + c2eaaf3 commit 2a69eaa
Show file tree
Hide file tree
Showing 143 changed files with 3,639 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.asic.cades.signature.asice;

import eu.europa.esig.dss.asic.cades.ASiCWithCAdESSignatureParameters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.asic.cades.signature.asics;

import eu.europa.esig.dss.asic.cades.ASiCWithCAdESSignatureParameters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.asic.xades.validation;

import eu.europa.esig.dss.diagnostic.DiagnosticData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.cades.signature;

import eu.europa.esig.dss.cades.CAdESSignatureParameters;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.cades.signature;

import eu.europa.esig.dss.cades.CAdESSignatureParameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,22 @@ The class `XmlDefinerUtils` is a singleton, therefore all changes performed on t

See section <<Alerts>> in chapter Annex for more information on alerts.

[[PdfMemoryUsageSetting]]
=== PDF Memory Usage Setting

Since DSS `6.2` it is possible to configure the memory usage on PDF reading. The feature is useful on document signing or validation, when a smart memory usage is crucial, for instance when processing big PDF files.

The configuration can be done using a `PdfMemoryUsageSetting` class, as shown below:

[source,java,indent=0]
.PdfMemoryUsageSetting configuration
----
include::{sourcetestdir}/eu/europa/esig/dss/cookbook/example/snippets/PAdESWithIPdfObjFactoryConfiguration.java[tags=pdf-memory-usage-setting]
----

NOTE: `PdfMemoryUsageSetting` is only supported in methods within `PAdESService` and `PDFDocumentValidator`.


[[DSSResourcesHandler]]
=== DSS Resources Handler

Expand Down Expand Up @@ -343,7 +359,6 @@ Since DSS `6.1` a `DSSResourcesHandler` may also be used for ASiC creation, allo
include::{sourcetestdir}/eu/europa/esig/dss/cookbook/example/sign/SignASiCEWithXAdESWithTempFileTest.java[tags=demo]
----


[[zipUtils]]
=== ZIP Utils

Expand Down
52 changes: 52 additions & 0 deletions dss-cookbook/src/main/asciidoc/_chapters/migration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,58 @@ SignatureWrapper signatureWrapper = ...
String filename = signatureWrapper.getFilename();
----

|PdfBoxUtils#generateScreenshot a|
[source,java]
----
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxUtils;
import eu.europa.esig.dss.model.DSSDocument;
DSSDocument screenshot = PdfBoxUtils.generateScreenshot(pdfDocument, page);
...
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxUtils;
import eu.europa.esig.dss.model.DSSDocument;
BufferedImage screenshot = PdfBoxUtils.generateBufferedImageScreenshot(pdfDocument, password, page);
----
a|
[source,java]
----
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxScreenshotBuilder;
import eu.europa.esig.dss.model.DSSDocument;
DSSDocument screenshot = PdfBoxScreenshotBuilder.fromDocument(pdfDocument).generateScreenshot(page);
...
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxScreenshotBuilder;
import eu.europa.esig.dss.model.DSSDocument;
BufferedImage screenshot = PdfBoxScreenshotBuilder.fromDocument(pdfDocument, password).generateBufferedImageScreenshot(page);
----

|PdfBoxUtils#generateSubtractionImage a|
[source,java]
----
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxUtils;
import eu.europa.esig.dss.model.DSSDocument;
DSSDocument subtractionImage = PdfBoxUtils.generateSubtractionImage(docOne, passwordOne, page, docTwo, passwordTwo, page,
tempFileResourcesHandlerBuilder.createResourcesHandler());
----
a|
[source,java]
----
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxUtils;
import eu.europa.esig.dss.pdf.pdfbox.PdfBoxScreenshotBuilder;
import eu.europa.esig.dss.model.DSSDocument;
BufferedImage screenshotOne = PdfBoxScreenshotBuilder.fromDocument(docOne, passwordOne)
.setDSSResourcesHandlerBuilder(tempFileResourcesHandlerBuilder).generateBufferedImageScreenshot(page);
BufferedImage screenshotTwo = PdfBoxScreenshotBuilder.fromDocument(docTwo, passwordTwo)
.setDSSResourcesHandlerBuilder(tempFileResourcesHandlerBuilder).generateBufferedImageScreenshot(page);
DSSDocument subtractionImage = PdfBoxUtils.generateSubtractionImage(screenshotOne, screenshotTwo);
----

|===

[cols="2,5,5"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.cookbook.example.sign;

import eu.europa.esig.dss.asic.common.definition.ASiCManifestElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts;

import java.awt.*;
import java.awt.Color;

public class PAdESVisibleSignatureSnippet {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import eu.europa.esig.dss.pades.alerts.ProtectedDocumentExceptionOnStatusAlert;
import eu.europa.esig.dss.pades.validation.PDFDocumentValidator;
import eu.europa.esig.dss.pdf.IPdfObjFactory;
import eu.europa.esig.dss.pdf.PdfMemoryUsageSetting;
import eu.europa.esig.dss.pdf.PdfPermissionsChecker;
import eu.europa.esig.dss.pdf.PdfSignatureFieldPositionChecker;
import eu.europa.esig.dss.pdf.ServiceLoaderPdfObjFactory;
Expand Down Expand Up @@ -84,6 +85,49 @@ public void demo() {
pdfObjFactory.setPdfSignatureFieldPositionChecker(pdfSignatureFieldPositionChecker);
// end::pdf-signature-field-position-checker[]

// tag::pdf-memory-usage-setting[]
// import eu.europa.esig.dss.pdf.PdfMemoryUsageSetting;

// Creates a configuration of memory usage on a PDF document reading,
// with the PDF document being fully load into the memory before parsing.
// NOTE: The setting is used by default.
PdfMemoryUsageSetting pdfFullInMemoryUsageSetting = PdfMemoryUsageSetting.memoryFull();

// Loads the parts of the PDF document into memory during its parsing
PdfMemoryUsageSetting pdfMemoryBufferedUsageSetting = PdfMemoryUsageSetting.memoryBuffered();

// Loads the parts of the PDF document into memory during its parsing.
// Allows definition of maximum number of bytes to be loaded into the memory.
// For example 2^20 bytes (1 Megabyte)
PdfMemoryUsageSetting pdfMemoryBufferedUsageWithLimitSetting = PdfMemoryUsageSetting.memoryBuffered(2^20);

// Loads the parts of the PDF document in the mixed mode, with bytes
// being allocated into the memory before the defined limit.
// All bytes after will be stored in a temporary file.
// For example 2^20 bytes (1 Megabyte).
PdfMemoryUsageSetting pdfMixedUsageSetting = PdfMemoryUsageSetting.mixed(2^20);

// Loads the parts of the PDF document in the mixed mode, with bytes
// being allocated into the memory before the defined limit.
// All bytes after will be stored in a temporary file before the defined limit.
// For example 2^20 bytes (1 Megabyte) for a memory storage limit,
// and 2^30 (1 Gigabyte) for a temporary file size limit.
PdfMemoryUsageSetting pdfMixedUsageWithTempFileLimitSetting = PdfMemoryUsageSetting.mixed(2^20, 2^30);

// Loads the parts of a PDF document into a temporary file in filesystem during parsing.
PdfMemoryUsageSetting pdfFileOnlyUsageSetting = PdfMemoryUsageSetting.fileOnly();

// Loads the parts of a PDF document into a temporary file in filesystem during parsing,
// before the specified limit.
// For example 2^30 (1 Gigabyte) for a temporary file size limit.
PdfMemoryUsageSetting pdfFileOnlyUsageWithLimitSetting = PdfMemoryUsageSetting.fileOnly(2^30);

// Provide chosen PdfMemoryUsageSetting to IPdfObjFactory instance
// defined in a PAdESService or PDFDocumentValidator
pdfObjFactory.setPdfMemoryUsageSetting(pdfFullInMemoryUsageSetting);

// end::pdf-memory-usage-setting[]

// Set the factory to the DocumentValidator
validator.setPdfObjFactory(pdfObjFactory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ public void testARLFile() throws Exception {
}
}

// @Ignore
@Test
public void testHugeCRL() throws Exception {
try (InputStream is = AbstractTestCRLUtils.class.getResourceAsStream("/esteid2011.crl");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.model.identifier;

import eu.europa.esig.dss.model.DSSException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.model.identifier;

import java.security.Key;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
/**
* DSS - Digital Signature Services
* Copyright (C) 2015 European Commission, provided under the CEF programme
*
* This file is part of the "DSS - Digital Signature Services" project.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package eu.europa.esig.dss.model.identifier;

import javax.security.auth.x500.X500Principal;
Expand Down
Loading

0 comments on commit 2a69eaa

Please sign in to comment.