in common/src/main/kotlin/org/jetbrains/teamcity/vault/gcp/GcpAuthenticationHandler.kt [37:58]
fun vaultTokenData(settings: VaultFeatureSettings): VaultTokenData {
if (settings.auth !is Auth.GcpIamAuth) {
error("Unsupported auth method: ${settings.auth.method}, class: ${settings.auth::class.qualifiedName}")
}
val gcpIamAuth = settings.auth
val template = createRestTemplate(settings, trustStoreProvider)
val gcpAuth = gcpIamCredentialsAuthentication(gcpIamAuth, template)
try {
return retrieveLeasedTokenInfo(gcpAuth, template)
} catch (e: VaultException) {
val cause = e.cause
if (cause is HttpStatusCodeException) {
throw VaultException("Cannot log in to HashiCorp Vault using ${gcpIamAuth.method.name} method: ${cause.message}")
}
throw e
}
}