Repository navigation
Parse service-key credential references in dynamic parameters #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,9 @@ public final class DynamicParameterUtil { | |
| public static final String PATTERN_FOR_DYNAMIC_PARAMETERS = "'{'ds/{0}/{1}'}'"; | ||
| public static final String REGEX_PATTERN_FOR_DYNAMIC_PARAMETERS = "^\\{ds[A-Za-z0-9_\\-\\.\\/]+\\}$"; | ||
|
|
||
| private static final String SERVICE_KEY_REFERENCE_PREFIX = "service-keys."; | ||
| private static final String CREDENTIALS_SEPARATOR = ".credentials."; | ||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are these dots after or between keywords?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dots are delimiters in the SERVICE_KEY_REFERENCE_PREFIX = "service-keys." - separates the literal service-keys token from the key name, so we can strip it off and get key CREDENTIALS_SEPARATOR = ".credentials." - fences off the literal credentials token, so we can split off field for exampel: "{ds/source-service/service-keys.source-key.credentials.clientid}" |
||
|
|
||
| private DynamicParameterUtil() { | ||
| } | ||
|
|
||
|
|
@@ -16,4 +19,16 @@ public static String getParameterName(String dynamicParameter) { | |
| return dynamicParameter.substring(dynamicParameter.lastIndexOf("/") + 1, dynamicParameter.lastIndexOf("}")); | ||
| } | ||
|
|
||
| public static boolean isServiceKeyCredentialReference(String parameterName) { | ||
| return parameterName.startsWith(SERVICE_KEY_REFERENCE_PREFIX) && parameterName.contains(CREDENTIALS_SEPARATOR); | ||
| } | ||
|
|
||
| public static String getServiceKeyName(String parameterName) { | ||
| return parameterName.substring(SERVICE_KEY_REFERENCE_PREFIX.length(), parameterName.indexOf(CREDENTIALS_SEPARATOR)); | ||
| } | ||
|
|
||
| public static String getCredentialFieldPath(String parameterName) { | ||
| return parameterName.substring(parameterName.indexOf(CREDENTIALS_SEPARATOR) + CREDENTIALS_SEPARATOR.length()); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is written, this will only work for a 'credentials' map inside the service key. Should this be a bit more general or do we intentionally want it this way? What would happen if the ztis service changes the internal service key parameter structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
credentials is the standard CF contract for service keys, not a ZTIS-specific structure. Every CF service key, regardless of service type, returns its useful data under credentials