The third and last part of the XMLDSig tutorial. Make sure you don’t miss the previous entries:
- Interoperable XML Digital Signatures (C#-Java), part 1
- Interoperable XML Digital Signatures (C#-Java), part 2
In this part of the tutorial we will learn how to create and validate XML digital signatures in Java. Let’s start with the interface:
Again, we will provide three implementations of the interface, for Enveloped, Enveloping and Detached signatures.
Let’s start however with the certificate manager:
We also need a Java-specific helper class to extract X509 certificates from existing signatures:
Similar to C#, we will have a common base class for all three types of signatures. The common base class will contain a method do verify signatures and the same verification code will apply to three different types of signatures:
And now the three providers.
Enveloping. Straightforward (compare to C# case).
All these three implementations allow me to sign my XML documents with a signature of my choice. Also, all three should correctly verify signed documents.
Now, as both C# and Java sign and verify, the reader is encouraged to conduct experiments that test the interoperability of provided implementation.