====== Signature Structures ======
The sample codes are in the package ''tr.gov.tubitak.uekae.esya.api.xades.example.structures''.
===== Detached Signature =====
It is the signature where the signed data is separate from the signature document.
The code is in ''Detached''.
// create context with working directory
Context context = createContext();
// create signature according to context,
// with default type (XADES_BES)
XMLSignature signature = new XMLSignature(context);
// add document as reference, but do not embed it
// into the signature (embed=false)
signature.addDocument("./sample.txt", "text/plain", false);
signature.getSignedInfo().setSignatureMethod(SignatureMethod.RSA_SHA256);
// false-true gets non-qualified certificates while true-false gets qualified ones
X509Certificate cert = JSmartCardManager.getInstance().getSignatureCertificate(true, false);
// add certificate to show who signed the document
signature.addKeyInfo(new ECertificate(cert.getEncoded()));
// now sign it by using smart card
signature.sign(JSmartCardManager.getInstance().getSigner(PIN, cert));
signature.write(new FileOutputStream(BASE_DIR + SIGNATURE_FILENAME));
===== Enveloping Signature =====
It is the signature where the signed data is in the signature document.
The code is in ''Enveloping''.
// create context with working directory
Context context = createContext();
// create signature according to context,
// with default type (XADES_BES)
XMLSignature signature = new XMLSignature(context);
// add document as reference, and keep BASE64 version of data
// in an