This package enables creating and verifying XML Signature for a given data source via the
interfaces SignatureCreator and SignatureVerifier. Data-source and the being
created signature are represented by {@link org.idoox.xml.Tokenizer Tokenizer}.
Class SignatureFactory is used to create the objects that implement SignatureCreator
and SignatureVerifier interfaces.
When creating XML signature, some transformations may by applied on the data source. The class
Transform provides the implemented transformations. It also enables application
to register and to use a application defined transformation.
XML Signature contains KeyInfo element that provides information about public key
or certificate used to sign. The specification allows application defined structure of contain of
the KeyInfo element. The classes KeyContentFactory, KeyContent
and KeyValueContent allow using implemented types of the KeyInfo element
and also application defined KeyInfo element.
Example of creating XML Signature:
Tokenizer dataSource;
java.security.PrivateKey privateKey;
java.security.PublicKey publicKey;
...
/* set privateKey, publicKey and dataSource */
...
SignatureCreator creator = SignatureFactory.getInstance().getSignatureCreator();
Tokenizer sign = creator.createSignature(dataSource, privateKey, publicKey);
Example of verifying XML Signature:
Tokenizer sign;
Tokenizer dataSource;
...
/* sign and dataSource must be set here*/
...
boolean verified = SignatureFactory.getInstance().getSignatureVerifier().verify(sign, dataSource);
if(verified){
System.out.println("OK, verifying signature passed");
}
else{
System.out.println("ERR, verifying signature not passed!!!");
}