PdfDigitalSignatureHashAlgorithm

Inheritance: java.lang.Object

public class PdfDigitalSignatureHashAlgorithm

Specifies a digital hash algorithm used by a digital signature.

Examples:

Shows how to sign a generated PDF document.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);
 builder.writeln("Contents of signed PDF.");

 CertificateHolder certificateHolder = CertificateHolder.create(getMyDir() + "morzal.pfx", "aw");

 // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
 // to modify how that method converts the document to .PDF.
 PdfSaveOptions options = new PdfSaveOptions();

 // Configure the "DigitalSignatureDetails" object of the "SaveOptions" object to
 // digitally sign the document as we render it with the "Save" method.
 Calendar calendar = Calendar.getInstance();
 calendar.set(2015, Calendar.JULY, 20);
 Date signingTime = calendar.getTime();
 options.setDigitalSignatureDetails(new PdfDigitalSignatureDetails(certificateHolder, "Test Signing", "My Office", signingTime));
 options.getDigitalSignatureDetails().setHashAlgorithm(PdfDigitalSignatureHashAlgorithm.RIPE_MD_160);

 Assert.assertEquals(options.getDigitalSignatureDetails().getReason(), "Test Signing");
 Assert.assertEquals(options.getDigitalSignatureDetails().getLocation(), "My Office");
 Assert.assertEquals(DocumentHelper.getLocalDate(options.getDigitalSignatureDetails().getSignatureDate()), DocumentHelper.getLocalDate(signingTime));

 doc.save(getArtifactsDir() + "PdfSaveOptions.PdfDigitalSignature.pdf", options);
 

Fields

FieldDescription
RIPE_MD_160RIPEMD-160 hash algorithm.
SHA_256SHA-256 hash algorithm.
SHA_384SHA-384 hash algorithm.
SHA_512SHA-512 hash algorithm.
length

Methods

MethodDescription
fromName(String pdfDigitalSignatureHashAlgorithmName)
getName(int pdfDigitalSignatureHashAlgorithm)
getValues()
toString(int pdfDigitalSignatureHashAlgorithm)

RIPE_MD_160

public static int RIPE_MD_160

RIPEMD-160 hash algorithm.

SHA_256

public static int SHA_256

SHA-256 hash algorithm.

SHA_384

public static int SHA_384

SHA-384 hash algorithm.

SHA_512

public static int SHA_512

SHA-512 hash algorithm.

length

public static int length

fromName(String pdfDigitalSignatureHashAlgorithmName)

public static int fromName(String pdfDigitalSignatureHashAlgorithmName)

Parameters:

ParameterTypeDescription
pdfDigitalSignatureHashAlgorithmNamejava.lang.String

Returns: int

getName(int pdfDigitalSignatureHashAlgorithm)

public static String getName(int pdfDigitalSignatureHashAlgorithm)

Parameters:

ParameterTypeDescription
pdfDigitalSignatureHashAlgorithmint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int pdfDigitalSignatureHashAlgorithm)

public static String toString(int pdfDigitalSignatureHashAlgorithm)

Parameters:

ParameterTypeDescription
pdfDigitalSignatureHashAlgorithmint

Returns: java.lang.String