Exemple #1
0
IXMLDOMNode* CNtlXMLDoc::SelectSingleNode(char* pszXPath)
{
	if (false == m_bIsFileLoaded)
		return NULL;

	WCHAR wszUnicodeXPath[MAX_UNICODE_XPATH_LENGTH + 1];
	ZeroMemory(wszUnicodeXPath, sizeof(WCHAR) * (MAX_UNICODE_XPATH_LENGTH + 1));

	int iWrittenChars = ::MultiByteToWideChar(GetACP(), 0, pszXPath, -1, wszUnicodeXPath, MAX_UNICODE_XPATH_LENGTH);
	wszUnicodeXPath[MAX_UNICODE_XPATH_LENGTH] = L'\0';

	if (0 == iWrittenChars)
		return NULL;

	return SelectSingleNode(wszUnicodeXPath);
}
Exemple #2
0
		   writefile->WriteStartDocument();
		   writefile->Formatting = Formatting::Indented;
		   writefile->WriteStartElement("DataRoot");
		   writefile->WriteStartElement("Info");
		   writefile->WriteStartElement("Info");
		   writefile->WriteAttributeString("author", "wang");
		   writefile->WriteEndElement();
		   writefile->WriteEndElement();
		   writefile->Close();
		   return 0;
	   }
 int XmlOperator::ReadANode(String^Name)
	   {
			
		   Node = doc->DocumentElement;
		  RNode = Node = Node->SelectSingleNode(Name);
		  delete[]doc;
		   return 0;
	   }
 int XmlOperator::ReadTheLastNode()
	   {
		   XmlDocument^doc = gcnew XmlDocument();
		   doc->Load(Application::StartupPath + "\\DebugClientData.xml");
		   XmlLastNode = doc->LastChild;
		   XmlLastNode = XmlLastNode->LastChild;
		  doc->Save(Application::StartupPath + "\\DebugClientData.xml");
		   return 0;
	   }


const shared_ptr<LicenseParserResult> LicenseParser::ParsePublishingLicenseInner(const void *pbPublishLicense,
                                                                     size_t cbPublishLicense)
{
    string publishLicense;
    if ((cbPublishLicense > sizeof(BOM_UTF8)) && (memcmp(pbPublishLicense, BOM_UTF8, sizeof(BOM_UTF8)) == 0))
    {
        string utf8NoBOM(reinterpret_cast<const uint8_t *>(pbPublishLicense) + sizeof(BOM_UTF8),
                         reinterpret_cast<const uint8_t *>(pbPublishLicense) +
                         cbPublishLicense);
        publishLicense = utf8NoBOM;
    }
    else if (cbPublishLicense % 2 == 0)
    {
        // Assume UTF16LE (Unicode)
        auto strUnicode = QString::fromUtf16(reinterpret_cast<const uint16_t*>(pbPublishLicense), 
                                                              static_cast<int>(cbPublishLicense) / sizeof(uint16_t));
        auto utf8ByteArray = strUnicode.toUtf8();
        string utfString(utf8ByteArray.constData(), utf8ByteArray.length());
        publishLicense = utfString;
    }
    else 
    {
        throw exceptions::RMSNetworkException("Invalid publishing license encoding",
                                              exceptions::RMSNetworkException::InvalidPL);
    }
    Logger::Hidden("Publishing License in LicenseParser: %s", publishLicense.c_str());
    size_t finalSize = publishLicense.size();

    string publishLicenseWithRoot;
    CXMLUtils::WrapWithRoot(publishLicense.c_str(), finalSize, publishLicenseWithRoot);

    auto document = IDomDocument::create();
    std::string errMsg;
    int errLine   = 0;
    int errColumn = 0;

    auto ok = document->setContent(publishLicenseWithRoot,
                                 errMsg,
                                 errLine,
                                 errColumn);

    if (!ok) 
    {
        throw exceptions::RMSNetworkException("Invalid publishing license",
                                          exceptions::RMSNetworkException::InvalidPL);
    }

    auto extranetDomainNode = document->SelectSingleNode(EXTRANET_XPATH);
    auto intranetDomainNode = document->SelectSingleNode(INTRANET_XPATH);

    auto extranetDomain = (nullptr != extranetDomainNode.get()) ? extranetDomainNode->text() : string();
    RemoveTrailingNewLine(extranetDomain);
    auto intranetDomain = (nullptr != intranetDomainNode.get()) ? intranetDomainNode->text() : string();
    RemoveTrailingNewLine(intranetDomain);
    vector<shared_ptr<Domain> > domains;

    if (!extranetDomain.empty())
    {
        domains.push_back(Domain::CreateFromUrl(extranetDomain));
    }

    if (!intranetDomain.empty())
    {
        // don't add the intranet domain if it's the same as extranet
        if (extranetDomain.empty() ||
           (0 != _stricmp(intranetDomain.data(), extranetDomain.data())))
        {
            domains.push_back(Domain::CreateFromUrl(intranetDomain));
        }
    }
    if (domains.empty()) 
    {
        throw exceptions::RMSNetworkException("Invalid domains publishing license",
                                          exceptions::RMSNetworkException::InvalidPL);
    }

    shared_ptr<LicenseParserResult> result;
    if (rmscore::core::FeatureControl::IsEvoEnabled())
    {
        auto slcNode = document->SelectSingleNode(SLC_XPATH);
        if (nullptr == slcNode.get())
        {
            throw exceptions::RMSNetworkException("Server public certificate",
                                              exceptions::RMSNetworkException::InvalidPL);
        }
        auto publicCertificate = slcNode->text();
        RemoveTrailingNewLine(publicCertificate);

        result = make_shared<LicenseParserResult>(LicenseParserResult(domains,
                                                                      make_shared<string>(publicCertificate)));
    }
    else
    {
        result = make_shared<LicenseParserResult>(domains);
    }
    return result;
}