Bu sayfanın seçili sürümü ile mevcut sürümü arasındaki farkları gösterir.
| 
    esya:xades:kod-e-fatura [2013/10/02 08:27] Süleyman Uslu  | 
    
    esya:xades:kod-e-fatura [2013/10/09 06:12] (mevcut) Süleyman Uslu  | 
    ||
|---|---|---|---|
| Satır 12: | Satır 12: | ||
| Element extContent = (Element)faturaDoc.getDocumentElement().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 27: | Satır 26: | ||
| Transforms transforms = new Transforms(context); | Transforms transforms = new Transforms(context); | ||
| transforms.addTransform(new Transform(context, TransformType.ENVELOPED.getUrl())); | 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 41: | Satır 39: | ||
| signature.getQualifyingProperties().getSignedSignatureProperties().setSignerRole(rol); | 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()); | PublicKey pk = KeyUtil.decodePublicKey(new ECertificate(cert.getEncoded()).getSubjectPublicKeyInfo()); | ||
| signature.getKeyInfo().add(new KeyValue(context, pk)); | signature.getKeyInfo().add(new KeyValue(context, pk)); | ||
| - | //add signing time | + | // add signing time | 
| signature.getQualifyingProperties().getSignedSignatureProperties().setSigningTime(getTime()); | signature.getQualifyingProperties().getSignedSignatureProperties().setSigningTime(getTime()); | ||
| + | </sxh> | ||
| + | |||
| + | .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> | </sxh> | ||
| Satır 52: | Satır 57: | ||
| <sxh java> | <sxh java> | ||
| - | // e-fatura standards want signatureID to be same with cbc:URI | + | //e-fatura standards want signatureID to be same with cbc:URI | 
| // get signatureID from e-fatura | // get signatureID from e-fatura | ||
| - | String signatureID = ((Element)(faturaDoc.getDocumentElement().getElementsByTagName("cbc:URI").item(0))).getTextContent(); | + | String signatureID = ((Element)(faturaDoc.getDocumentElement().getElementsByTagName("cbc:URI").item(0)) ).getTextContent(); | 
| String signatureIDwoNumberSign = signatureID.substring(1); | String signatureIDwoNumberSign = signatureID.substring(1); | ||
| - | // change original signatureID | + | //change original signatureID | 
| Element dsSignature = (Element)(faturaDoc.getDocumentElement().getElementsByTagName("ds:Signature").item(0)); | Element dsSignature = (Element)(faturaDoc.getDocumentElement().getElementsByTagName("ds:Signature").item(0)); | ||
| dsSignature.setAttribute("Id", signatureIDwoNumberSign); | dsSignature.setAttribute("Id", signatureIDwoNumberSign); | ||
| Satır 63: | Satır 68: | ||
| Kodu ''tr.gov.tubitak.uekae.esya.api.xades.example.efatura.EFatura'' altında inceleyebilirsiniz. | Kodu ''tr.gov.tubitak.uekae.esya.api.xades.example.efatura.EFatura'' altında inceleyebilirsiniz. | ||
| - | |||