[
https://issues.apache.org/jira/browse/HADOOP-13609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15501897#comment-15501897
]
Kai Zheng edited comment on HADOOP-13609 at 9/19/16 12:31 AM:
--------------------------------------------------------------
Genmao,
I thought we missed to consolidate the codes in the following two places, as I
said at the beginning.
In {{CredentialsProvider getCredentialsProvider}}:
{code}
if (StringUtils.isEmpty(className)) {
Configuration newConf =
ProviderUtils.excludeIncompatibleCredentialProviders(conf,
AliyunOSSFileSystem.class);
String accessKeyId =
AliyunOSSUtils.getValueWithKey(newConf, ACCESS_KEY_ID);
String accessKeySecret =
AliyunOSSUtils.getValueWithKey(newConf, ACCESS_KEY_SECRET);
credentials = new DefaultCredentialProvider(
new DefaultCredentials(accessKeyId, accessKeySecret));
}
{code}
And in {{AliyunCredentialsProvider(URI uri, Configuration conf)}}:
{code}
public AliyunCredentialsProvider(URI uri, Configuration conf)
throws IOException {
String accessKeyId =
AliyunOSSUtils.getValueWithKey(conf, ACCESS_KEY_ID);
String accessKeySecret =
AliyunOSSUtils.getValueWithKey(conf, ACCESS_KEY_SECRET);
String securityToken =
AliyunOSSUtils.getValueWithKey(conf, SECURITY_TOKEN);
if (!StringUtils.isEmpty(accessKeyId)
&& !StringUtils.isEmpty(accessKeySecret)) {
credentials = new DefaultCredentials(accessKeyId, accessKeySecret,
securityToken);
} else {
throw new InvalidCredentialsException(
"AccessKeyId and AccessKeySecret should not be null or empty.");
}
}
{code}
We might have two AliyunCredentialsProvider constructors, one going with a
security token, the other without token. In the current constructor, the
{{uri}} parameter isn't used and needed. {{AliyunCredentialsProvider#NAME}} is
also not needed.
Would you help clean up and refine further? Thanks!
was (Author: drankye):
Genmao,
I thought we missed to consolidate the codes in the following two places, as I
said at the beginning.
In {{CredentialsProvider getCredentialsProvider}}:
{code}
if (StringUtils.isEmpty(className)) {
Configuration newConf =
ProviderUtils.excludeIncompatibleCredentialProviders(conf,
AliyunOSSFileSystem.class);
String accessKeyId =
AliyunOSSUtils.getValueWithKey(newConf, ACCESS_KEY_ID);
String accessKeySecret =
AliyunOSSUtils.getValueWithKey(newConf, ACCESS_KEY_SECRET);
credentials = new DefaultCredentialProvider(
new DefaultCredentials(accessKeyId, accessKeySecret));
}
{code}
And in {{AliyunCredentialsProvider(URI uri, Configuration conf)}
{code}
public AliyunCredentialsProvider(URI uri, Configuration conf)
throws IOException {
String accessKeyId =
AliyunOSSUtils.getValueWithKey(conf, ACCESS_KEY_ID);
String accessKeySecret =
AliyunOSSUtils.getValueWithKey(conf, ACCESS_KEY_SECRET);
String securityToken =
AliyunOSSUtils.getValueWithKey(conf, SECURITY_TOKEN);
if (!StringUtils.isEmpty(accessKeyId)
&& !StringUtils.isEmpty(accessKeySecret)) {
credentials = new DefaultCredentials(accessKeyId, accessKeySecret,
securityToken);
} else {
throw new InvalidCredentialsException(
"AccessKeyId and AccessKeySecret should not be null or empty.");
}
}
{code}
We might have two AliyunCredentialsProvider constructors, one going with a
security token, the other without token. In the current constructor, the
{{uri}} parameter isn't used and needed. {{AliyunCredentialsProvider#NAME}} is
also not needed.
Would you help clean up and refine further? Thanks!
> Refine credential provider related codes for AliyunOss integration
> ------------------------------------------------------------------
>
> Key: HADOOP-13609
> URL: https://issues.apache.org/jira/browse/HADOOP-13609
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: fs
> Affects Versions: HADOOP-12756
> Reporter: Kai Zheng
> Assignee: Genmao Yu
> Fix For: HADOOP-12756
>
> Attachments: HADOOP-13609-HADOOP-12756.001.patch,
> HADOOP-13609-HADOOP-12756.002.patch, HADOOP-13609-HADOOP-12756.003.patch
>
>
> looking at the AliyunOss integration codes, some findings:
> 1. {{TemporaryAliyunCredentialsProvider}} could be better named;
> 2. TemporaryAliyunCredentialsProvider shared many codes with
> {{AliyunOSSUtils#getCredentialsProvider}}, and the dup can be resolved;
> 3. {{AliyunOSSUtils#getPassword}} is rather confusing, as used to get other
> things than password.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]