DocumentProcessor¶
- public class DocumentProcessor¶
Class describes all operations available on a document.
Methods¶
signDocument¶
- public static void signDocument(InputStream documentStream, PrivateKey privateKey, Certificate certificate, Map<String, Object> options, OutputStream signedDocumentStream)¶
Signs a document. The sign options are provided by the
options
parameter. It must be aMap
object with the following fields:DOCUMENT_SIGNATURE_FORMAT_KEY
: Format to use for signature, given as a string. It can take following value:DOCUMENT_SIGNATURE_FORMAT_PKCS7
for PKCS#7 signature
DOCUMENT_HASH_ALGORITHM_KEY
: Hash algorithm to use, given as a string. It can take the following values:DOCUMENT_HASH_ALGORITHM_SHA1
for SHA-1 algorithmDOCUMENT_HASH_ALGORITHM_SHA256
for SHA-256 algorithmDOCUMENT_HASH_ALGORITHM_SHA384
for SHA-384 algorithmDOCUMENT_HASH_ALGORITHM_SHA512
for SHA-512 algorithm
Note that this parameter may evolve in the future to handle more options.
- Parameters:
documentStream – The document to sign, given in an
InputStream
object.privateKey – A
PrivateKey
object with private attribute, which will be used to sign the document.certificate – A
Certificate
object corresponding to a certificate linked to the current private key, with correct signature usages.options – A
Map
as described above.signedDocumentStream – An
OutputStream
where the signed document will be written.
- Throws:
SCMException
– if an error occurred.