com.aliyuncs.v5.auth.SystemPropertiesCredentialsProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aliyun-java-sdk-core-v5 Show documentation
Show all versions of aliyun-java-sdk-core-v5 Show documentation
Aliyun Open API SDK for Java
Copyright (C) Alibaba Cloud Computing
All rights reserved.
版权所有 (C)阿里云计算有限公司
http://www.aliyun.com
The newest version!
package com.aliyuncs.v5.auth;
import com.aliyuncs.v5.exceptions.ClientException;
import com.aliyuncs.v5.exceptions.ServerException;
import com.aliyuncs.v5.utils.AuthUtils;
import com.aliyuncs.v5.utils.StringUtils;
public class SystemPropertiesCredentialsProvider implements AlibabaCloudCredentialsProvider {
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException, ServerException {
if (!"default".equals(AuthUtils.getClientType())) {
return null;
}
String accessKeyId = System.getProperty(AuthConstant.SYSTEM_ACCESSKEYID);
String accessKeySecret = System.getProperty(AuthConstant.SYSTEM_ACCESSKEYSECRET);
if (StringUtils.isEmpty(accessKeyId) || StringUtils.isEmpty(accessKeySecret)) {
return null;
}
return new BasicCredentials(accessKeyId, accessKeySecret);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy