Skip to content

Commit

Permalink
Removed unused mehtods and LogInfo msg from VaultHelper (apache#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gschiavon authored and jlopezmalla committed Sep 6, 2017
1 parent 7ad4018 commit 2c74458
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions core/src/main/scala/org/apache/spark/security/VaultHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ object VaultHelper extends Logging {
logDebug(s"Requesting login from app and role: $requestUrl")
val replace: String = jsonRoleSecretTemplate.replace("_replace_role_", roleId)
.replace("_replace_secret_", secretId)
logInfo(s"getting secret: $secretId and role: $roleId")
logInfo(s"generated JSON: $replace")
logDebug(s"getting secret: $secretId and role: $roleId")
logDebug(s"generated JSON: $replace")
val jsonAppRole = replace
HTTPHelper.executePost(requestUrl, "auth",
None, Some(jsonAppRole))("client_token").asInstanceOf[String]
Expand All @@ -43,7 +43,7 @@ object VaultHelper extends Logging {
role: String): String = {
val requestUrl = s"$vaultUrl/v1/auth/approle/role/$role/role-id"
if (!token.isDefined) token = {
logDebug(s"Requesting token from app role:")
logDebug(s"Requesting token from app role: $role")
Option(VaultHelper.getTokenFromAppRole(vaultUrl,
sys.env("VAULT_ROLE_ID"),
sys.env("VAULT_SECRET_ID")))
Expand All @@ -57,7 +57,7 @@ object VaultHelper extends Logging {
role: String): String = {
val requestUrl = s"$vaultUrl/v1/auth/approle/role/$role/secret-id"
if (!token.isDefined) token = {
logDebug(s"Requesting token from app role:")
logDebug(s"Requesting token from app role: $role")
Option(VaultHelper.getTokenFromAppRole(vaultUrl,
sys.env("VAULT_ROLE_ID"),
sys.env("VAULT_SECRET_ID")))
Expand Down Expand Up @@ -90,22 +90,6 @@ object VaultHelper extends Logging {
(keytab64, principal)
}

@deprecated
def getRootCA(vaultUrl: String, token: String): String = {
val certVaultPath = "/v1/ca-trust/certificates/"
val requestUrl = s"$vaultUrl/$certVaultPath"
val listCertKeysVaultPath = s"$requestUrl?list=true"

logDebug(s"Requesting Cert List: $listCertKeysVaultPath")
val keys = HTTPHelper.executeGet(listCertKeysVaultPath,
"data", Some(Seq(("X-Vault-Token", token))))("keys").asInstanceOf[List[String]]

keys.flatMap(key => {
HTTPHelper.executeGet(s"$requestUrl$key",
"data", Some(Seq(("X-Vault-Token", token)))).find(_._1.endsWith("_crt"))
}).map(_._2).mkString
}

def getTrustStore(vaultUrl: String, token: String, certVaultPath: String): String = {
val requestUrl = s"$vaultUrl/$certVaultPath"
val truststoreVaultPath = s"$requestUrl"
Expand All @@ -117,14 +101,6 @@ object VaultHelper extends Logging {
trustStore
}

def getCertPassFromVault(vaultUrl: String, token: String): String = {
val certPassVaultPath = "/v1/ca-trust/passwords/default/keystore"
logDebug(s"Requesting Cert Pass: $certPassVaultPath")
val requestUrl = s"$vaultUrl/$certPassVaultPath"
HTTPHelper.executeGet(requestUrl,
"data", Some(Seq(("X-Vault-Token", token))))("pass").asInstanceOf[String]
}

def getCertPassForAppFromVault(vaultUrl: String,
appPassVaulPath: String,
token: String): String = {
Expand All @@ -146,15 +122,6 @@ object VaultHelper extends Logging {
(key, certs)
}

def getPassForAppFromVault(vaultUrl: String,
vaultPath: String,
token: String): String = {
logDebug(s"Requesting Pass for App: $vaultPath")
val requestUrl = s"$vaultUrl/$vaultPath"
HTTPHelper.executeGet(requestUrl,
"data", Some(Seq(("X-Vault-Token", token))))("token").asInstanceOf[String]
}

def getRealToken(vaultUrl: String, token: String): String = {
val requestUrl = s"$vaultUrl/v1/sys/wrapping/unwrap"
logDebug(s"Requesting real Token: $requestUrl")
Expand Down

0 comments on commit 2c74458

Please sign in to comment.