All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pdftools.signaturevalidation.Certificate Maven / Gradle / Ivy

Go to download

The Pdftools SDK is a comprehensive development library that lets developers integrate advanced PDF functionalities into in-house applications.

There is a newer version: 1.8.0
Show newest version
/****************************************************************************
 *
 * File:            Certificate.java
 *
 * Description:     PDFTOOLS Certificate Class
 *
 * Author:          PDF Tools AG
 * 
 * Copyright:       Copyright (C) 2023 - 2024 PDF Tools AG, Switzerland
 *                  All rights reserved.
 * 
 * Notice:          By downloading and using this artifact, you accept PDF Tools AG's
 *                  [license agreement](https://www.pdf-tools.com/license-agreement/),
 *                  [privacy policy](https://www.pdf-tools.com/privacy-policy/),
 *                  and allow PDF Tools AG to track your usage data.
 *
 ***************************************************************************/

package com.pdftools.signaturevalidation;

import com.pdftools.sys.*;
import com.pdftools.internal.*;
import java.util.EnumSet;
import java.time.OffsetDateTime;
/**
 * 

A X.509 certificate

*/ public class Certificate extends NativeObject { protected Certificate(long handle) { super(handle); } /** * @hidden */ public static Certificate createDynamicObject(long handle) { return new Certificate(handle); } /** *

The name (subject) of the certificate (Getter)

* The common name (CN) of the person or authority that owns the certificate. */ public String getSubjectName() { String retVal = getSubjectNameNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: break; default: throwLastRuntimeException(); } } return retVal; } /** *

The subject of the certificate (Getter)

* The distinguished name (DN) of the person or authority that owns the certificate. * Formatted according to RFC 4514. */ public String getSubject() { String retVal = getSubjectNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return retVal; } /** *

The name of the certificate's issuer (CA) (Getter)

* The common name (CN) of the certificate authority (CA) that issued the certificate. */ public String getIssuerName() { String retVal = getIssuerNameNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: break; default: throwLastRuntimeException(); } } return retVal; } /** *

The date after which the certificate is no longer valid. (Getter)

* */ public OffsetDateTime getNotAfter() { OffsetDateTime retVal = getNotAfterNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: break; default: throwLastRuntimeException(); } } return retVal; } /** *

The date on which the certificate becomes valid. (Getter)

* */ public OffsetDateTime getNotBefore() { OffsetDateTime retVal = getNotBeforeNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: break; default: throwLastRuntimeException(); } } return retVal; } /** *

The certificate's fingerprint (Getter)

* The hex string representation of the certificate’s SHA-1 digest. */ public String getFingerprint() { String retVal = getFingerprintNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return retVal; } /** *

The raw data of the certificate as a byte array (Getter)

* */ public byte[] getRawData() { byte[] retVal = getRawDataNative(getHandle()); if (retVal == null) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return retVal; } /** *

Source of the certificate (Getter)

* */ public EnumSet getSource() { int retVal = getSourceNative(getHandle()); if (retVal == 0) { switch (getLastErrorCode()) { case 0: break; default: throwLastRuntimeException(); } } return getEnumSet(retVal, com.pdftools.signaturevalidation.DataSource.class); } /** *

Whether the certificate is valid according to the validation profile used (Getter)

* */ public com.pdftools.signaturevalidation.ConstraintResult getValidity() { long retHandle = getValidityNative(getHandle()); if (retHandle == 0) { switch (getLastErrorCode()) { case 0: throw new RuntimeException("An unexpected error occurred"); default: throwLastRuntimeException(); } } return com.pdftools.signaturevalidation.ConstraintResult.createDynamicObject(retHandle); } private native String getSubjectNameNative(long handle); private native String getSubjectNative(long handle); private native String getIssuerNameNative(long handle); private native OffsetDateTime getNotAfterNative(long handle); private native OffsetDateTime getNotBeforeNative(long handle); private native String getFingerprintNative(long handle); private native byte[] getRawDataNative(long handle); private native int getSourceNative(long handle); private native long getValidityNative(long handle); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy