本文整理汇总了Java中com.aliyuncs.DefaultAcsClient类的典型用法代码示例。如果您正苦于以下问题:Java DefaultAcsClient类的具体用法?Java DefaultAcsClient怎么用?Java DefaultAcsClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultAcsClient类属于com.aliyuncs包,在下文中一共展示了DefaultAcsClient类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assumeRole
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
static AssumeRoleResponse assumeRole(String accessKeyId, String accessKeySecret,String roleArn, String roleSessionName, String policy,ProtocolType protocolType) throws ClientException {
try {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
IClientProfile profile = DefaultProfile.getProfile(region_cn_hangzhou, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
// 创建一个 AssumeRoleRequest 并设置请求参数
final AssumeRoleRequest request = new AssumeRoleRequest();
request.setVersion(sta_api_version);
request.setMethod(MethodType.POST);
request.setProtocol(protocolType);
request.setRoleArn(roleArn);
request.setRoleSessionName(roleSessionName);
request.setPolicy(policy);
// 发起请求,并得到response
final AssumeRoleResponse response = client.getAcsResponse(request);
return response;
} catch (ClientException e) {
throw e;
}
}
示例2: getInstance
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
public static SMSUtil getInstance(String key){
if(BasicUtil.isEmpty(key)){
key = "default";
}
SMSUtil util = instances.get(key);
if(null == util){
util = new SMSUtil();
SMSConfig config = SMSConfig.getInstance(key);
util.config = config;
try {
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", config.ACCESS_KEY, config.ACCESS_SECRET);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Sms", "sms.aliyuncs.com");
util.client = new DefaultAcsClient(profile);
}
catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
}
instances.put(key, util);
}
return util;
}
示例3: assumeRole
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
static AssumeRoleResponse assumeRole(String accessKeyId, String accessKeySecret,
String roleArn, String roleSessionName, String policy,
ProtocolType protocolType) throws ClientException {
try {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
IClientProfile profile = DefaultProfile.getProfile(REGION_CN_HANGZHOU, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
// 创建一个 AssumeRoleRequest 并设置请求参数
final AssumeRoleRequest request = new AssumeRoleRequest();
request.setVersion(STS_API_VERSION);
request.setMethod(MethodType.POST);
request.setProtocol(protocolType);
request.setRoleArn(roleArn);
request.setRoleSessionName(roleSessionName);
request.setPolicy(policy);
// 发起请求,并得到response
final AssumeRoleResponse response = client.getAcsResponse(request);
return response;
} catch (ClientException e) {
throw e;
}
}
示例4: assumeRole
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
static AssumeRoleResponse assumeRole(String id, String accessKeyId, String accessKeySecret, String roleArn,
String roleSessionName, String policy, ProtocolType protocolType) throws ClientException {
try {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
IClientProfile profile = DefaultProfile.getProfile(_config.getConf(id, K_regionId), accessKeyId,
accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
// 创建一个 AssumeRoleRequest 并设置请求参数
final AssumeRoleRequest request = new AssumeRoleRequest();
request.setVersion(_config.getConf(id, K_api_version));
request.setMethod(MethodType.POST);
request.setProtocol(protocolType);
request.setRoleArn(roleArn);
request.setRoleSessionName(roleSessionName);
request.setPolicy(policy);
// 发起请求,并得到response
final AssumeRoleResponse response = client.getAcsResponse(request);
return response;
} catch (ClientException e) {
throw e;
}
}
示例5: assumeRole
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
static AssumeRoleResponse assumeRole(String accessKeyId, String accessKeySecret, String roleArn, String roleSessionName, String policy,
ProtocolType protocolType) throws ClientException {
try {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
IClientProfile profile = DefaultProfile.getProfile(REGION_CN_HANGZHOU, accessKeyId, accessKeySecret);
DefaultAcsClient client = new DefaultAcsClient(profile);
// 创建一个 AssumeRoleRequest 并设置请求参数
final AssumeRoleRequest request = new AssumeRoleRequest();
request.setVersion(STS_API_VERSION);
request.setMethod(MethodType.POST);
request.setProtocol(protocolType);
request.setRoleArn(roleArn);
request.setRoleSessionName(roleSessionName);
request.setPolicy(policy);
// 发起请求,并得到response
final AssumeRoleResponse response = client.getAcsResponse(request);
return response;
} catch (ClientException e) {
throw e;
}
}
示例6: getAssumeRoleCredentials
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
private Credentials getAssumeRoleCredentials(String policy)
throws com.aliyuncs.exceptions.ClientException {
IClientProfile profile = DefaultProfile
.getProfile(REGION, ACCESS_KEY, SECRET_KEY);
//DefaultProfile.addEndpoint("sts.us-west-1.aliyuncs.com", "us-west-1", "Sts", "sts.us-west-1.aliyuncs.com");
DefaultAcsClient client = new DefaultAcsClient(profile);
AssumeRoleRequest request = new AssumeRoleRequest();
request.setVersion(STS_API_VERSION);
request.setMethod(MethodType.POST);
request.setProtocol(ProtocolType.HTTPS);
request.setRoleArn(ROLE);
request.setRoleSessionName("test-session");
if (policy != null) {
request.setPolicy(policy);
}
AssumeRoleResponse stsResponse;
try {
stsResponse = client.getAcsResponse(request);
} catch (com.aliyuncs.exceptions.ClientException e) {
throw new RuntimeException(e);
}
String accessKey = stsResponse.getCredentials().getAccessKeyId();
String secretKey = stsResponse.getCredentials().getAccessKeySecret();
String stsToken = stsResponse.getCredentials().getSecurityToken();
assertNotNull(accessKey);
assertNotNull(secretKey);
assertNotNull(stsToken);
return stsResponse.getCredentials();
}
示例7: SmsSenderAliyunImpl
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
public SmsSenderAliyunImpl(AdvancedAliyunOptions options) {
this.options = options;
try {
IClientProfile profile = DefaultProfile.getProfile(options.getArea(),
options.getAccessKey(),
options.getAccessSecret());
DefaultProfile.addEndpoint(options.getArea(), options.getArea(), "Sms", options.getSmsEndpoint());
client = new DefaultAcsClient(profile);
}
catch (Throwable e) {
throw new SmsException("Initialize the aliyun sms client failed.", e);
}
}
示例8: ApiRequest
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
/**
* 构造一个api命令对象
* @param request 阿里云Request,可接受各类阿里云RoaAcsRequest的子类
* @param region 可用区标识符,Regions类中提供了可用区的常量池
* @param credential api鉴权信息
*/
public ApiRequest(RoaAcsRequest request, String region, ApiCredential credential) {
this.profile = DefaultProfile.getProfile(region, credential.getKey(), credential.getSecret());
this.client = new DefaultAcsClient(this.profile);
this.request = request;
this.request.putHeaderParameter("x-acs-region-id", region);
}
示例9: onContextRefreshed
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
@Override
public void onContextRefreshed() {
if (validator.isEmpty(key) || validator.isEmpty(secret))
return;
try {
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", key, secret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", "Dysmsapi", "dysmsapi.aliyuncs.com");
acsClient = new DefaultAcsClient(profile);
if (logger.isInfoEnable())
logger.info("初始化阿里云短信接口[{}]完成。", key);
} catch (Exception e) {
logger.warn(e, "初始化阿里云短信接口时发生异常!");
}
}
示例10: setSecurityInfo
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
public void setSecurityInfo(String accessKeyId, String secret) {
IClientProfile profile = DefaultProfile.getProfile(REGION_CN, accessKeyId, secret);
client = new DefaultAcsClient(profile);
bLogin = true;
}
示例11: getAcsClient
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
@Override
public IAcsClient getAcsClient(String region) {
IClientProfile profile = DefaultProfile.getProfile(region, identity, credential);
return new DefaultAcsClient(profile);
}
示例12: AliyunPushUtil
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
public AliyunPushUtil(String regionId, String accessKeyId, String accessKeySecret, long appKey) {
this.appKey = appKey;
profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
client = new DefaultAcsClient(profile);
}
示例13: init
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
@PostConstruct
public void init() {
profile = DefaultProfile.getProfile("cn-qingdao", key, secret);
client = new DefaultAcsClient(profile);
}
示例14: TxtFilterUtil
import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
/**
* 文本合法性过滤
* @param regionId 哪个区,如 cn-hangzhou 、 cn-qingdao
* @param accessKeyId 阿里云的 AccessKeys 查看
* @param accessKeySecret
*/
public TxtFilterUtil(String regionId, String accessKeyId, String accessKeySecret) {
//请替换成你自己的accessKeyId、accessKeySecret
profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
client = new DefaultAcsClient(profile);
}