bobpaulin commented on code in PR #9635:
URL: https://github.com/apache/nifi/pull/9635#discussion_r1917248042
##########
nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/factory/strategies/AbstractServiceAccountCredentialsStrategy.java:
##########
@@ -37,7 +39,13 @@ public AbstractServiceAccountCredentialsStrategy(String
name, PropertyDescriptor
@Override
public GoogleCredentials getGoogleCredentials(Map<PropertyDescriptor,
String> properties, HttpTransportFactory transportFactory) throws IOException {
+ final String delegationStrategy =
properties.get(CredentialPropertyDescriptors.DELEGATION_STRATEGY);
+ if (delegationStrategy != null &&
delegationStrategy.equals(DelegationStrategy.DELEGATED_ACCOUNT.getValue())) {
+ final String delegationUser =
properties.get(CredentialPropertyDescriptors.DELEGATION_USER);
+ return
GoogleCredentials.fromStream(getServiceAccountJson(properties),
transportFactory).createDelegated(delegationUser);
+ } else {
return
GoogleCredentials.fromStream(getServiceAccountJson(properties),
transportFactory);
+ }
Review Comment:
So that would be possible but the switch statement would be based on the
string value since properties map doesn't return the enum directly. So I'd
still have a default case to handle that would essentially be the null check.
```
switch (delegationStrategy) {
case DelegationStrategy.DELEGATED_ACCOUNT.getValue():
....
case DelegationStrategy.SERVICE_ACCOUNT.getValue()
...
default:
throw IllegalArgumentException("Delegation Strategy not defined");
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]