-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds functions for creating a PDF PAdES and adding a signature [SFEQS-966] #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May you add some comments to clarify what's happening?
void generatePadesFile( | ||
File originalPdf, | ||
OutputStream outputStream, | ||
String signatureFieldId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if we have multiple signature fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, you have to indicate the signatureFieldId. If the signature already exists on that signatureFieldId an exception is thrown!
|
||
private static final Logger LOG = LoggerFactory.getLogger(Utility.class); | ||
|
||
static ByteRange getByteRange(DSSDocument documentToSign, String signatureFieldId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add some comments clarifying what's happening here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surely. I will try to clarify as best I can!
@@ -0,0 +1,36 @@ | |||
package it.pagopa.dss; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think this coverage is enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still lack addSignatureToPadesFile
coverage!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new test and coverage report!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brilliant!
); | ||
|
||
assertThat(signedByte).isEqualTo(signatureValue); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the Java framework but if any exceptions occurs here it looks like it's silently swallowed and the asertion would not be called, maybe it's better to avoid to catch it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, test fails anyway. However it is best to add a throws Exception
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it fails anyway? Because no assertion was called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, i thought that without a call to assertThat
the test failed instead it doesn't. I fixed by adding throws Exception
on test function.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
|
//converting the file into a DSS document (from dss library) | ||
DSSDocument documentToSign = new FileDocument(originalPdf); | ||
|
||
//initialization of PAdES parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this kind of comments add little value (are self-evident). instead I'd try to elaborate more ie. on what
parameters.setGenerateTBSWithoutCertificate(true);
does and why it must be set to true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK!
Co-authored-by: Danilo Spinelli <[email protected]>
Co-authored-by: Danilo Spinelli <[email protected]>
|
This PR implement:
generatePadesFile
addSignatureToPadesFile