Skip to content

Commit 4837237

Browse files
author
Eugene Bochilo
committed
Make SignatureValidator public
DEVSIX-8390
1 parent c22b870 commit 4837237

23 files changed

+358
-169
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@
499499
<exclude>com.itextpdf.commons.bouncycastle</exclude>
500500
<exclude>com.itextpdf.pdfua.exceptions.PdfUAConformanceException</exclude>
501501
<exclude>com.itextpdf.signatures.validation.v1.DocumentRevisionsValidator</exclude>
502+
<exclude>com.itextpdf.signatures.validation.v1.SignatureValidator</exclude>
502503
</excludes>
503504
<excludeModules>
504505
<excludeModule>bouncy-castle-adapter</excludeModule>

sign/src/main/java/com/itextpdf/signatures/CRLVerifier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ This file is part of the iText (R) project.
3737
/**
3838
* Class that allows you to verify a certificate against
3939
* one or more Certificate Revocation Lists.
40+
*
41+
* @deprecated starting from 8.0.5.
42+
* {@link com.itextpdf.signatures.validation.v1.CRLValidator} should be used instead.
4043
*/
44+
@Deprecated
4145
public class CRLVerifier extends RootStoreVerifier {
4246

4347
/** The Logger instance */

sign/src/main/java/com/itextpdf/signatures/CertificateVerifier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ This file is part of the iText (R) project.
3434
* be used in a chain. It wraps another <code>CertificateVerifier</code>
3535
* that is the next element in the chain of which the <code>verify()</code>
3636
* method will be called.
37+
*
38+
* @deprecated starting from 8.0.5.
39+
* {@link com.itextpdf.signatures.validation.v1.CertificateChainValidator} should be used instead.
3740
*/
41+
@Deprecated
3842
public class CertificateVerifier {
3943

4044
/** The previous CertificateVerifier in the chain of verifiers. */

sign/src/main/java/com/itextpdf/signatures/LtvVerifier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ This file is part of the iText (R) project.
5656

5757
/**
5858
* Verifies the signatures in an LTV document.
59+
*
60+
* @deprecated starting from 8.0.5.
61+
* {@link com.itextpdf.signatures.validation.v1.SignatureValidator} should be used instead.
5962
*/
63+
@Deprecated
6064
public class LtvVerifier extends RootStoreVerifier {
6165

6266
private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory();

sign/src/main/java/com/itextpdf/signatures/OCSPVerifier.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ This file is part of the iText (R) project.
5151
/**
5252
* Class that allows you to verify a certificate against
5353
* one or more OCSP responses.
54+
*
55+
* @deprecated starting from 8.0.5.
56+
* {@link com.itextpdf.signatures.validation.v1.OCSPValidator} should be used instead.
5457
*/
58+
@Deprecated
5559
public class OCSPVerifier extends RootStoreVerifier {
5660

5761
private static final IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.getFactory();
@@ -330,7 +334,7 @@ && isSignatureValid(ocspResp, cert)) {
330334
}
331335
// 2.2. Try to check responderCert for revocation using Authority Information Access for OCSP responses
332336
// or CRL Distribution Points for CRL responses using default clients.
333-
IBasicOCSPResp responderOcspResp = new OcspClientBouncyCastle(null)
337+
IBasicOCSPResp responderOcspResp = new OcspClientBouncyCastle()
334338
.getBasicOCSPResp(responderCert, issuerCert, null);
335339
if (verifyOcsp(responderOcspResp, responderCert, issuerCert, ocspResp.getProducedAt())) {
336340
return;
@@ -402,7 +406,7 @@ public IBasicOCSPResp getOcspResponse(X509Certificate signCert, X509Certificate
402406
if (signCert == null && issuerCert == null) {
403407
return null;
404408
}
405-
OcspClientBouncyCastle ocsp = new OcspClientBouncyCastle(null);
409+
OcspClientBouncyCastle ocsp = new OcspClientBouncyCastle();
406410
return ocsp.getBasicOCSPResp(signCert, issuerCert, null);
407411
}
408412

sign/src/main/java/com/itextpdf/signatures/OcspClientBouncyCastle.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This file is part of the iText (R) project.
3535
import com.itextpdf.commons.utils.DateTimeUtil;
3636
import com.itextpdf.io.logs.IoLogMessageConstant;
3737
import com.itextpdf.io.util.StreamUtil;
38+
import com.itextpdf.signatures.validation.v1.OCSPValidator;
3839

3940
import java.io.IOException;
4041
import java.io.InputStream;
@@ -66,12 +67,21 @@ public class OcspClientBouncyCastle implements IOcspClient {
6667
*
6768
* @param verifier will be used for response verification.
6869
*
69-
* @see OCSPVerifier
70+
* @deprecated starting from 8.0.5. {@link OcspClientBouncyCastle#OcspClientBouncyCastle()} should be used instead.
71+
* If required, {@link IBasicOCSPResp} can be checked using {@link OCSPValidator} class.
7072
*/
73+
@Deprecated
7174
public OcspClientBouncyCastle(OCSPVerifier verifier) {
7275
this.verifier = verifier;
7376
}
7477

78+
/**
79+
* Creates new {@link OcspClientBouncyCastle} instance.
80+
*/
81+
public OcspClientBouncyCastle() {
82+
this.verifier = null;
83+
}
84+
7585
/**
7686
* Gets OCSP response. If {@link OCSPVerifier} was set, the response will be checked.
7787
*

sign/src/main/java/com/itextpdf/signatures/PdfPadesSigner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ void createRevocationClients(Certificate signingCert, boolean clientsRequired) {
514514
crlClient = new CrlClientOnline();
515515
}
516516
if (ocspClient == null) {
517-
ocspClient = new OcspClientBouncyCastle(null);
517+
ocspClient = new OcspClientBouncyCastle();
518518
}
519519
}
520520

sign/src/main/java/com/itextpdf/signatures/RootStoreVerifier.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ This file is part of the iText (R) project.
3232
/**
3333
* Verifies a certificate against a <code>KeyStore</code>
3434
* containing trusted anchors.
35+
*
36+
* @deprecated starting from 8.0.5.
37+
* {@link com.itextpdf.signatures.validation.v1.CertificateChainValidator} should be used instead.
3538
*/
39+
@Deprecated
3640
public class RootStoreVerifier extends CertificateVerifier {
3741

3842
/** A key store against which certificates can be verified. */

sign/src/main/java/com/itextpdf/signatures/VerificationOK.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ This file is part of the iText (R) project.
2828
* Class that informs you that the verification of a Certificate
2929
* succeeded using a specific CertificateVerifier and for a specific
3030
* reason.
31+
*
32+
* @deprecated starting from 8.0.5.
33+
* {@link com.itextpdf.signatures.validation.v1.report.ReportItem} should be used instead.
3134
*/
35+
@Deprecated
3236
public class VerificationOK {
3337

3438
/** The certificate that was verified successfully. */

sign/src/main/java/com/itextpdf/signatures/validation/v1/CertificateChainValidator.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ protected CertificateChainValidator(ValidatorChainBuilder builder) {
9595
*
9696
* @param crlClient {@link ICrlClient} to be used for CRL responses receiving
9797
*
98-
* @return same instance of {@link CertificateChainValidator}
98+
* @return same instance of {@link CertificateChainValidator}.
99+
*
100+
* @deprecated in favour of either {@link SignatureValidationProperties#addCrlClient}
101+
* or {@link RevocationDataValidator#addCrlClient}. TODO DEVSIX-8398 To be removed.
99102
*/
103+
@Deprecated
100104
public CertificateChainValidator addCrlClient(ICrlClient crlClient) {
101105
revocationDataValidator.addCrlClient(crlClient);
102106
return this;
@@ -107,8 +111,12 @@ public CertificateChainValidator addCrlClient(ICrlClient crlClient) {
107111
*
108112
* @param ocpsClient {@link IOcspClient} to be used for OCSP responses receiving
109113
*
110-
* @return same instance of {@link CertificateChainValidator}
114+
* @return same instance of {@link CertificateChainValidator}.
115+
*
116+
* @deprecated in favour of either {@link SignatureValidationProperties#addOcspClient}
117+
* or {@link RevocationDataValidator#addOcspClient}. TODO DEVSIX-8398 To be removed.
111118
*/
119+
@Deprecated
112120
public CertificateChainValidator addOcspClient(IOcspClient ocpsClient) {
113121
revocationDataValidator.addOcspClient(ocpsClient);
114122
return this;
@@ -122,7 +130,7 @@ public CertificateChainValidator addOcspClient(IOcspClient ocpsClient) {
122130
* @param validationDate {@link Date} against which certificate is expected to be validated. Usually signing
123131
* date
124132
*
125-
* @return {@link ValidationReport} which contains detailed validation results
133+
* @return {@link ValidationReport} which contains detailed validation results.
126134
*/
127135
public ValidationReport validateCertificate(ValidationContext context, X509Certificate certificate,
128136
Date validationDate) {
@@ -140,7 +148,7 @@ public ValidationReport validateCertificate(ValidationContext context, X509Certi
140148
* @param validationDate {@link Date} against which certificate is expected to be validated. Usually signing
141149
* date
142150
*
143-
* @return {@link ValidationReport} which contains both provided and new validation results
151+
* @return {@link ValidationReport} which contains both provided and new validation results.
144152
*/
145153
public ValidationReport validate(ValidationReport result, ValidationContext context, X509Certificate certificate,
146154
Date validationDate) {

0 commit comments

Comments
 (0)