示例#1
0
    void Endpoint::parseHstsPolicy(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsHstsPolicy_t &hstsPolicy) {

        if (obj.HasMember("LONG_MAX_AGE") && obj["LONG_MAX_AGE"].IsInt64()) {
            hstsPolicy.LONG_MAX_AGE = obj["LONG_MAX_AGE"].GetInt64();
        }

        if (obj.HasMember("header") && obj["header"].IsString()) {
            hstsPolicy.Header.assign(obj["header"].GetString());
        }

        if (obj.HasMember("status") && obj["status"].IsString()) {
            hstsPolicy.Status.assign(obj["status"].GetString());
        }

        if (obj.HasMember("maxAge") && obj["maxAge"].IsInt64()) {
            hstsPolicy.MaxAge = obj["maxAge"].GetInt64();
        }

        if (obj.HasMember("directives") && obj["directives"].IsObject()) {

        }

        return;
    }
示例#2
0
void Model::JsonAddModel(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> &data,ValueMap& model)
{
	for (auto member = data.MemberonBegin(); member < data.MemberonEnd(); ++member)
	{
		auto name = member->name.GetString();
		if(model[name].isNull())
		{
			if(member->value.IsInt())
			{
				model[name] = member->value.GetInt();
			}
			else if(member->value.IsString())
			{
				model[name] = member->value.GetString();
			}
			else if(member->value.IsBool())
			{
				model[name] = member->value.GetBool();
			}
			else if(member->value.IsDouble())
			{
				model[name] = member->value.GetDouble();
			}
		}
	}
}
示例#3
0
 bool
 member_compare(const std::set<std::string>& members_,
                const rapidjson::GenericValue<Encoding, Allocator>& v_)
 {
   if (v_.IsObject())
   {
     decltype(members_.size()) n = 0;
     for (auto i = v_.MemberBegin(), e = v_.MemberEnd(); i != e; ++i)
     {
       const auto& name = i->name;
       if (!name.IsString() ||
           members_.find(
               std::string(name.GetString(), name.GetStringLength())) ==
               members_.end())
       {
         return false;
       }
       if (ExpectFullMatch)
       {
         ++n;
       }
     }
     return !ExpectFullMatch || n == members_.size();
   }
   else
   {
     return false;
   }
 }
示例#4
0
 bool has_members(std::set<std::string> members_,
                  const rapidjson::GenericValue<Encoding, Allocator>& v_)
 {
   if (v_.IsObject())
   {
     for (auto i = v_.MemberBegin(), e = v_.MemberEnd(); i != e; ++i)
     {
       const auto& name = i->name;
       if (name.IsString())
       {
         const auto m = members_.find(
             std::string(name.GetString(), name.GetStringLength()));
         if (m != members_.end())
         {
           members_.erase(m);
           if (members_.empty())
           {
             return true;
           }
         }
       }
     }
     return members_.empty();
   }
   return false;
 }
示例#5
0
	void operator()(
		rapidjson::GenericValue<Encoding, Allocator>& rja,
		Allocator& alloc,
		const Range& r
	) const {
		using namespace puddle;

		rja.SetArray();
		for(const auto& e : r) {
			rapidjson::Value rje;
			_comp(rje, alloc, e);
			rja.PushBack(rje, alloc);
		}
	}
      bool JsonQueryFactory::deserializeGetAccountAssets(
          rapidjson::GenericValue<rapidjson::UTF8<char>>::Object &obj_query,
          protocol::Query &pb_query) {
        if (not(obj_query.HasMember("account_id") &&
                obj_query.HasMember("asset_id"))) {
          log_->error("No account, asset id in json");
          return false;
        }
        auto pb_get_account_assets = pb_query.mutable_get_account_assets();
        pb_get_account_assets->set_account_id(
            obj_query["account_id"].GetString());
        pb_get_account_assets->set_asset_id(obj_query["asset_id"].GetString());

        return true;
      }
示例#7
0
    void Endpoint::parseProtocosls(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsProtocol_t &labsProtocol) {

        if (obj.HasMember("id") && obj["id"].IsInt()) {
            labsProtocol.Id = obj["id"].GetInt();
        }

        if (obj.HasMember("name") && obj["name"].IsString()) {
            labsProtocol.Name.assign(obj["name"].GetString());
        }

        if (obj.HasMember("version") && obj["version"].IsString()) {
            labsProtocol.Version.assign(obj["version"].GetString());
        }
    }
示例#8
0
文件: UserSkill.cpp 项目: Longpc/RTS
vector<UserSkillInfo> UserSkill::createUserSkillDataFromJson(rapidjson::GenericValue<rapidjson::UTF8<char>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>& value)
{
	vector<UserSkillInfo> vInfo;
	vector<UserSkillInfo> pInfo;
	UserSkillInfo info;
	for (int i = 0; i < value.Size(); i++)
	{
		info.mst_skill_id = DataUtils::stringToFloat(value[i]["mst_skill_id"].GetString());
		info.name = value[i]["name"].GetString();
		info.skill_type = DataUtils::stringToFloat(value[i]["skill_type"].GetString());
		info.mp_cost = DataUtils::stringToFloat(value[i]["mp_cost"].GetString());
		info.cooldown_time = DataUtils::stringToFloat(value[i]["cooldown_time"].GetString());
		info.range_type = DataUtils::stringToFloat(value[i]["range_type"].GetString());
		info.range_distance = DataUtils::stringToFloat(value[i]["range_distance"].GetString());
		info.multi_effect = DataUtils::stringToFloat(value[i]["multi_effect"].GetString());
		info.target_type = DataUtils::stringToFloat(value[i]["target_type"].GetString());
		info.effect_type = DataUtils::stringToFloat(value[i]["effect_type"].GetString());
		info.buff_effect_type = DataUtils::stringToFloat(value[i]["buff_effect_type"].GetString());
		info.duration = DataUtils::stringToFloat(value[i]["effect_duration"].GetString());
		info.correct_type = DataUtils::stringToFloat(value[i]["correct_type"].GetString());
		info.corrett_value = DataUtils::stringToFloat(value[i]["corrett_value"].GetString());
		info.skill_des = value[i]["description"].GetString();
		info.image_path = value[i]["image_path"].GetString();
		info.skill_icon_path = value[i]["skill_icon_path"].GetString();

		vInfo.push_back(info);
		if (info.skill_type == 1) {
			pInfo.push_back(info);
		}
		log("skill %d name: %s", i+1, value[i]["name"].GetString());
	}
	setUserSkillList(vInfo);
	setPlayerSkillsList(pInfo);
	return getUserSkillList();
}
示例#9
0
    void Endpoint::parseLabsSuites(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsSuites_t &labsSuites) {


        if (obj.HasMember("preference") && obj["preference"].IsBool()) {
            labsSuites.Preference = obj["preference"].GetBool();
        }

        if (obj.HasMember("list") && obj["list"].IsArray()) {
            labsSuite_t labsSuite;
            for (auto itr = obj["list"].GetArray().Begin(); itr != obj["list"].GetArray().End(); itr++) {
                parseSuitesList(itr->GetObject(), labsSuite);
                labsSuites.List.push_back(labsSuite);
            }
        }
    }
示例#10
0
    void Endpoint::parseChain(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsChain_t &labsChain) {

        if (obj.HasMember("issues") && obj["issues"].IsInt()) {
            labsChain.Issues = obj["issues"].GetInt();
        }

        if (obj.HasMember("certs") && obj["certs"].IsArray()) {
            labsChainCert_t labsChainCert;

            for (auto itr = obj["certs"].GetArray().Begin(); itr != obj["certs"].GetArray().End(); itr++) {
                parseChainCert(itr->GetObject(), labsChainCert);
                labsChain.Certs.push_back(labsChainCert);
            }
        }

    }
示例#11
0
	void operator()(
		rapidjson::GenericValue<Encoding, Allocator>& rjo,
		Allocator& alloc,
		const std::map<K, V, C, A>& c
	) const {
		using namespace puddle;

		rjo.SetObject();
		for(const auto& p : c) {
			rapidjson::Value rjk;
			_keycomp(rjk, alloc, p.first);
			rapidjson::Value rjv;
			_valcomp(rjv, alloc, p.second);

			rjo.AddMember(rjk, rjv, alloc);
		}
	}
示例#12
0
    void Endpoint::parseSuitesList(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsSuite_t &labsSuite) {

        if (obj.HasMember("id") && obj["id"].IsInt()) {
            labsSuite.Id = obj["id"].GetInt();
        }

        if (obj.HasMember("name") && obj["name"].IsString()) {
            labsSuite.Name.assign(obj["name"].GetString());
        }

        if (obj.HasMember("cipherStrength") && obj["cipherStrength"].IsInt()) {
            labsSuite.CipherStrength = obj["cipherStrength"].GetInt();
        }

        if (obj.HasMember("dhStrength") && obj["dhStrength"].IsInt()) {
            labsSuite.DhStrength = obj["dhStrength"].GetInt();
        }

        if (obj.HasMember("dhP") && obj["dhP"].IsInt()) {
            labsSuite.DhP = obj["dhP"].GetInt();
        }

        if (obj.HasMember("dhG") && obj["dhG"].IsInt()) {
            labsSuite.DhG = obj["dhG"].GetInt();
        }

        if (obj.HasMember("dhYs") && obj["dhYs"].IsInt()) {
            labsSuite.DhYs = obj["dhYs"].GetInt();
        }
    }
void PFMSceneryPreset::setExternValue(rapidjson::GenericValue<rapidjson::UTF8<>>& value,std::string key)
{
    if(key == "route")
    {
        routeStrategy = value.GetString();
    }
    else if(key == "shoot")
    {
        shootStrategy = value.GetString();
    }
    else if(key == "composition")
    {
        compositionStrategy = value.GetString();
    }
    else if(key == "health")
    {
        health = value.GetDouble();
    }
}
示例#14
0
    void Endpoint::parseKey(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsKey_t &labsKey) {

        if (obj.HasMember("size") && obj["size"].IsInt()) {
            labsKey.Size = obj["size"].GetInt();
        }

        if (obj.HasMember("alg") && obj["alg"].IsString()) {
            labsKey.Algorithm.assign(obj["alg"].GetString());
        }

        if (obj.HasMember("debianFlaw") && obj["debianFlaw"].IsBool()) {
            labsKey.DebianFlaw = obj["debianFlaw"].GetBool();
        }

        if (obj.HasMember("strength") && obj["strength"].IsInt()) {
            labsKey.Strength = obj["strength"].GetInt();
        }
    }
示例#15
0
    void Endpoint::parseSimulationClient(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj,
                                         labsSimClient_t &labsSimClient) {

        if (obj.HasMember("id") && obj["id"].IsInt()) {
            labsSimClient.Id = obj["id"].GetInt();
        }

        if (obj.HasMember("name") && obj["name"].IsString()) {
            labsSimClient.Name.assign(obj["name"].GetString());
        }

        if (obj.HasMember("version") && obj["version"].IsString()) {
            labsSimClient.Version.assign(obj["version"].GetString());
        }

        if (obj.HasMember("isReference") && obj["isReference"].IsBool()) {
            labsSimClient.IsReference = obj["isReference"].GetBool();
        }
    }
示例#16
0
	void operator()(
		rapidjson::GenericValue<Encoding, Allocator>& rjv,
		Allocator& alloc,
		T* v
	) const {
		if(bool(v)) {
			_comp(rjv, alloc, *v);
		} else {
			rjv.SetNull();
		}
	}
示例#17
0
	bool _compose_element(
		rapidjson::GenericValue<Enc, Alloc>& rja,
		Alloc& alloc,
		const E& e,
		const rapidjson_compositor<E>& comp
	) const {
		rapidjson::Value rje;
		comp(rje, alloc, e);
		rja.PushBack(rje, alloc);
		return true;
	}
示例#18
0
    void Endpoint::parseHpkpPolicy(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsHpkpPolicy_t &hpkpPolicy) {

        if (obj.HasMember("status") && obj["status"].IsString()) {
            hpkpPolicy.Status.assign(obj["status"].GetString());
        }

        if (obj.HasMember("pins") && obj["pins"].IsArray()) {

        }

        if (obj.HasMember("matchedPins") && obj["matchedPins"].IsArray()) {

        }

        if (obj.HasMember("directives") && obj["directives"].IsObject()) {

        }

        return;
    }
示例#19
0
    void Endpoint::parseSimulationResults(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj,
                                    labsSimulation_t &labsSimulation) {

        if (obj.HasMember("errorCode") && obj["errorCode"].IsInt()) {
            labsSimulation.ErrorCode = obj["errorCode"].GetInt();
        }

        if (obj.HasMember("attempts") && obj["attempts"].IsInt()) {
            labsSimulation.Attempts = obj["attempts"].GetInt();
        }

        if (obj.HasMember("protocolId") && obj["protocolId"].IsInt()) {
            labsSimulation.ProtocolId = obj["protocolId"].GetInt();
        }

        if (obj.HasMember("suiteId") && obj["suiteId"].IsInt()) {
            labsSimulation.SuiteId = obj["suiteId"].GetInt();
        }

        if (obj.HasMember("client") && obj["client"].IsObject()) {
            parseSimulationClient(obj["client"].GetObject(), labsSimulation.Client);
        }
    }
示例#20
0
文件: page.cpp 项目: JIM-DB/Server
        size_t Page::insert(const rapidjson::GenericValue<rapidjson::UTF8<>>& value)
        {
            tasking::RWLockGuard<> lock(m_rwLock, tasking::WRITE);
            //here we know this page has one chunk big enough to fitt the whole object
            //including its overhead! so start inserting it.

            //get the object name
            std::string name = value.MemberBegin()->name.GetString();

            //returns the pos of the first element needed for the headerdata

            auto firstElementPos = insertObject(value.MemberBegin()->value, nullptr).first;
            auto l_first = dist(m_body, firstElementPos);

            //insert the header
            HeaderMetaData* meta = insertHeader(m_objCount++, 0, common::FNVHash()(name), l_first);
            if (meta == nullptr)
                LOG_DEBUG << "wm";
            //push the obj to obj index
            index::ObjectIndex::getInstance().add(meta->getOID(), index::ObjectIndexValue(this->m_id, dist(m_header, meta)));

            //done!
            return meta->getOID();
        }
示例#21
0
    void Endpoint::parseSimulationDetails(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj,
                                          labsSimDetails_t &labsSimDetails) {

            if (obj.HasMember("results") && obj["results"].IsArray()) {
                for (auto itr = obj["results"].GetArray().Begin(); itr != obj["results"].GetArray().End(); itr++) {
                    labsSimulation_t labsSimulation;

                    if (itr->IsObject()) {
                        parseSimulationResults(itr->GetObject(), labsSimulation);
                        labsSimDetails.Results.push_back(labsSimulation);
                    }
                }
            }

    }
示例#22
0
void JSObject::FillRecursive(const rapidjson::GenericValue<rapidjson::UTF8<wchar_t>> &val)
{
  using namespace rapidjson;
  /**/
  switch(val.GetType())
  {
  case kNullType:		//!< null
    value = JSValue();
    break;
  case kFalseType:		//!< false
    value = JSValue(false);
    break;
  case kTrueType:		//!< true
    value = JSValue(true);
    break;
  case kObjectType:	//!< object
    value.type = JSTypeObject;
    for(GenericValue<UTF8<wchar_t>>::ConstMemberIterator itr2 = val.MemberBegin(); itr2 != val.MemberEnd(); ++itr2)
    {
      children.push_back(std::make_pair(itr2->name.GetString(), JSObject()));
      children.back().second.FillRecursive(itr2->value);
    }
    break;
  case kArrayType:		//!< array 
    value.type = JSTypeObject;
    children.resize(val.Size());
    for(SizeType i = 0; i < val.Size(); i++)
    {
      children[i].second.FillRecursive(val[i]);
    }
    break;
  case kStringType:	//!< string
    value.str = val.GetString();
    value.type = JSTypeString;
    break;
  case kNumberType:	//!< number
    value = val.GetDouble();
    break;
  }

}
示例#23
0
    void Endpoint::parseEndpointData(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> &obj, labsEndpoint_t &endpoint) {
        if (obj.HasMember("ipAddress") && obj["ipAddress"].IsString()) {
            endpoint.IpAddress.assign(obj["ipAddress"].GetString());
        }

        if (obj.HasMember("serverName") && obj["serverName"].IsString()) {
            endpoint.ServerName.assign(obj["serverName"].GetString());
        }

        if (obj.HasMember("statusMessage") && obj["statusMessage"].IsString()) {
            endpoint.StatusMessage.assign(obj["statusMessage"].GetString());
        }

        if (obj.HasMember("statusDetailsMessage") && obj["statusDetailsMessage"].IsString()) {
            endpoint.StatusDetailMessage.assign(obj["statusDetailsMessage"].GetString());
        }

        if (obj.HasMember("grade") && obj["grade"].IsString()) {
            endpoint.Grade.assign(obj["grade"].GetString());
        }

        if (obj.HasMember("gradeTrustIgnored") && obj["gradeTrustIgnored"].IsString()) {
            endpoint.GradeTrustIgnored.assign(obj["gradeTrustIgnored"].GetString());
        }

        if (obj.HasMember("hasWarnings") && obj["hasWarnings"].IsBool()) {
            endpoint.HasWarnings = obj["hasWarnings"].GetBool();
        }

        if (obj.HasMember("isExceptional") && obj["isExceptional"].IsBool()) {
            endpoint.IsExceptional = obj["isExceptional"].GetBool();
        }

        if (obj.HasMember("progress") && obj["progress"].IsInt()) {
            endpoint.Progress = obj["progress"].GetInt();
        }

        if (obj.HasMember("duration") && obj["duration"].IsInt()) {
            endpoint.Duration = obj["duration"].GetInt();
        }

        if (obj.HasMember("eta") && obj["eta"].IsInt()) {
            endpoint.Eta = obj["eta"].GetInt();
        }

        if (obj.HasMember("delegation") && obj["delegation"].IsInt()) {
            endpoint.Delegation = obj["delegation"].GetInt();
        }

        if (obj.HasMember("details") && obj["details"].IsObject()) {
            parseEndpointDetails(obj["details"].GetObject(), endpoint);
        }

        return;
    }
示例#24
0
 bool is_string(const std::string& s_,
                const rapidjson::GenericValue<Encoding, Allocator>& v_)
 {
   return v_.IsString() &&
          std::string(v_.GetString(), v_.GetStringLength()) == s_;
 }
示例#25
0
    void Endpoint::parseEndpointDetails(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject & obj, labsEndpoint_t &endpoint) {

        if (obj.HasMember("hostStartTime") && obj["hostStartTime"].IsInt64()) {
            endpoint.Details.HostStartTime = obj["hostStartTime"].GetInt64();
        }

        if (obj.HasMember("key") && obj["key"].IsObject()) {
            Endpoint::parseKey(obj["key"].GetObject(), endpoint.Details.Key);
        }

        if (obj.HasMember("cert") && obj["cert"].IsObject()) {
            Endpoint::parseCert(obj["cert"].GetObject(), endpoint.Details.Cert);
        }

        if (obj.HasMember("chain") && obj["chain"].IsObject()) {
            Endpoint::parseChain(obj["chain"].GetObject(), endpoint.Details.Chain);
        }

        if (obj.HasMember("protocols") && obj["protocols"].IsArray()) {
            labsProtocol_t labsProtocol;

            for (auto itr = obj["protocols"].GetArray().Begin(); itr != obj["protocols"].GetArray().End(); itr++) {
                parseProtocosls(itr->GetObject(), labsProtocol);
                endpoint.Details.Protocols.push_back(labsProtocol);
            }
        }

        if (obj.HasMember("suites") && obj["suites"].IsObject()) {
            Endpoint::parseLabsSuites(obj["suites"].GetObject(), endpoint.Details.Suites);
        }

        if (obj.HasMember("serverSignature") && obj["serverSignature"].IsString()) {
            endpoint.Details.ServerSignature = obj["serverSignature"].GetString();
        }

        if (obj.HasMember("prefixDelegation") && obj["prefixDelegation"].IsBool()) {
            endpoint.Details.PrefixDelegation = obj["prefixDelegation"].GetBool();
        }

        if (obj.HasMember("nonPrefixDelegation") && obj["nonPrefixDelegation"].IsBool()) {
            endpoint.Details.NonPrefixDelegation = obj["nonPrefixDelegation"].GetBool();
        }

        if (obj.HasMember("vulnBeast") && obj["vulnBeast"].IsBool()) {
            endpoint.Details.VulnBeast = obj["vulnBeast"].GetBool();
        }

        if (obj.HasMember("renegSupport") && obj["renegSupport"].IsInt()) {
            endpoint.Details.RenegSupport = obj["renegSupport"].GetInt();
        }

        // * TODO: need to parse stsStatus & sts.. any variable;

        if (obj.HasMember("sessionResumption") && obj["sessionResumption"].IsInt()) {
            endpoint.Details.SessionResumption = obj["sessionResumption"].GetInt();
        }

        if (obj.HasMember("compressionMethods") && obj["compressionMethods"].IsInt()) {
            endpoint.Details.CompressionMethods = obj["compressionMethods"].GetInt();
        }

        if (obj.HasMember("supportsNpn") && obj["supportsNpn"].IsBool()) {
            endpoint.Details.SupportsNpn = obj["supportsNpn"].GetBool();
        }

        if (obj.HasMember("sessionTickets") && obj["sessionTickets"].IsInt()) {
            endpoint.Details.SessionTickets = obj["sessionTickets"].GetInt();
        }

        if (obj.HasMember("ocspStapling") && obj["ocspStapling"].IsBool()) {
            endpoint.Details.OcspStapling = obj["ocspStapling"].GetBool();
        }

        if (obj.HasMember("sniRequired") && obj["sniRequired"].IsBool()) {
            endpoint.Details.SniRequired = obj["sniRequired"].GetBool();
        }

        if (obj.HasMember("httpStatusCode") && obj["httpStatusCode"].IsInt()) {
            endpoint.Details.HttpStatusCode = obj["httpStatusCode"].GetInt();
        }

        if (obj.HasMember("supportsRc4") && obj["supportsRc4"].IsBool()) {
            endpoint.Details.SupportsRc4 = obj["supportsRc4"].GetBool();
        }

        if (obj.HasMember("rc4WithModern") && obj["rc4WithModern"].IsBool()) {
            endpoint.Details.Rc4WithModern = obj["rc4WithModern"].GetBool();
        }

        if (obj.HasMember("rc4Only") && obj["rc4Only"].IsBool()) {
            endpoint.Details.Rc4Only = obj["rc4Only"].GetBool();
        }

        if (obj.HasMember("forwardSecrecy") && obj["forwardSecrecy"].IsInt()) {
            endpoint.Details.ForwardSecrecy = obj["forwardSecrecy"].GetInt();
        }

        if (obj.HasMember("sims") && obj["sims"].IsObject()) {
            parseSimulationDetails(obj["sims"].GetObject(), endpoint.Details.Sims);
        }

        if (obj.HasMember("heartbleed") && obj["heartbleed"].IsBool()) {
            endpoint.Details.Heartbleed = obj["heartbleed"].GetBool();
        }

        if (obj.HasMember("heartbeat") && obj["heartbeat"].IsBool()) {
            endpoint.Details.Heartbeat = obj["heartbeat"].GetBool();
        }

        if (obj.HasMember("openSslCcs") && obj["openSslCcs"].IsInt()) {
            endpoint.Details.OpenSslCcs = obj["openSslCcs"].GetInt();
        }

        if (obj.HasMember("poodle") && obj["poodle"].IsBool()) {
            endpoint.Details.Poodle = obj["poodle"].GetBool();
        }

        if (obj.HasMember("poodleTls") && obj["poodleTls"].IsInt()) {
            endpoint.Details.PoodleTls = obj["poodleTls"].GetInt();
        }

        if (obj.HasMember("fallbackScsv") && obj["fallbackScsv"].IsBool()) {
            endpoint.Details.FallbackScsv = obj["fallbackScsv"].GetBool();
        }

        if (obj.HasMember("freak") && obj["freak"].IsBool()) {
            endpoint.Details.Freak = obj["freak"].GetBool();
        }

        if (obj.HasMember("hasSct") && obj["hasSct"].IsInt()) {
            endpoint.Details.HasSct = obj["hasSct"].GetInt();
        }

        if (obj.HasMember("dhPrimes") && obj["dhPrimes"].IsArray()) {
            for (auto itr = obj["dhPrimes"].GetArray().Begin(); itr != obj["dhPrimes"].GetArray().End(); itr++) {
                if (itr->IsString()) {
                    endpoint.Details.DhPrimes.push_back(itr->GetString());
                }
            }
        }

        if (obj.HasMember("dhUsesKnownPrimes") && obj["dhUsesKnownPrimes"].IsInt()) {
            endpoint.Details.DhUsesKnownPrimes = obj["dhUsesKnownPrimes"].GetInt();
        }

        if (obj.HasMember("dhYsReuse") && obj["dhYsReuse"].IsBool()) {
            endpoint.Details.DhYsReuse = obj["dhYsReuse"].GetBool();
        }

        if (obj.HasMember("logjam") && obj["logjam"].IsBool()) {
            endpoint.Details.Logjam = obj["logjam"].GetBool();
        }

        if (obj.HasMember("hstsPolicy") && obj["hstsPolicy"].IsObject()) {
            Endpoint::parseHstsPolicy(obj["hstsPolicy"].GetObject(), endpoint.Details.HstsPolicy);
        }

        if (obj.HasMember("hstsPreloads") && obj["hstsPreloads"].IsArray()) {

        }

        if (obj.HasMember("hpkpPolicy") && obj["hpkpPolicy"].IsObject()) {
            Endpoint::parseHpkpPolicy(obj["hpkpPolicy"].GetObject(), endpoint.Details.HpkpPolicy);
        }

        if (obj.HasMember("hpkpRoPolicy") && obj["hpkpRoPolicy"].IsObject()) {
            Endpoint::parseHpkpPolicy(obj["hpkpRoPolicy"].GetObject(), endpoint.Details.HpkpRoPolicy);
        }

        // * TODO: need to parse drownHosts;

        if (obj.HasMember("drownErrors") && obj["drownErrors"].IsBool()) {
            endpoint.Details.DrownErrors = obj["drownErrors"].GetBool();
        }

        if (obj.HasMember("drownVulnerable") && obj["drownVulnerable"].IsBool()) {
            endpoint.Details.DrownVulnerable = obj["drownVulnerable"].GetBool();
        }

        return;
    }
示例#26
0
文件: page.cpp 项目: JIM-DB/Server
        std::pair<void*, void*> Page::insertObject(const rapidjson::GenericValue<rapidjson::UTF8<>>& value,
                BaseType<size_t>* const last)
        {
            //return ptr to the first element
            void* l_ret = nullptr;
            //prev element ptr
            BaseType<size_t>* l_prev = last;

            //position pointer
            void* l_pos = nullptr;
            //get the members
            for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it)
            {
                switch (it->value.GetType())
                {
                    case rapidjson::kNullType:
                        LOG_WARN << "null type: " << it->name.GetString();
                        continue;

                    case rapidjson::kFalseType:
                    case rapidjson::kTrueType:
                        {
                            l_pos = find(sizeof(BoolTyp));

                            void* l_new = new (l_pos) BoolTyp(it->value.GetBool());

                            if (l_prev != nullptr)
                                l_prev->setNext(dist(l_prev, l_new));
                            //set the ret pointer
                            if (l_ret == nullptr)
                                l_ret = l_pos;
                        }
                        break;
                    case rapidjson::kObjectType:
                        {
                            //pos for the obj id
                            //and insert the ID of the obj
                            l_pos = find(sizeof(ObjHashTyp));
                            std::string name = it->name.GetString();
                            auto hash = common::FNVHash()(name);
                            void* l_new = new (l_pos) ObjHashTyp(hash);



                            if (l_prev != nullptr)
                                l_prev->setNext(dist(l_prev, l_new));

                            // pass the objid Object to the insertobj!
                            // now recursive insert the obj
                            // the second contains the last element inserted
                            // l_pos current contains the last inserted element and get set to the
                            // last element of the obj we insert
                            l_pos = insertObject(it->value, RC(SizeTType*, l_new)).second;

                            //set the ret pointer
                            if (l_ret == nullptr)
                                l_ret = l_new;
                        }
                        break;

                    case rapidjson::kArrayType:
                        {

                            //now insert values
                            l_pos = find(sizeof(ArrayType));

                            //insert the number of elements which follows
                            size_t l_size = it->value.Size();
                            void* l_new = new(l_pos) ArrayType(l_size);
                            //update prev
                            if (l_prev != nullptr)
                                l_prev->setNext(dist(l_prev, l_new));

                            //insert elements
                            l_pos = insertArray(it->value, SC(SizeTType*, l_new));

                            //set the ret pointer
                            if (l_ret == nullptr)
                                l_ret = l_new;

                        }
                        break;

                    case rapidjson::kStringType:
                        {
                            // find pos where the string fits
                            // somehow we get here sometimes and it does not fit!
                            // which cant be since we lock the whole page
                            l_pos = find(sizeof(StringType) + it->value.GetStringLength());

                            //add the String Type at the pos of the FreeType
                            auto* l_new = new (l_pos) StringType(it->value.GetString());
                            if (l_prev != nullptr)
                                l_prev->setNext(dist(l_prev, l_new));
                            //set the ret pointer
                            if (l_ret == nullptr)
                                l_ret = l_pos;
                        }
                        break;

                    case rapidjson::kNumberType:
                        {
                            //doesnt matter since long long and double are equal on
                            // x64
                            //find pos where the string fits
                            l_pos = find(sizeof(IntTyp));

                            void* l_new;
                            if (it->value.IsInt() || it->value.IsInt64())
                            {
                                //insert INT
                                l_new = new (l_pos) IntTyp(it->value.GetInt64());
                            }
                            else
                            {
                                //INSERT DOUBLE
                                l_new = new (l_pos) DoubleTyp(it->value.GetDouble());
                            }
                            if (l_prev != nullptr)
                                l_prev->setNext(dist(l_prev, l_new));

                            //set the ret pointer
                            if (l_ret == nullptr)
                                l_ret = l_pos;
                        }
                        break;
                    default:
                        LOG_WARN << "Unknown member Type: " << it->name.GetString() << ":" << it->value.GetType();
                        continue;
                }
                //prev is the l_pos now so cast it to this;
                l_prev = RC(SizeTType*, l_pos);
            }
            //if we get here its in!
            return{ l_ret, l_pos };
        }
示例#27
0
    void Endpoint::parseCert(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj, labsCert_t &labsCert) {

        if (obj.HasMember("subject") && obj["subject"].IsString()) {
            labsCert.Subject.assign(obj["subject"].GetString());
        }

        if (obj.HasMember("commonNames") && obj["commonNames"].IsArray()) {
            for (auto itr = obj["commonNames"].GetArray().Begin(); itr != obj["commonNames"].GetArray().End(); itr++) {
                if (itr->IsString()) {
                    labsCert.CommonNames.push_back(itr->GetString());
                }
            }
        }

        if (obj.HasMember("altNames") && obj["altNames"].IsArray()) {
            for (auto itr = obj["altNames"].GetArray().Begin(); itr != obj["altNames"].GetArray().End(); itr++) {
                if (itr->IsString()) {
                    labsCert.AltNames.push_back(itr->GetString());
                }
            }
        }

        if (obj.HasMember("notBefore") && obj["notBefore"].IsInt64()) {
            labsCert.NotBefore = obj["notBefore"].GetInt64();
        }

        if (obj.HasMember("notAfter") && obj["notAfter"].IsInt64()) {
            labsCert.NotAfter = obj["notAfter"].GetInt64();
        }

        if (obj.HasMember("issuerSubject") && obj["issuerSubject"].IsString()) {
            labsCert.IssuerSubject.assign(obj["issuerSubject"].GetString());
        }

        if (obj.HasMember("issuerLabel") && obj["issuerLabel"].IsString()) {
            labsCert.IssuerLabel.assign(obj["issuerLabel"].GetString());
        }

        if (obj.HasMember("sigAlg") && obj["sigAlg"].IsString()) {
            labsCert.SigAlg.assign(obj["sigAlg"].GetString());
        }

        if (obj.HasMember("revocationInfo") && obj["revocationInfo"].IsInt()) {
            labsCert.RevocationInfo = obj["revocationInfo"].GetInt();
        }

        if (obj.HasMember("crlURIs") && obj["crlURIs"].IsArray()) {
            for (auto itr = obj["crlURIs"].GetArray().Begin(); itr != obj["crlURIs"].GetArray().End(); itr++) {
                if (itr->IsString()) {
                    labsCert.CrlURIs.push_back(itr->GetString());
                }
            }
        }

        if (obj.HasMember("ocspURIs") && obj["ocspURIs"].IsArray()) {
            for (auto itr = obj["ocspURIs"].GetArray().Begin(); itr != obj["ocspURIs"].GetArray().End(); itr++) {
                if (itr->IsString()) {
                    labsCert.OcspURIs.push_back(itr->GetString());
                }
            }
        }

        if (obj.HasMember("revocationStatus") && obj["revocationStatus"].IsInt()) {
            labsCert.RevocationStatus = obj["revocationStatus"].GetInt();
        }

        if (obj.HasMember("crlRevocationStatus") && obj["crlRevocationStatus"].IsInt()) {
            labsCert.CrlRevocationStatus = obj["crlRevocationStatus"].GetInt();
        }

        if (obj.HasMember("ocspRevocationStatus") && obj["ocspRevocationStatus"].IsInt()) {
            labsCert.OcspRevocationStatus = obj["ocspRevocationStatus"].GetInt();
        }

        if (obj.HasMember("sgc") && obj["sgc"].IsInt()) {
            labsCert.Sgc = obj["sgc"].GetInt();
        }

        if (obj.HasMember("issues") && obj["issues"].IsInt()) {
            labsCert.Issues = obj["issues"].GetInt();
        }

        if (obj.HasMember("sct") && obj["sct"].IsBool()) {
            labsCert.Sct = obj["sct"].GetBool();
        }

        if (obj.HasMember("mustStaple") && obj["mustStaple"].IsInt()) {
            labsCert.MustStaple = obj["mustStaple"].GetInt();
        }

        if (obj.HasMember("sha1Hash") && obj["sha1Hash"].IsString()) {
            labsCert.Sha1Hash.assign(obj["sha1Hash"].GetString());
        }

        if (obj.HasMember("pinSha256") && obj["pinSha256"].IsString()) {
            labsCert.PinSha256.assign(obj["pinSha256"].GetString());
        }

    }
示例#28
0
	void operator()(
		rapidjson::GenericValue<Encoding, Allocator>& rjv,
		Allocator& alloc,
		char v
	) const { rjv.SetString(&v, 1, alloc); }
示例#29
0
    void Endpoint::parseChainCert(const rapidjson::GenericValue<rapidjson::UTF8<char>,
            rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>::ConstObject &obj,
                                  labsChainCert_t &labsChainCert) {

        if (obj.HasMember("subject") && obj["subject"].IsString()) {
            labsChainCert.Subject.assign(obj["subject"].GetString());
        }

        if (obj.HasMember("label") && obj["label"].IsString()) {
            labsChainCert.Label.assign(obj["label"].GetString());
        }

        if (obj.HasMember("notBefore") && obj["notBefore"].IsInt64()) {
            labsChainCert.NotBefore = obj["notBefore"].GetInt64();
        }

        if (obj.HasMember("notAfter") && obj["notAfter"].IsInt64()) {
            labsChainCert.NotAfter = obj["notAfter"].GetInt64();
        }

        if (obj.HasMember("issuerSubject") && obj["issuerSubject"].IsString()) {
            labsChainCert.IssuerSubject.assign(obj["issuerSubject"].GetString());
        }

        if (obj.HasMember("issuerLabel") && obj["issuerLabel"].IsString()) {
            labsChainCert.IssuerLabel.assign(obj["issuerLabel"].GetString());
        }

        if (obj.HasMember("sigAlg") && obj["sigAlg"].IsString()) {
            labsChainCert.SigAlg.assign(obj["sigAlg"].GetString());
        }

        if (obj.HasMember("issues") && obj["issues"].IsInt()) {
            labsChainCert.Issues = obj["issues"].GetInt();
        }

        if (obj.HasMember("keyAlg") && obj["keyAlg"].IsString()) {
            labsChainCert.KeyAlg.assign(obj["keyAlg"].GetString());
        }

        if (obj.HasMember("keySize") && obj["keySize"].IsInt()) {
            labsChainCert.KeySize = obj["keySize"].GetInt();
        }

        if (obj.HasMember("keyStrength") && obj["keyStrength"].IsInt()) {
            labsChainCert.KeyStrength = obj["keyStrength"].GetInt();
        }

        if (obj.HasMember("revocationStatus") && obj["revocationStatus"].IsInt()) {
            labsChainCert.RevocationStatus = obj["revocationStatus"].GetInt();
        }

        if (obj.HasMember("crlRevocationStatus") && obj["crlRevocationStatus"].IsInt()) {
            labsChainCert.CrlRevocationStatus = obj["crlRevocationStatus"].GetInt();
        }

        if (obj.HasMember("ocspRevocationStatus") && obj["ocspRevocationStatus"].IsInt()) {
            labsChainCert.OcspRevocationStatus = obj["ocspRevocationStatus"].GetInt();
        }

        if (obj.HasMember("sha1Hash") && obj["sha1Hash"].IsString()) {
            labsChainCert.Sha1Hash.assign(obj["sha1Hash"].GetString());
        }

        if (obj.HasMember("pinSha256") && obj["pinSha256"].IsString()) {
            labsChainCert.PinSha256.assign(obj["pinSha256"].GetString());
        }

        if (obj.HasMember("raw") && obj["raw"].IsString()) {
            labsChainCert.Raw.assign(obj["raw"].GetString());
        }
    }
示例#30
0
	void operator()(
		rapidjson::GenericValue<Encoding, Allocator>& rjv,
		Allocator&,
		bool v
	) const { rjv.SetBool(v); }