Skip to content

Commit

Permalink
IJMP-1990 Fixed work with encrypted/plaintext credentials in the zowe…
Browse files Browse the repository at this point in the history
… config.

Signed-off-by: Katsiaryna Tsytsenia <[email protected]>
  • Loading branch information
Katsiaryna Tsytsenia authored and Katsiaryna Tsytsenia committed Oct 11, 2024
1 parent a649e7e commit 83d790e
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/main/kotlin/org/zowe/kotlinsdk/zowe/config/ZoweConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,12 @@ data class ZoweConfig(
ps.forEach { (_, profile) ->
if (profile.profiles != null) extractSecureProperties(configCredentialsMap, profile.profiles)
profile.secure?.forEach { secureProfileProp ->
profile.properties?.set(
secureProfileProp,
configCredentialsMap["profiles.${buildCredPath(profile, ".profiles.")}.properties.${secureProfileProp}"]
)
if (profile.properties?.get(secureProfileProp) == null &&
configCredentialsMap["profiles.${buildCredPath(profile, ".profiles.")}.properties.${secureProfileProp}"] != null)
profile.properties?.set(
"secure"+secureProfileProp,
configCredentialsMap["profiles.${buildCredPath(profile, ".profiles.")}.properties.${secureProfileProp}"]
)
}
}
}
Expand Down Expand Up @@ -345,11 +347,11 @@ data class ZoweConfig(
}
val curr = buildCredPath(profile, ".profiles.")
profile.secure?.forEach { propName ->
if (profile.properties?.containsKey(propName) == true)
if (profile.properties?.containsKey("secure"+propName) == true)
if (curr == zosmfProfileName)
zosmfConfigCredentialsMap["profiles.${curr}.properties.${propName}"] = profile.properties[propName]
zosmfConfigCredentialsMap["profiles.${curr}.properties.${propName}"] = profile.properties["secure"+propName]
else if (curr == baseProfileName)
baseConfigCredentialsMap["profiles.${curr}.properties.${propName}"] = profile.properties[propName]
baseConfigCredentialsMap["profiles.${curr}.properties.${propName}"] = profile.properties["secure"+propName]
}
}
}
Expand Down Expand Up @@ -395,7 +397,7 @@ data class ZoweConfig(
private fun removeSecure(ps: Map<String, ZoweConfigProfile>?) {
ps?.forEach { (_, v) ->
v.secure?.forEach { propName ->
v.properties?.remove(propName)
v.properties?.remove("secure"+propName)
}
removeSecure(v.profiles)
}
Expand Down Expand Up @@ -425,11 +427,21 @@ data class ZoweConfig(

var user: String?
get() = searchProperty("user") { zosmf(); base() } as String?
set(el) { updateProperty("user", el ?: "") { zosmf(); base() } }
?: searchProperty("secureuser") { zosmf(); base() } as String?
set(el) { if (searchProperty("user") { zosmf(); base() } as String? != null)
updateProperty("user", el ?: "") { zosmf(); base() }
else
updateProperty("secureuser", el ?: "") { zosmf(); base() } }

var password: String?
get() = searchProperty("password") { zosmf(); base() } as String?
set(el) { updateProperty("password", el ?: "") { zosmf(); base() } }
?: searchProperty("securepassword") { zosmf(); base() } as String?
set(el) {
if (searchProperty("password") { zosmf(); base() } as String? != null)
updateProperty("password", el ?: "") { zosmf(); base() }
else
updateProperty("securepassword", el ?: "") { zosmf(); base() }
}

var host: String?
get() = searchProperty("host") { zosmf(); base() } as String?
Expand Down

0 comments on commit 83d790e

Please sign in to comment.