SignatureCertificateRevocationStatus Class
Contains the revocation status of a signature certificate.
Declaration
public class SignatureCertificateRevocationStatus extends JavaObject
Remarks
The following methods return SignatureCertificateRevocationStatus objects:
- Pkcs7Signature.checkCertificateRevocation(atDateTime, tryFetchCrlOnline, tryFetchOcspOnline)
- LtvVerificationStatus.getCertificateRevocationStatuses()
Refer to the following help topic for additional information: Validate PDF Signatures — PDF Document API for Java.
Example
Check Certificate Revocation and Verify LTV Information
The following code snippet checks the revocation status of the Signature1 field signing certificate in Document.pdf and verifies LTV information for all signatures:
import java.io.*;
import java.nio.file.*;
import java.security.cert.X509Certificate;
import java.time.OffsetDateTime;
import java.util.Map;
import com.devexpress.docs.pdf.*;
public class Main {
public static void main(String[] args) throws Exception {
try (InputStream documentStream = Files.newInputStream(Path.of("Document.pdf"))) {
PdfSignatureValidator validator = new PdfSignatureValidator(documentStream);
Pkcs7Signature signature = validator.getPkcs7Signature("Signature1");
// Check whether the certificate was revoked at the timestamp time (or now if there is no timestamp).
OffsetDateTime checkDate = signature.getTimeStampDate() != null
? signature.getTimeStampDate() : OffsetDateTime.now();
SignatureCertificateRevocationStatus revocationStatus =
signature.checkCertificateRevocation(checkDate, true, true);
System.out.println("CRL revoked: " + revocationStatus.getIsCrlRevoked());
System.out.println("OCSP status: " + revocationStatus.getOcspRevocationStatus());
// Verify LTV information for all signatures.
for (LtvVerificationStatus ltvStatus : validator.verifyLtv(true, false, false)) {
System.out.println("LTV for " + ltvStatus.getSignatureFieldName() + ":");
for (Map.Entry<X509Certificate, SignatureCertificateRevocationStatus> item :
ltvStatus.getCertificateRevocationStatuses().entrySet())
System.out.println(" " + item.getKey().getSubjectX500Principal().getName()
+ ": " + item.getValue().getOcspRevocationStatus());
}
}
}
}
Inherited Members
Inheritance
Methods
getIsCrlFoundOnline() Method
Returns whether a Certificate Revocation List (CRL) downloaded from a server lists the certificate as revoked.
Declaration
public boolean getIsCrlFoundOnline()
Returns
| Type | Description |
|---|---|
| boolean |
|
Remarks
The API downloads CRLs only if you pass true as the tryFetchCrlOnline parameter and the signature or document does not contain CRLs.
getIsCrlRevoked() Method
Returns whether a Certificate Revocation List (CRL) lists the certificate as revoked.
Declaration
public boolean getIsCrlRevoked()
Returns
| Type | Description |
|---|---|
| boolean |
|
getIsOcspFoundOnline() Method
Returns whether the API received the certificate status from an Online Certificate Status Protocol (OCSP) responder.
Declaration
public boolean getIsOcspFoundOnline()
Returns
| Type | Description |
|---|---|
| boolean |
|
Remarks
The API requests the certificate status from an OCSP responder only if you pass true as the tryFetchOcspOnline parameter and embedded OCSP responses do not contain the certificate status.
getOcspRevocationStatus() Method
Returns the certificate status from an Online Certificate Status Protocol (OCSP) response.
Declaration
public OcspRevocationStatus getOcspRevocationStatus()
Returns
| Type | Description |
|---|---|
| OcspRevocationStatus | The certificate status. |
Remarks
The getOcspRevocationStatus() method returns one of the following values:
| Value | Description |
|---|---|
| NONE | No valid OCSP response contains the certificate status. |
| GOOD | The certificate is not revoked. |
| REVOKED | The certificate is revoked. |
| UNKNOWN | The OCSP responder does not know the certificate status. |
The getOcspRevocationStatus() method returns OcspRevocationStatus.GOOD only if the API validates the OCSP response signature.