com.itextpdf.text.pdf.security
Class PrivateKeySignature

java.lang.Object
  extended by com.itextpdf.text.pdf.security.PrivateKeySignature
All Implemented Interfaces:
ExternalSignature

public class PrivateKeySignature
extends Object
implements ExternalSignature

Implementation of the ExternalSignature interface that can be used when you have a PrivateKey object.

Author:
Paulo Soares

Constructor Summary
PrivateKeySignature(PrivateKey pk, String hashAlgorithm, String provider)
          Creates an ExternalSignature instance
 
Method Summary
 String getEncryptionAlgorithm()
          Returns the encryption algorithm used for signing.
 String getHashAlgorithm()
          Returns the hash algorithm.
 byte[] sign(byte[] b)
          Signs it using the encryption algorithm in combination with the digest algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrivateKeySignature

public PrivateKeySignature(PrivateKey pk,
                           String hashAlgorithm,
                           String provider)
Creates an ExternalSignature instance

Parameters:
pk - a PrivateKey object
hashAlgorithm - the hash algorithm (e.g. "SHA-1", "SHA-256",...)
provider - the security provider (e.g. "BC")
Method Detail

getHashAlgorithm

public String getHashAlgorithm()
Returns the hash algorithm.

Specified by:
getHashAlgorithm in interface ExternalSignature
Returns:
the hash algorithm (e.g. "SHA-1", "SHA-256,...")
See Also:
ExternalSignature.getHashAlgorithm()

getEncryptionAlgorithm

public String getEncryptionAlgorithm()
Returns the encryption algorithm used for signing.

Specified by:
getEncryptionAlgorithm in interface ExternalSignature
Returns:
the encryption algorithm ("RSA" or "DSA")
See Also:
ExternalSignature.getEncryptionAlgorithm()

sign

public byte[] sign(byte[] b)
            throws GeneralSecurityException
Signs it using the encryption algorithm in combination with the digest algorithm.

Specified by:
sign in interface ExternalSignature
Parameters:
message - the message you want to be hashed and signed
Returns:
a signed message digest
Throws:
GeneralSecurityException


Copyright © 2013. All Rights Reserved.