// Called for copying <links2> from commonLinks.xml to a method or property. public void CopyLinks(Chilkat.Xml xLinks) { if (m_xml == null) { return; } m_xml.RemoveChild("links2"); Chilkat.Xml xCopy = new Chilkat.Xml(); xCopy.LoadXml(xLinks.GetXml()); m_xml.AddChildTree(xCopy); return; }
public void AddProperty(XProperty xprop) { if (xprop == null) { return; } if (ContainsProperty(xprop.EntryName)) { throw new Exception(); } m_propList.Add(xprop); m_propList.Sort(); m_props.Add(xprop.EntryName, xprop); Chilkat.Xml x = m_xml.FindChild("properties"); if (x == null) { x = m_xml.NewChild("properties", ""); } Chilkat.Xml xp = xprop.GetXml_careful(); x.AddChildTree(xp); return; }
public void AddMethod(XMethod xMethod) { if (xMethod == null) { return; } if (ContainsMethod(xMethod.EntryName)) { throw new Exception(); } m_methodList.Add(xMethod); m_methodList.Sort(); m_methods.Add(xMethod.EntryName, xMethod); Chilkat.Xml x = m_xml.FindChild("methods"); if (x == null) { x = m_xml.NewChild("methods", ""); } Chilkat.Xml xm = xMethod.GetXml_careful(); x.AddChildTree(xm); return; }
/// <summary> /// converte file tsr in formato tsd (RFC 5544) /// </summary> /// <param name="pathFileTsr">file tsr</param> /// <param name="pathFileSign">file firmato</param> /// <param name="pathFileTsd">file tsd creato</param> /// <param name="lastError">ultimo errore della funzionalità</param> /// <returns>true se la funzionalità ha avuto successo</returns> public static bool CreaTsd(string pathFileTsr, string pathFileSign, out string pathFileTsd, ref string lastError) { bool success = false; pathFileTsd = null; try { if (Utilities.glob.UnlockStatus == 0) { lastError = "Licenza bloccata"; return(success); } Chilkat.BinData bdTsr = new Chilkat.BinData(); success = bdTsr.LoadFile(pathFileTsr); if (!success) { lastError = "Errore nel caricare il file tsr!"; return(success); } // Carico il tsr in un oggetto ASN.1 Chilkat.Asn asnTsr = new Chilkat.Asn(); success = asnTsr.LoadEncoded(bdTsr.GetEncoded("base64"), "base64"); if (!success) { lastError = asnTsr.LastErrorText; return(success); } // Prendo il timestamp nell'xml Chilkat.Xml xmlTsr = new Chilkat.Xml(); xmlTsr.LoadXml(asnTsr.AsnToXml()); // Il timestamp inizia in questo modo // Rimuovo la prima sub-tree // <?xml version="1.0" encoding="utf-8"?> // <sequence> // <sequence> <---- Remove this sub-tree. // <int>00</int> // <sequence> // <utf8>Operation Okay</utf8> // </sequence> // </sequence> // <sequence> // <oid>1.2.840.113549.1.7.2</oid> // <contextSpecific tag="0" constructed="1"> // ... // Rimuovo la prima sub-tree.. xmlTsr.RemoveChildByIndex(0); // Combiniamo il timestamp e il .p7m in un timestampData Chilkat.BinData bdContent = new Chilkat.BinData(); success = bdContent.LoadFile(pathFileSign); if (!success) { lastError = "Errore nel caricare il file p7m!"; return(success); } // Costruisco il TimeStampData. // Lo costruisco in XML e poi lo converto in ASN.1 Chilkat.Xml xml = new Chilkat.Xml(); xml.Tag = "sequence"; xml.UpdateChildContent("oid", "1.2.840.113549.1.9.16.1.31"); xml.UpdateAttrAt("contextSpecific", true, "tag", "0"); xml.UpdateAttrAt("contextSpecific", true, "constructed", "1"); xml.UpdateChildContent("contextSpecific|sequence|int", "01"); xml.UpdateChildContent("contextSpecific|sequence|octets", bdContent.GetEncoded("base64")); xml.UpdateAttrAt("contextSpecific|sequence|contextSpecific", true, "tag", "0"); xml.UpdateAttrAt("contextSpecific|sequence|contextSpecific", true, "constructed", "1"); Chilkat.Xml xContext = xml.GetChildWithTag("contextSpecific|sequence|contextSpecific"); xContext.AddChildTree(xmlTsr); // Converto il file XML in ASN.1 Chilkat.Asn tsd = new Chilkat.Asn(); tsd.LoadAsnXml(xml.GetXml()); // scrivo il timestamped success = tsd.WriteBinaryDer(pathFileTsd); } catch { throw; } return(success); }