ESYAE-imza Kütüphaneleri

User Tools

Site Tools


esya:xades:kod-imza-gelistirmeleri

Bu, dökümanın eski bir sürümüdür!


XAdES İmza Geliştirmeleri

Genel İmza Geliştirme

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ış İmzanın Geliştirmesi

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 İmza Geliştirmesi

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)));

esya/xades/kod-imza-gelistirmeleri.1375075922.txt.gz · Son değiştirilme: 2013/07/29 05:32 Değiştiren: Süleyman Uslu