forked from qiniu/java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZoneReqInfo.java
More file actions
40 lines (33 loc) · 1.09 KB
/
Copy pathZoneReqInfo.java
File metadata and controls
40 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.qiniu.common;
import com.qiniu.util.Json;
import com.qiniu.util.UrlSafeBase64;
/**
* 封装了 accessKey 和 bucket 的类
*/
@Deprecated
public class ZoneReqInfo {
private final String accessKey;
private final String bucket;
public ZoneReqInfo(String token) throws QiniuException {
// http://developer.qiniu.com/article/developer/security/upload-token.html
// http://developer.qiniu.com/article/developer/security/put-policy.html
try {
String[] strings = token.split(":");
accessKey = strings[0];
String policy = new String(UrlSafeBase64.decode(strings[2]), Constants.UTF_8);
bucket = Json.decode(policy).get("scope").toString().split(":")[0];
} catch (Exception e) {
throw new QiniuException(e, "token is invalid");
}
}
public ZoneReqInfo(String accessKey, String bucket) {
this.accessKey = accessKey;
this.bucket = bucket;
}
public String getAccessKey() {
return accessKey;
}
public String getBucket() {
return bucket;
}
}