github-advanced-security[bot] commented on code in PR #16043:
URL: 
https://github.com/apache/dolphinscheduler/pull/16043#discussion_r1607578547


##########
dolphinscheduler-authentication/dolphinscheduler-aws-authentication/src/main/java/org/apache/dolphinscheduler/authentication/aws/AWSCredentialsProviderFactor.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.authentication.aws;
+
+import java.util.Map;
+
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+
+import com.amazonaws.auth.AWSCredentialsProvider;
+import com.amazonaws.auth.AWSStaticCredentialsProvider;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.auth.InstanceProfileCredentialsProvider;
+
+@Slf4j
+@UtilityClass
+public class AWSCredentialsProviderFactor {
+
+    public static AWSCredentialsProvider credentialsProvider(Map<String, 
String> awsProperties) {
+        String awsAuthenticationType =
+                
awsProperties.getOrDefault(AwsConfigurationKeys.AWS_AUTHENTICATION_TYPE,
+                        
AWSCredentialsProviderType.STATIC_CREDENTIALS_PROVIDER.getName());
+        switch (AWSCredentialsProviderType.of(awsAuthenticationType)) {
+            case STATIC_CREDENTIALS_PROVIDER:
+                return createAWSStaticCredentialsProvider(awsProperties);
+            case INSTANCE_PROFILE_CREDENTIALS_PROVIDER:
+                return createInstanceProfileCredentialsProvider(awsProperties);
+            default:
+                throw new IllegalArgumentException(
+                        "The aws.credentials.provider.type: " + 
awsAuthenticationType + " is invalidated");
+        }
+
+    }
+
+    private static AWSCredentialsProvider 
createAWSStaticCredentialsProvider(Map<String, String> awsProperties) {
+        String awsAccessKeyId = 
awsProperties.get(AwsConfigurationKeys.AWS_ACCESS_KEY_ID);
+        String awsSecretAccessKey = 
awsProperties.get(AwsConfigurationKeys.AWS_SECRET);
+        final BasicAWSCredentials basicAWSCredentials = new 
BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey);
+        AWSStaticCredentialsProvider awsStaticCredentialsProvider =
+                new AWSStaticCredentialsProvider(basicAWSCredentials);
+        log.info("AWSStaticCredentialsProvider created successfully");
+        return awsStaticCredentialsProvider;
+    }
+
+    private static AWSCredentialsProvider 
createInstanceProfileCredentialsProvider(Map<String, String> awsProperties) {

Review Comment:
   ## Useless parameter
   
   The parameter 'awsProperties' is never used.
   
   [Show more 
details](https://github.com/apache/dolphinscheduler/security/code-scanning/4155)



-- 
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]

Reply via email to