vod普通加密
This commit is contained in:
@@ -5,6 +5,13 @@ import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.aliyun.vod20170321.Client;
|
||||
import com.aliyun.vod20170321.models.GetVideoPlayAuthRequest;
|
||||
import com.aliyun.vod20170321.models.GetVideoPlayAuthResponse;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.aliyuncs.DefaultAcsClient;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.IClientProfile;
|
||||
import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest;
|
||||
import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse;
|
||||
//import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||||
//import org.bytedeco.javacv.FrameGrabber;
|
||||
|
||||
@@ -59,4 +66,53 @@ public class SpdbUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static AssumeRoleResponse assumeRole() throws ClientException {
|
||||
try {
|
||||
|
||||
String accessKeyId = "LTAI5tC9d38msYxw6RSEwJJR";
|
||||
|
||||
String accessKeySecret = "njJxkvrwBmbMfGyhAFeyjthodnwt58";
|
||||
|
||||
String roleArn = "acs:ram::1604740137891907:role/vodrole";
|
||||
|
||||
String roleSessionName = "testsession";
|
||||
|
||||
String policy = "{\n" +
|
||||
" \"Version\": \"1\",\n" +
|
||||
" \"Statement\": [\n" +
|
||||
" {\n" +
|
||||
" \"Action\": \"vod:*\",\n" +
|
||||
" \"Resource\": \"*\",\n" +
|
||||
" \"Effect\": \"Allow\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
//构造default profile(参数留空,无需添加Region ID)
|
||||
/*
|
||||
说明:当设置SysEndpoint为sts.aliyuncs.com时,regionId可填可不填;反之,regionId必填,根据使用的服务区域填写,例如:cn-shanghai
|
||||
详情参考STS各地域的Endpoint。
|
||||
*/
|
||||
IClientProfile profile = DefaultProfile.getProfile("", accessKeyId, accessKeySecret);
|
||||
//用profile构造client
|
||||
DefaultAcsClient client = new DefaultAcsClient(profile);
|
||||
// 创建一个 AssumeRoleRequest 并设置请求参数
|
||||
final AssumeRoleRequest request = new AssumeRoleRequest();
|
||||
// request.setSysEndpoint("sts.aliyuncs.com");
|
||||
// request.setSysMethod(MethodType.POST);
|
||||
request.setRoleArn(roleArn);
|
||||
request.setRoleSessionName(roleSessionName);
|
||||
request.setPolicy(policy);
|
||||
request.setRegionId("cn-shanghai");
|
||||
// 发起请求,并得到response
|
||||
final AssumeRoleResponse response = client.getAcsResponse(request);
|
||||
return response;
|
||||
} catch (ClientException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user