예제 #1
0
void Cylinder::computeNHSBitVectors(vector <Cylinder> const & cylinders)
{
	unsigned int count, pos;
	float cmVal;
	float i_abs, j_abs;

	count = 0;
	pos = 0;
	
	for (unsigned int i=1; i<=Ns; i++)
		for (unsigned int j=1; j<=Ns; j++)
			for (unsigned int k=1; k<=Nd; k++)
			{
				pij(i,j,i_abs,j_abs);
				
				if(xiM(i_abs,j_abs))
				{
					cmVal = cm(i,j,k,cylinders);
				
					setB1(pos, cmVal == 1.0);
			
					if (cmVal == -1.0)
						count++;
					
					pos++;
				}
			}

	if (count >= MAXNVCELLS)
	{
		setValidity(false);
	}
	else
	{
		count = 0;
		
		for (unsigned int jj=0; count < MINM && (count+cylinders.size()-jj) >= MINM && jj<cylinders.size(); jj++)
			if (cylinders[jj].dss(X, Y) <= RNEIGHBORHOODRADIUS*RNEIGHBORHOODRADIUS)
				count++;

		setValidity(count >= MINM);
	}
}
예제 #2
0
void ContentDistributor::didShadowBoundaryChange(Element* host)
{
    setValidity(Undetermined);
    invalidateDistribution(host);
}
예제 #3
0
SubscriptionQos::SubscriptionQos(const std::int64_t& validity)
        : expiryDate(-1), publicationTtl(DEFAULT_PUBLICATION_TTL())
{
    setValidity(validity);
}
예제 #4
0
std::shared_ptr<fizz::server::FizzServerContext> createFizzServerContext(
    folly::StringPiece pemCertPath,
    folly::StringPiece certData,
    folly::StringPiece pemKeyPath,
    folly::StringPiece keyData,
    folly::StringPiece pemCaPath,
    bool requireClientVerification,
    wangle::TLSTicketKeySeeds* ticketKeySeeds) {
  initSSL();
  auto certMgr = std::make_unique<fizz::server::CertManager>();
  try {
    auto selfCert =
        fizz::CertUtils::makeSelfCert(certData.str(), keyData.str());
    // add the default cert
    certMgr->addCert(std::move(selfCert), true);
  } catch (const std::exception& ex) {
    LOG_FAILURE(
        "SSLCert",
        failure::Category::kBadEnvironment,
        "Failed to create self cert from \"{}\" and \"{}\".  ex: {}",
        pemCertPath,
        pemKeyPath,
        ex.what());
    return nullptr;
  }

  auto ctx = std::make_shared<fizz::server::FizzServerContext>();
  ctx->setSupportedVersions({fizz::ProtocolVersion::tls_1_3});
  ctx->setSupportedPskModes(
      {fizz::PskKeyExchangeMode::psk_ke, fizz::PskKeyExchangeMode::psk_dhe_ke});
  ctx->setVersionFallbackEnabled(true);
  ctx->setCertManager(std::move(certMgr));
  if (!pemCaPath.empty()) {
    auto verifier = fizz::DefaultCertificateVerifier::createFromCAFile(
        fizz::VerificationContext::Server, pemCaPath.str());
    ctx->setClientCertVerifier(std::move(verifier));
    ctx->setClientAuthMode(fizz::server::ClientAuthMode::Optional);
  }
  if (requireClientVerification) {
    ctx->setClientAuthMode(fizz::server::ClientAuthMode::Required);
  }

  // set ticket seeds
  if (ticketKeySeeds) {
    std::vector<folly::ByteRange> ticketSecrets;
    for (const auto& secret : ticketKeySeeds->currentSeeds) {
      ticketSecrets.push_back(folly::StringPiece(secret));
    }
    for (const auto& secret : ticketKeySeeds->oldSeeds) {
      ticketSecrets.push_back(folly::StringPiece(secret));
    }
    for (const auto& secret : ticketKeySeeds->newSeeds) {
      ticketSecrets.push_back(folly::StringPiece(secret));
    }
    auto cipher = std::make_shared<fizz::server::AES128TicketCipher>();
    cipher->setTicketSecrets(std::move(ticketSecrets));
    cipher->setValidity(std::chrono::seconds(kSessionLifeTime));
    ctx->setTicketCipher(std::move(cipher));
  }
  // TODO: allow for custom FizzFactory
  return ctx;
}
예제 #5
0
SubscriptionQos::SubscriptionQos() : expiryDate(-1), publicationTtl(DEFAULT_PUBLICATION_TTL())
{
    setValidity(1000);
}