Bu, dökümanın eski bir sürümüdür!
Mevcut imzanın okunmasının ardından geliştirme fonksiyonunun geliştirilmek istenen imza tipi parametresi ile çağırılması yeterlidir.
// create context with working directory Context context = createContext(); // read signature to be upgraded XMLSignature signature = XMLSignature.parse(new FileDocument(new File(BASE_DIR + "bes.xml")),context); // upgrade to T signature.upgrade(SignatureType.ES_T); signature.write(new FileOutputStream(BASE_DIR + SIGNATURE_FILENAME));
Zarflanmış imzalarda ise dökümanın okunması, içinden imzanın alınması, imzanın geliştirilmesi ve tekrar bütün dökümanın yazılması gerekir.
// create context with working directory Context context = createContext(); // parse the previously created enveloped signature org.w3c.dom.Document document = parseDoc(Enveloped.SIGNATURE_FILENAME, context); // get the signature in DOM document XMLSignature signature = readSignature(document, context); // upgrade the signature to type T signature.upgrade(SignatureType.ES_T); // writing enveloped XML to the file Source source = new DOMSource(document); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(source, new StreamResult(new FileOutputStream(BASE_DIR + SIGNATURE_FILENAME)));
Paralel imzaların geliştirmesinde ise geliştirilecek imzalar seçilip onlar üzerinden işlem yapılması gerekir.
// create context with working directory Context context = createContext(); // parse the previously created enveloped signature org.w3c.dom.Document document = parseDoc(ParallelDetached.SIGNATURE_FILENAME, context); // get and upgrade the signature 1 in DOM document XMLSignature signature1 = readSignature(document, context, 0); signature1.upgrade(SignatureType.ES_T); // get and upgrade the signature 2 in DOM document XMLSignature signature2 = readSignature(document, context, 1); signature2.upgrade(SignatureType.ES_T); // writing enveloped XML to the file Source source = new DOMSource(document); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(source, new StreamResult(new FileOutputStream(BASE_DIR + SIGNATURE_FILENAME)));