com.itextpdf.text.pdf.security
Class DigestAlgorithms

java.lang.Object
  extended by com.itextpdf.text.pdf.security.DigestAlgorithms

public class DigestAlgorithms
extends java.lang.Object

Class that contains a map with the different message digest algorithms.


Field Summary
static java.lang.String RIPEMD160
          Algorithm available for signatures since PDF 1.7
static java.lang.String SHA1
          Algorithm available for signatures since PDF 1.3
static java.lang.String SHA256
          Algorithm available for signatures since PDF 1.6
static java.lang.String SHA384
          Algorithm available for signatures since PDF 1.7
static java.lang.String SHA512
          Algorithm available for signatures since PDF 1.7
 
Constructor Summary
DigestAlgorithms()
           
 
Method Summary
static byte[] digest(java.io.InputStream data, java.security.MessageDigest messageDigest)
           
static byte[] digest(java.io.InputStream data, java.lang.String hashAlgorithm, java.lang.String provider)
          Creates a hash using a specific digest algorithm and a provider.
static java.lang.String getAllowedDigests(java.lang.String name)
          Returns the id of a digest algorithms that is allowed in PDF, or null if it isn't allowed.
static java.lang.String getDigest(java.lang.String oid)
          Gets the digest name for a certain id
static java.security.MessageDigest getMessageDigest(java.lang.String hashAlgorithm, java.lang.String provider)
          Creates a MessageDigest object that can be used to create a hash.
static java.security.MessageDigest getMessageDigestFromOid(java.lang.String digestOid, java.lang.String provider)
           
static java.lang.String normalizeDigestName(java.lang.String algo)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHA1

public static final java.lang.String SHA1
Algorithm available for signatures since PDF 1.3

See Also:
Constant Field Values

SHA256

public static final java.lang.String SHA256
Algorithm available for signatures since PDF 1.6

See Also:
Constant Field Values

SHA384

public static final java.lang.String SHA384
Algorithm available for signatures since PDF 1.7

See Also:
Constant Field Values

SHA512

public static final java.lang.String SHA512
Algorithm available for signatures since PDF 1.7

See Also:
Constant Field Values

RIPEMD160

public static final java.lang.String RIPEMD160
Algorithm available for signatures since PDF 1.7

See Also:
Constant Field Values
Constructor Detail

DigestAlgorithms

public DigestAlgorithms()
Method Detail

getMessageDigestFromOid

public static java.security.MessageDigest getMessageDigestFromOid(java.lang.String digestOid,
                                                                  java.lang.String provider)
                                                           throws java.security.NoSuchAlgorithmException,
                                                                  java.security.NoSuchProviderException
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException

getMessageDigest

public static java.security.MessageDigest getMessageDigest(java.lang.String hashAlgorithm,
                                                           java.lang.String provider)
                                                    throws java.security.NoSuchAlgorithmException,
                                                           java.security.NoSuchProviderException
Creates a MessageDigest object that can be used to create a hash.

Parameters:
hashAlgorithm - the algorithm you want to use to create a hash
provider - the provider you want to use to create the hash
Returns:
a MessageDigest object
Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.GeneralSecurityException

digest

public static byte[] digest(java.io.InputStream data,
                            java.lang.String hashAlgorithm,
                            java.lang.String provider)
                     throws java.security.GeneralSecurityException,
                            java.io.IOException
Creates a hash using a specific digest algorithm and a provider.

Parameters:
data - the message of which you want to create a hash
hashAlgorithm - the algorithm used to create the hash
provider - the provider used to create the hash
Returns:
the hash
Throws:
java.security.GeneralSecurityException
java.io.IOException

digest

public static byte[] digest(java.io.InputStream data,
                            java.security.MessageDigest messageDigest)
                     throws java.security.GeneralSecurityException,
                            java.io.IOException
Throws:
java.security.GeneralSecurityException
java.io.IOException

getDigest

public static java.lang.String getDigest(java.lang.String oid)
Gets the digest name for a certain id

Parameters:
oid - an id (for instance "1.2.840.113549.2.5")
Returns:
a digest name (for instance "MD5")

normalizeDigestName

public static java.lang.String normalizeDigestName(java.lang.String algo)

getAllowedDigests

public static java.lang.String getAllowedDigests(java.lang.String name)
Returns the id of a digest algorithms that is allowed in PDF, or null if it isn't allowed.

Parameters:
name - the name of the digest algorithm
Returns:
an oid


Copyright © 2013. All Rights Reserved.