Package com.itextpdf.text.pdf.security
Class PrivateKeySignature
java.lang.Object
com.itextpdf.text.pdf.security.PrivateKeySignature
- All Implemented Interfaces:
ExternalSignature
Implementation of the ExternalSignature interface that can be used
when you have a PrivateKey object.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The encryption algorithm (obtained from the private key)private String
The hash algorithm.private PrivateKey
The private key object.private String
The security provider -
Constructor Summary
ConstructorsConstructorDescriptionPrivateKeySignature
(PrivateKey pk, String hashAlgorithm, String provider) Creates an ExternalSignature instance -
Method Summary
Modifier and TypeMethodDescriptionReturns the encryption algorithm used for signing.Returns the hash algorithm.byte[]
sign
(byte[] b) Signs it using the encryption algorithm in combination with the digest algorithm.
-
Field Details
-
pk
The private key object. -
hashAlgorithm
The hash algorithm. -
encryptionAlgorithm
The encryption algorithm (obtained from the private key) -
provider
The security provider
-
-
Constructor Details
-
PrivateKeySignature
Creates an ExternalSignature instance- Parameters:
pk
- a PrivateKey objecthashAlgorithm
- the hash algorithm (e.g. "SHA-1", "SHA-256",...)provider
- the security provider (e.g. "BC")
-
-
Method Details
-
getHashAlgorithm
Returns the hash algorithm.- Specified by:
getHashAlgorithm
in interfaceExternalSignature
- Returns:
- the hash algorithm (e.g. "SHA-1", "SHA-256,...")
- See Also:
-
getEncryptionAlgorithm
Returns the encryption algorithm used for signing.- Specified by:
getEncryptionAlgorithm
in interfaceExternalSignature
- Returns:
- the encryption algorithm ("RSA" or "DSA")
- See Also:
-
sign
Signs it using the encryption algorithm in combination with the digest algorithm.- Specified by:
sign
in interfaceExternalSignature
- Parameters:
message
- the message you want to be hashed and signed- Returns:
- a signed message digest
- Throws:
GeneralSecurityException
-