• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultAcsClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;
	}
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:21,代码来源:OSSUtil.java


示例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;
}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:23,代码来源:SMSUtil.java


示例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;
    }
}
 
开发者ID:aliyun,项目名称:sts-demo-simple-android-app,代码行数:27,代码来源:StsServiceImpl.java


示例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;
    }
}
 
开发者ID:dzh,项目名称:jframe,代码行数:27,代码来源:STSServiceImpl.java


示例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;
    }
}
 
开发者ID:dzh,项目名称:jframe,代码行数:26,代码来源:StsServiceSample.java


示例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();
}
 
开发者ID:aliyun,项目名称:fc-java-sdk,代码行数:35,代码来源:FunctionComputeClientTest.java


示例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);
	}
}
 
开发者ID:melthaw,项目名称:spring-backend-boilerplate,代码行数:14,代码来源:SmsSenderAliyunImpl.java


示例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);
}
 
开发者ID:peterchen82,项目名称:iaac4j.aliyun,代码行数:13,代码来源:ApiRequest.java


示例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, "初始化阿里云短信接口时发生异常!");
    }
}
 
开发者ID:heisedebaise,项目名称:ranch,代码行数:16,代码来源:AliyunSmsSenderImpl.java


示例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;
}
 
开发者ID:aliyun,项目名称:aliyun-cloudphotos-android-demo,代码行数:6,代码来源:PhotoStoreClient.java


示例11: getAcsClient

import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
@Override
public IAcsClient getAcsClient(String region) {
   IClientProfile profile = DefaultProfile.getProfile(region, identity, credential);
   return new DefaultAcsClient(profile);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:6,代码来源:ECSApiImpl.java


示例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);
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:6,代码来源:AliyunPushUtil.java


示例13: init

import com.aliyuncs.DefaultAcsClient; //导入依赖的package包/类
@PostConstruct
public void init() {
    profile = DefaultProfile.getProfile("cn-qingdao", key, secret);
    client = new DefaultAcsClient(profile);
}
 
开发者ID:chocotan,项目名称:lolibox,代码行数:6,代码来源:AliGreenService.java


示例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);
}
 
开发者ID:xnx3,项目名称:xnx3,代码行数:12,代码来源:TxtFilterUtil.java



注:本文中的com.aliyuncs.DefaultAcsClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AVFile类代码示例发布时间:2022-05-22
下一篇:
Java JXTree类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap