To make my comment an answer...
I answer the questions last to first:
Question 2) I can get
COSBase
object but how can I getCOSDictionary
object?
Simply check whether the COSBase
you have got, also is an instance of COSDictionary
using instanceof
. If it is, cast to COSDictionary
.
Question 1) But how can I add another certificates here?
After casting (see above) you can get the contained Certs dictionary, and after casting that again, you can work in that dictionary, e.g. adding another certificate.
In reaction to the comment, you found the following to work as you desired:
COSDictionary dssDictionary = (COSDictionary) catalogDictionary.getDictionaryObject(COSName.getPDFName("DSS"));
While this certainly will work for valid PAdES part 4 / PDF version 2 document security stores, you in general should be aware that there are broken documents for which DSS in the catalog is of a different type. Thus, I would always check with instanceof
first.