ESYAE-imza Kütüphaneleri

User Tools

Site Tools


esya:xades:kod-e-fatura

Farklar

Bu sayfanın seçili sürümü ile mevcut sürümü arasındaki farkları gösterir.

Karşılaştırma görünümüne bağlantı

esya:xades:kod-e-fatura [2013/10/02 08:16]
Süleyman Uslu
esya:xades:kod-e-fatura [2013/10/09 06:12] (mevcut)
Süleyman Uslu
Satır 2: Satır 2:
  
  
-Not: .NET ile e-fatura imzalanacağı vakit, XML yapısında olan+Not: .NET ile e-fatura imzalanacağı vakit, XML yapısında olan faturanın düzgün bir şekilde okunup işlenmesi gerekiyor. Okuma kod örneği için ''​tr.gov.tubitak.uekae.esya.api.xades.example.utils.SampleBase''​ sınıfının ''​newEnvelope(String)''​ metodunu inceleyiniz.
  
  
Satır 10: Satır 10:
 <sxh java> <sxh java>
 //get the element that signature will be added //get the element that signature will be added
-Element ​exts = (Element)faturaDoc.getDocumentElement().getElementsByTagName("​ext:​UBLExtensions"​).item(0);​ Element ext = (Element)exts.getElementsByTagName("​ext:​UBLExtension"​).item(0);​ Element extContent = (Element)exts.getElementsByTagName("​ext:​ExtensionContent"​).item(0);​+Element ​extContent ​= (Element)faturaDoc.getDocumentElement().getElementsByTagName("​ext:​ExtensionContent"​).item(0);​
  
-// generate signature +// generate signature Context context = createContext();​
-Context context = createContext();​+
 context.setDocument(faturaDoc);​ context.setDocument(faturaDoc);​
 XMLSignature signature = new XMLSignature(context,​ false); XMLSignature signature = new XMLSignature(context,​ false);
Satır 24: Satır 23:
  
 <sxh java> <sxh java>
-// use enveloped signature transform Transforms transforms = new Transforms(context);​ transforms.addTransform(new Transform(context,​ TransformType.ENVELOPED.getUrl()));​ +// use enveloped signature transform 
 +Transforms transforms = new Transforms(context);​ 
 +transforms.addTransform(new Transform(context,​ TransformType.ENVELOPED.getUrl()));​
  
 //add whole document(=""​) with envelope transform, with SHA256 //add whole document(=""​) with envelope transform, with SHA256
Satır 36: Satır 36:
 <sxh java> <sxh java>
 //add signer role information //add signer role information
-SignerRole rol = new SignerRole(context,​ new ClaimedRole[]{new ClaimedRole(context,​ "​Supplier"​)});​ signature.getQualifyingProperties().getSignedSignatureProperties().setSignerRole(rol);​+SignerRole rol = new SignerRole(context,​ new ClaimedRole[]{new ClaimedRole(context,​ "​Supplier"​)});​ 
 +signature.getQualifyingProperties().getSignedSignatureProperties().setSignerRole(rol);​
  
-// e-fatura standard wants public key info in the signature +//e-fatura standard wants public key info in the signature 
-PublicKey pk = KeyUtil.decodePublicKey(new ECertificate(cert.getEncoded()).getSubjectPublicKeyInfo());​ signature.getKeyInfo().add(new KeyValue(context,​ pk));+PublicKey pk = KeyUtil.decodePublicKey(new ECertificate(cert.getEncoded()).getSubjectPublicKeyInfo());​ 
 +signature.getKeyInfo().add(new KeyValue(context,​ pk));
  
-//add signing time signature.getQualifyingProperties().getSignedSignatureProperties().setSigningTime(getTime());​+// add signing time 
 +signature.getQualifyingProperties().getSignedSignatureProperties().setSigningTime(getTime());​
 </​sxh>​ </​sxh>​
  
-Kodu ''​tr.gov.tubitak.uekae.esya.api.xades.example.efatura.EFatura''​ altında inceleyebilirsiniz.+.NET kütüphanesinde ise açık anahtar eklemede ufak bir fark var.
  
 +<sxh c#>
 +// e-fatura standards want public key info to be in the signature
 +signature.KeyInfo.add(new KeyValue(context,​ cert.asX509Certificate2().PublicKey.Key));​
 +</​sxh>​
 +
 +Yine e-fatura kuralı olarak, imzanın id'si, yani signature-id bölümü faturada belirtilen id'ye çevrilir.
 +
 +<sxh java>
 +//e-fatura standards want signatureID to be same with cbc:URI
 +// get signatureID from e-fatura
 +String signatureID = ((Element)(faturaDoc.getDocumentElement().getElementsByTagName("​cbc:​URI"​).item(0)) ).getTextContent();​
 +String signatureIDwoNumberSign = signatureID.substring(1);​
 +
 +//change original signatureID
 +Element dsSignature = (Element)(faturaDoc.getDocumentElement().getElementsByTagName("​ds:​Signature"​).item(0));​
 +dsSignature.setAttribute("​Id",​ signatureIDwoNumberSign);​
 +</​sxh>​
 +
 +Kodu ''​tr.gov.tubitak.uekae.esya.api.xades.example.efatura.EFatura''​ altında inceleyebilirsiniz.
esya/xades/kod-e-fatura.1380701770.txt.gz · Son değiştirilme: 2013/10/02 08:16 Değiştiren: Süleyman Uslu