MCPcopy Create free account
hub / github.com/OSGeo/gdal / GetConfiguration

Method GetConfiguration

port/cpl_google_cloud.cpp:361–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359/************************************************************************/
360
361bool VSIGSHandleHelper::GetConfiguration(const std::string &osPathForOption,
362 CSLConstList papszOptions,
363 std::string &osSecretAccessKey,
364 std::string &osAccessKeyId,
365 bool &bUseAuthenticationHeader,
366 GOA2Manager &oManager)
367{
368 osSecretAccessKey.clear();
369 osAccessKeyId.clear();
370 bUseAuthenticationHeader = false;
371
372 if (CPLTestBool(VSIGetPathSpecificOption(osPathForOption.c_str(),
373 "GS_NO_SIGN_REQUEST", "NO")))
374 {
375 return true;
376 }
377
378 osSecretAccessKey = VSIGetPathSpecificOption(osPathForOption.c_str(),
379 "GS_SECRET_ACCESS_KEY", "");
380 if (!osSecretAccessKey.empty())
381 {
382 osAccessKeyId = VSIGetPathSpecificOption(osPathForOption.c_str(),
383 "GS_ACCESS_KEY_ID", "");
384 if (osAccessKeyId.empty())
385 {
386 VSIError(VSIE_InvalidCredentials,
387 "GS_ACCESS_KEY_ID configuration option not defined");
388 bFirstTimeForDebugMessage = false;
389 return false;
390 }
391
392 if (bFirstTimeForDebugMessage)
393 {
394 CPLDebug("GS", "Using GS_SECRET_ACCESS_KEY and "
395 "GS_ACCESS_KEY_ID configuration options");
396 }
397 bFirstTimeForDebugMessage = false;
398 return true;
399 }
400
401 const std::string osHeaderFile = VSIGetPathSpecificOption(
402 osPathForOption.c_str(), "GDAL_HTTP_HEADER_FILE", "");
403 bool bMayWarnDidNotFindAuth = false;
404 if (!osHeaderFile.empty())
405 {
406 bool bFoundAuth = false;
407 VSILFILE *fp = nullptr;
408 // Do not allow /vsicurl/ access from /vsicurl because of
409 // GetCurlHandleFor() e.g. "/vsicurl/,HEADER_FILE=/vsicurl/,url= " would
410 // cause use of memory after free
411 if (strstr(osHeaderFile.c_str(), "/vsicurl/") == nullptr &&
412 strstr(osHeaderFile.c_str(), "/vsicurl?") == nullptr &&
413 strstr(osHeaderFile.c_str(), "/vsis3/") == nullptr &&
414 strstr(osHeaderFile.c_str(), "/vsigs/") == nullptr &&
415 strstr(osHeaderFile.c_str(), "/vsiaz/") == nullptr &&
416 strstr(osHeaderFile.c_str(), "/vsioss/") == nullptr &&
417 strstr(osHeaderFile.c_str(), "/vsiswift/") == nullptr)
418 {

Callers

nothing calls this directly

Calls 15

CPLTestBoolFunction · 0.85
VSIGetPathSpecificOptionFunction · 0.85
VSIErrorFunction · 0.85
CPLDebugFunction · 0.85
VSIFOpenLFunction · 0.85
CPLErrorFunction · 0.85
CPLReadLineLFunction · 0.85
VSIFCloseLFunction · 0.85
CSLFetchNameValueDefFunction · 0.85
CPLMallocFunction · 0.85
VSIFReadLFunction · 0.85
moveFunction · 0.85

Tested by

no test coverage detected