Skip to content

Commit fea95df

Browse files
committed
由温仰发起的CORE SDK自动发布, BUILD_ID=41, 版本号:3.2.7
发布日志: 1, 解决不支持body参数的bug
1 parent 4914331 commit fea95df

22 files changed

Lines changed: 384 additions & 28 deletions

aliyun-java-sdk-core/ChangeLog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2017-08-11 Version: 3.2.7
2+
1, 解决不支持body参数的bug
3+
14
2017-07-27 Version: 3.2.6
25
1, 支持自动寻址,自动寻址endpoint缓存失效时间为1小时
36
2, 手工调用addEndpoint方法添加endpoint优先级高于自动寻址

aliyun-java-sdk-core/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<groupId>com.aliyun</groupId>
44
<artifactId>aliyun-java-sdk-core</artifactId>
55
<packaging>jar</packaging>
6-
<version>3.2.6</version>
7-
<name>aliyun-java-sdk-core</name>
6+
<version>3.2.7</version>
7+
<name>aliyun-java-sdk-core</name>
88
<url>http://www.aliyun.com</url>
99
<description>Aliyun Open API SDK for Java
1010

@@ -51,6 +51,12 @@ http://www.aliyun.com</description>
5151
<version>4.12</version>
5252
<scope>test</scope>
5353
</dependency>
54+
<dependency>
55+
<groupId>com.alibaba</groupId>
56+
<artifactId>fastjson</artifactId>
57+
<version>1.1.36</version>
58+
<scope>test</scope>
59+
</dependency>
5460
</dependencies>
5561

5662
<build>

aliyun-java-sdk-core/src/main/java/com/aliyuncs/AcsRequest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public abstract class AcsRequest<T extends AcsResponse> extends HttpRequest {
4747
private ProtocolType protocol = ProtocolType.HTTP;
4848
private final Map<String, String> queryParameters = new HashMap<String, String>();
4949
private final Map<String, String> domainParameters = new HashMap<String, String>();
50+
private final Map<String, String> bodyParameters = new HashMap<String, String>();
5051

5152
private String locationProduct;
5253
private String endpointType;
@@ -105,11 +106,7 @@ public Map<String, String> getQueryParameters() {
105106
return Collections.unmodifiableMap(queryParameters);
106107
}
107108

108-
public <K> void putQueryParameter(String name, K value) {
109-
setParameter(this.queryParameters, name, value);
110-
}
111-
112-
protected void putQueryParameter(String name, String value) {
109+
public void putQueryParameter(String name, Object value) {
113110
setParameter(this.queryParameters, name, value);
114111
}
115112

@@ -121,11 +118,15 @@ protected void putDomainParameter(String name, Object value) {
121118
setParameter(this.domainParameters, name, value);
122119
}
123120

124-
protected void putDomainParameter(String name, String value) {
125-
setParameter(this.domainParameters, name, value);
121+
public Map<String, String> getBodyParameters() {
122+
return Collections.unmodifiableMap(bodyParameters);
123+
}
124+
125+
protected void putBodyParameter(String name, Object value) {
126+
setParameter(this.bodyParameters, name, value);
126127
}
127128

128-
protected <K> void setParameter(Map<String, String> map, String name, K value) {
129+
protected void setParameter(Map<String, String> map, String name, Object value) {
129130
if (null == map || null == name || null == value) {
130131
return;
131132
}

aliyun-java-sdk-core/src/main/java/com/aliyuncs/OssAcsRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,6 @@ public HttpRequest signRequest(ISigner signer, Credential credential,
9999
return request;
100100
}
101101

102+
@Override
102103
public abstract Class<T> getResponseClass();
103104
}

aliyun-java-sdk-core/src/main/java/com/aliyuncs/RoaAcsRequest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.aliyuncs.http.FormatType;
3232
import com.aliyuncs.http.HttpRequest;
3333
import com.aliyuncs.regions.ProductDomain;
34+
import com.aliyuncs.utils.ParameterHelper;
3435

3536
public abstract class RoaAcsRequest<T extends AcsResponse> extends AcsRequest<T> {
3637

@@ -101,6 +102,7 @@ protected void putPathParameter(String name, String value) {
101102
setParameter(this.pathParameters, name, value);
102103
}
103104

105+
@Override
104106
public String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException {
105107

106108
Map<String, String> mapQueries = (queries == null) ? this.getQueryParameters() : queries;
@@ -135,6 +137,12 @@ public void setUriPattern(String uriPattern) {
135137
public HttpRequest signRequest(ISigner signer, Credential credential, FormatType format, ProductDomain domain)
136138
throws InvalidKeyException, IllegalStateException, UnsupportedEncodingException, NoSuchAlgorithmException {
137139

140+
Map<String, String> formParams = this.getBodyParameters();
141+
if (formParams != null && !formParams.isEmpty()) {
142+
byte[] data = ParameterHelper.getFormData(formParams);
143+
this.setHttpContent(data, "UTF-8", FormatType.FORM);
144+
}
145+
138146
Map<String, String> imutableMap = new HashMap<String, String>(this.getHeaders());
139147
if (null != signer && null != credential) {
140148
String accessKeyId = credential.getAccessKeyId();

aliyun-java-sdk-core/src/main/java/com/aliyuncs/RpcAcsRequest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.aliyuncs.http.HttpRequest;
3131
import com.aliyuncs.http.MethodType;
3232
import com.aliyuncs.regions.ProductDomain;
33+
import com.aliyuncs.utils.ParameterHelper;
3334

3435
public abstract class RpcAcsRequest<T extends AcsResponse> extends AcsRequest<T> {
3536

@@ -98,6 +99,7 @@ public void setAcceptFormat(FormatType acceptFormat) {
9899
this.putQueryParameter("Format", acceptFormat.toString());
99100
}
100101

102+
@Override
101103
public String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException {
102104
Map<String, String> mapQueries = (queries == null) ? this.getQueryParameters() : queries;
103105
StringBuilder urlBuilder = new StringBuilder("");
@@ -122,12 +124,21 @@ public HttpRequest signRequest(ISigner signer, Credential credential, FormatType
122124
}
123125
imutableMap = this.composer.refreshSignParameters(this.getQueryParameters(), signer, accessKeyId, format);
124126
imutableMap.put("RegionId", getRegionId());
125-
String strToSign = this.composer.composeStringToSign(this.getMethod(), null, signer, imutableMap, null,
127+
Map<String, String> paramsToSign = new HashMap<String, String>(imutableMap);
128+
Map<String, String> formParams = this.getBodyParameters();
129+
if (formParams != null && !formParams.isEmpty()) {
130+
byte[] data = ParameterHelper.getFormData(formParams);
131+
this.setHttpContent(data, "UTF-8", FormatType.FORM);
132+
paramsToSign.putAll(formParams);
133+
}
134+
String strToSign = this.composer.composeStringToSign(this.getMethod(), null, signer, paramsToSign, null,
126135
null);
127136
String signature = signer.signString(strToSign, accessSecret + "&");
128137
imutableMap.put("Signature", signature);
129138
}
130139
setUrl(this.composeUrl(domain.getDomianName(), imutableMap));
131140
return this;
132141
}
142+
143+
133144
}

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/OssSignatureComposer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private String buildQueryString(String uri, Map<String, String> queries) {
5050
return queryString;
5151
}
5252

53+
@Override
5354
public String composeStringToSign(MethodType method, String uriPattern,
5455
ISigner signer, Map<String, String> queries,
5556
Map<String, String> headers, Map<String, String> paths) {

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/RoaSignatureComposer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class RoaSignatureComposer implements ISignatureComposer {
3232
protected final static String QUERY_SEPARATOR = "&";
3333
protected final static String HEADER_SEPARATOR = "\n";
3434

35+
@Override
3536
public Map<String, String> refreshSignParameters(Map<String, String> parameters,
3637
ISigner signer, String accessKeyId, FormatType format) {
3738
Map<String, String> immutableMap = new HashMap<String, String>(parameters);
@@ -108,6 +109,7 @@ public static String replaceOccupiedParameters(String url, Map<String, String> p
108109
return result;
109110
}
110111

112+
@Override
111113
public String composeStringToSign(MethodType method, String uriPattern, ISigner signer,
112114
Map<String, String> queries, Map<String, String> headers,
113115
Map<String, String> paths) {

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/RpcSignatureComposer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private RpcSignatureComposer() {
3636

3737
}
3838

39+
@Override
3940
public Map<String, String> refreshSignParameters(Map<String, String> parameters,
4041
ISigner signer, String accessKeyId, FormatType format) {
4142
Map<String, String> immutableMap = new HashMap<String, String>(parameters);
@@ -44,10 +45,13 @@ public Map<String, String> refreshSignParameters(Map<String, String> parameters,
4445
immutableMap.put("SignatureVersion", signer.getSignerVersion());
4546
immutableMap.put("SignatureNonce", ParameterHelper.getUniqueNonce());
4647
immutableMap.put("AccessKeyId", accessKeyId);
47-
if (null != format) { immutableMap.put("Format", format.toString()); }
48+
if (null != format) {
49+
immutableMap.put("Format", format.toString());
50+
}
4851
return immutableMap;
4952
}
5053

54+
@Override
5155
public String composeStringToSign(MethodType method, String uriPattern,
5256
ISigner signer, Map<String, String> queries,
5357
Map<String, String> headers, Map<String, String> paths) {

aliyun-java-sdk-core/src/main/java/com/aliyuncs/auth/ShaHmac1.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class ShaHmac1 implements ISigner {
3131

3232
private final static String AGLORITHM_NAME = "HmacSHA1";
3333

34+
@Override
3435
public String signString(String source, String accessSecret)
3536
throws InvalidKeyException, IllegalStateException {
3637
try {
@@ -47,10 +48,12 @@ public String signString(String source, String accessSecret)
4748

4849
}
4950

51+
@Override
5052
public String getSignerName() {
5153
return "HMAC-SHA1";
5254
}
5355

56+
@Override
5457
public String getSignerVersion() {
5558
return "1.0";
5659
}

0 commit comments

Comments
 (0)