index
int64 | repo_id
string | file_path
string | content
string |
|---|---|---|---|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/GetSupplementInfoResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.GetSupplementInfoResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class GetSupplementInfoResponseUnmarshaller {
public static GetSupplementInfoResponse unmarshall(GetSupplementInfoResponse getSupplementInfoResponse, UnmarshallerContext _ctx) {
getSupplementInfoResponse.setRequestId(_ctx.stringValue("GetSupplementInfoResponse.RequestId"));
getSupplementInfoResponse.setSuccess(_ctx.booleanValue("GetSupplementInfoResponse.Success"));
getSupplementInfoResponse.setMessage(_ctx.stringValue("GetSupplementInfoResponse.Message"));
getSupplementInfoResponse.setBizId(_ctx.stringValue("GetSupplementInfoResponse.BizId"));
getSupplementInfoResponse.setSupplementId(_ctx.stringValue("GetSupplementInfoResponse.SupplementId"));
getSupplementInfoResponse.setSupplementType(_ctx.stringValue("GetSupplementInfoResponse.SupplementType"));
getSupplementInfoResponse.setSupplementReason(_ctx.stringValue("GetSupplementInfoResponse.SupplementReason"));
getSupplementInfoResponse.setReceiveTimestamp(_ctx.stringValue("GetSupplementInfoResponse.ReceiveTimestamp"));
getSupplementInfoResponse.setAdditionalReason(_ctx.stringValue("GetSupplementInfoResponse.AdditionalReason"));
getSupplementInfoResponse.setSupplementFields(_ctx.stringValue("GetSupplementInfoResponse.SupplementFields"));
return getSupplementInfoResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/GetTicketsInfoResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.GetTicketsInfoResponse;
import com.aliyuncs.copyright.model.v20190123.GetTicketsInfoResponse.Tickets;
import com.aliyuncs.transform.UnmarshallerContext;
public class GetTicketsInfoResponseUnmarshaller {
public static GetTicketsInfoResponse unmarshall(GetTicketsInfoResponse getTicketsInfoResponse, UnmarshallerContext _ctx) {
getTicketsInfoResponse.setRequestId(_ctx.stringValue("GetTicketsInfoResponse.RequestId"));
getTicketsInfoResponse.setSuccess(_ctx.booleanValue("GetTicketsInfoResponse.Success"));
List<Tickets> data = new ArrayList<Tickets>();
for (int i = 0; i < _ctx.lengthValue("GetTicketsInfoResponse.Data.Length"); i++) {
Tickets tickets = new Tickets();
tickets.setInvoiceUrl(_ctx.stringValue("GetTicketsInfoResponse.Data["+ i +"].InvoiceUrl"));
tickets.setRemark(_ctx.stringValue("GetTicketsInfoResponse.Data["+ i +"].Remark"));
tickets.setPatentNo(_ctx.longValue("GetTicketsInfoResponse.Data["+ i +"].PatentNo"));
tickets.setInvoiceYear(_ctx.integerValue("GetTicketsInfoResponse.Data["+ i +"].InvoiceYear"));
tickets.setFee(_ctx.stringValue("GetTicketsInfoResponse.Data["+ i +"].Fee"));
data.add(tickets);
}
getTicketsInfoResponse.setData(data);
return getTicketsInfoResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/GetUpdateSaleInfoResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.GetUpdateSaleInfoResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class GetUpdateSaleInfoResponseUnmarshaller {
public static GetUpdateSaleInfoResponse unmarshall(GetUpdateSaleInfoResponse getUpdateSaleInfoResponse, UnmarshallerContext _ctx) {
getUpdateSaleInfoResponse.setRequestId(_ctx.stringValue("GetUpdateSaleInfoResponse.RequestId"));
getUpdateSaleInfoResponse.setInstanceId(_ctx.stringValue("GetUpdateSaleInfoResponse.InstanceId"));
getUpdateSaleInfoResponse.setCommodityCode(_ctx.stringValue("GetUpdateSaleInfoResponse.CommodityCode"));
getUpdateSaleInfoResponse.setSuccess(_ctx.booleanValue("GetUpdateSaleInfoResponse.Success"));
List<String> skuList = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("GetUpdateSaleInfoResponse.SkuList.Length"); i++) {
skuList.add(_ctx.stringValue("GetUpdateSaleInfoResponse.SkuList["+ i +"]"));
}
getUpdateSaleInfoResponse.setSkuList(skuList);
return getUpdateSaleInfoResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/GetUpgradeWorkResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.GetUpgradeWorkResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class GetUpgradeWorkResponseUnmarshaller {
public static GetUpgradeWorkResponse unmarshall(GetUpgradeWorkResponse getUpgradeWorkResponse, UnmarshallerContext _ctx) {
getUpgradeWorkResponse.setRequestId(_ctx.stringValue("GetUpgradeWorkResponse.RequestId"));
getUpgradeWorkResponse.setModifiedTime(_ctx.longValue("GetUpgradeWorkResponse.ModifiedTime"));
getUpgradeWorkResponse.setNewSku(_ctx.stringValue("GetUpgradeWorkResponse.NewSku"));
getUpgradeWorkResponse.setSuccess(_ctx.booleanValue("GetUpgradeWorkResponse.Success"));
getUpgradeWorkResponse.setCreateTime(_ctx.longValue("GetUpgradeWorkResponse.CreateTime"));
getUpgradeWorkResponse.setWorkId(_ctx.longValue("GetUpgradeWorkResponse.WorkId"));
getUpgradeWorkResponse.setOldSku(_ctx.stringValue("GetUpgradeWorkResponse.OldSku"));
getUpgradeWorkResponse.setWorkStatus(_ctx.integerValue("GetUpgradeWorkResponse.WorkStatus"));
getUpgradeWorkResponse.setReason(_ctx.stringValue("GetUpgradeWorkResponse.Reason"));
return getUpgradeWorkResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/GetUserPatentStatisticsStatusResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.GetUserPatentStatisticsStatusResponse;
import com.aliyuncs.copyright.model.v20190123.GetUserPatentStatisticsStatusResponse.DataItem;
import com.aliyuncs.transform.UnmarshallerContext;
public class GetUserPatentStatisticsStatusResponseUnmarshaller {
public static GetUserPatentStatisticsStatusResponse unmarshall(GetUserPatentStatisticsStatusResponse getUserPatentStatisticsStatusResponse, UnmarshallerContext _ctx) {
getUserPatentStatisticsStatusResponse.setRequestId(_ctx.stringValue("GetUserPatentStatisticsStatusResponse.RequestId"));
getUserPatentStatisticsStatusResponse.setSuccess(_ctx.booleanValue("GetUserPatentStatisticsStatusResponse.Success"));
List<DataItem> data = new ArrayList<DataItem>();
for (int i = 0; i < _ctx.lengthValue("GetUserPatentStatisticsStatusResponse.Data.Length"); i++) {
DataItem dataItem = new DataItem();
dataItem.setStatus(_ctx.integerValue("GetUserPatentStatisticsStatusResponse.Data["+ i +"].Status"));
data.add(dataItem);
}
getUserPatentStatisticsStatusResponse.setData(data);
return getUserPatentStatisticsStatusResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/IdentifyDocInfoResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.IdentifyDocInfoResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class IdentifyDocInfoResponseUnmarshaller {
public static IdentifyDocInfoResponse unmarshall(IdentifyDocInfoResponse identifyDocInfoResponse, UnmarshallerContext _ctx) {
identifyDocInfoResponse.setRequestId(_ctx.stringValue("IdentifyDocInfoResponse.RequestId"));
identifyDocInfoResponse.setData(_ctx.stringValue("IdentifyDocInfoResponse.Data"));
identifyDocInfoResponse.setSuccess(_ctx.booleanValue("IdentifyDocInfoResponse.Success"));
return identifyDocInfoResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/ListItemsResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.ListItemsResponse;
import com.aliyuncs.copyright.model.v20190123.ListItemsResponse.Module;
import com.aliyuncs.copyright.model.v20190123.ListItemsResponse.Module.Item;
import com.aliyuncs.transform.UnmarshallerContext;
public class ListItemsResponseUnmarshaller {
public static ListItemsResponse unmarshall(ListItemsResponse listItemsResponse, UnmarshallerContext _ctx) {
listItemsResponse.setRequestId(_ctx.stringValue("ListItemsResponse.RequestId"));
listItemsResponse.setHttpStatusCode(_ctx.integerValue("ListItemsResponse.HttpStatusCode"));
listItemsResponse.setDynamicCode(_ctx.stringValue("ListItemsResponse.DynamicCode"));
listItemsResponse.setDynamicMessage(_ctx.stringValue("ListItemsResponse.DynamicMessage"));
listItemsResponse.setErrorMsg(_ctx.stringValue("ListItemsResponse.ErrorMsg"));
listItemsResponse.setErrorCode(_ctx.stringValue("ListItemsResponse.ErrorCode"));
listItemsResponse.setSuccess(_ctx.booleanValue("ListItemsResponse.Success"));
listItemsResponse.setAllowRetry(_ctx.booleanValue("ListItemsResponse.AllowRetry"));
listItemsResponse.setAppName(_ctx.stringValue("ListItemsResponse.AppName"));
List<String> errorArgs = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("ListItemsResponse.ErrorArgs.Length"); i++) {
errorArgs.add(_ctx.stringValue("ListItemsResponse.ErrorArgs["+ i +"]"));
}
listItemsResponse.setErrorArgs(errorArgs);
Module module = new Module();
module.setTotalNum(_ctx.integerValue("ListItemsResponse.Module.TotalNum"));
List<Item> items = new ArrayList<Item>();
for (int i = 0; i < _ctx.lengthValue("ListItemsResponse.Module.Items.Length"); i++) {
Item item = new Item();
item.setItemId(_ctx.integerValue("ListItemsResponse.Module.Items["+ i +"].ItemId"));
item.setTitle(_ctx.stringValue("ListItemsResponse.Module.Items["+ i +"].Title"));
item.setPicUrl(_ctx.stringValue("ListItemsResponse.Module.Items["+ i +"].PicUrl"));
item.setDescription(_ctx.stringValue("ListItemsResponse.Module.Items["+ i +"].Description"));
item.setLeftNum(_ctx.integerValue("ListItemsResponse.Module.Items["+ i +"].LeftNum"));
item.setTotalNum(_ctx.integerValue("ListItemsResponse.Module.Items["+ i +"].TotalNum"));
items.add(item);
}
module.setItems(items);
listItemsResponse.setModule(module);
return listItemsResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/ListPatentContactResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.ListPatentContactResponse;
import com.aliyuncs.copyright.model.v20190123.ListPatentContactResponse.Produces;
import com.aliyuncs.transform.UnmarshallerContext;
public class ListPatentContactResponseUnmarshaller {
public static ListPatentContactResponse unmarshall(ListPatentContactResponse listPatentContactResponse, UnmarshallerContext _ctx) {
listPatentContactResponse.setRequestId(_ctx.stringValue("ListPatentContactResponse.RequestId"));
listPatentContactResponse.setPageNum(_ctx.integerValue("ListPatentContactResponse.PageNum"));
listPatentContactResponse.setSuccess(_ctx.booleanValue("ListPatentContactResponse.Success"));
listPatentContactResponse.setTotalItemNum(_ctx.integerValue("ListPatentContactResponse.TotalItemNum"));
listPatentContactResponse.setPageSize(_ctx.integerValue("ListPatentContactResponse.PageSize"));
listPatentContactResponse.setTotalPageNum(_ctx.integerValue("ListPatentContactResponse.TotalPageNum"));
List<Produces> data = new ArrayList<Produces>();
for (int i = 0; i < _ctx.lengthValue("ListPatentContactResponse.Data.Length"); i++) {
Produces produces = new Produces();
produces.setEmail(_ctx.stringValue("ListPatentContactResponse.Data["+ i +"].Email"));
produces.setName(_ctx.stringValue("ListPatentContactResponse.Data["+ i +"].Name"));
produces.setMobile(_ctx.stringValue("ListPatentContactResponse.Data["+ i +"].Mobile"));
produces.setId(_ctx.longValue("ListPatentContactResponse.Data["+ i +"].Id"));
data.add(produces);
}
listPatentContactResponse.setData(data);
return listPatentContactResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/ListPatentUserSearchCompanyResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.ListPatentUserSearchCompanyResponse;
import com.aliyuncs.copyright.model.v20190123.ListPatentUserSearchCompanyResponse.Produces;
import com.aliyuncs.transform.UnmarshallerContext;
public class ListPatentUserSearchCompanyResponseUnmarshaller {
public static ListPatentUserSearchCompanyResponse unmarshall(ListPatentUserSearchCompanyResponse listPatentUserSearchCompanyResponse, UnmarshallerContext _ctx) {
listPatentUserSearchCompanyResponse.setRequestId(_ctx.stringValue("ListPatentUserSearchCompanyResponse.RequestId"));
listPatentUserSearchCompanyResponse.setSuccess(_ctx.booleanValue("ListPatentUserSearchCompanyResponse.Success"));
List<Produces> data = new ArrayList<Produces>();
for (int i = 0; i < _ctx.lengthValue("ListPatentUserSearchCompanyResponse.Data.Length"); i++) {
Produces produces = new Produces();
produces.setType(_ctx.integerValue("ListPatentUserSearchCompanyResponse.Data["+ i +"].Type"));
produces.setEnterpriseName(_ctx.stringValue("ListPatentUserSearchCompanyResponse.Data["+ i +"].EnterpriseName"));
produces.setId(_ctx.longValue("ListPatentUserSearchCompanyResponse.Data["+ i +"].Id"));
data.add(produces);
}
listPatentUserSearchCompanyResponse.setData(data);
return listPatentUserSearchCompanyResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/ListUserHistoryProducesResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.ListUserHistoryProducesResponse;
import com.aliyuncs.copyright.model.v20190123.ListUserHistoryProducesResponse.Produces;
import com.aliyuncs.transform.UnmarshallerContext;
public class ListUserHistoryProducesResponseUnmarshaller {
public static ListUserHistoryProducesResponse unmarshall(ListUserHistoryProducesResponse listUserHistoryProducesResponse, UnmarshallerContext _ctx) {
listUserHistoryProducesResponse.setRequestId(_ctx.stringValue("ListUserHistoryProducesResponse.RequestId"));
listUserHistoryProducesResponse.setPageNum(_ctx.integerValue("ListUserHistoryProducesResponse.PageNum"));
listUserHistoryProducesResponse.setSuccess(_ctx.booleanValue("ListUserHistoryProducesResponse.Success"));
listUserHistoryProducesResponse.setTotalItemNum(_ctx.integerValue("ListUserHistoryProducesResponse.TotalItemNum"));
listUserHistoryProducesResponse.setPageSize(_ctx.integerValue("ListUserHistoryProducesResponse.PageSize"));
listUserHistoryProducesResponse.setTotalPageNum(_ctx.integerValue("ListUserHistoryProducesResponse.TotalPageNum"));
List<Produces> data = new ArrayList<Produces>();
for (int i = 0; i < _ctx.lengthValue("ListUserHistoryProducesResponse.Data.Length"); i++) {
Produces produces = new Produces();
produces.setSerialNumber(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].SerialNumber"));
produces.setStatus(_ctx.integerValue("ListUserHistoryProducesResponse.Data["+ i +"].Status"));
produces.setOrderPrice(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].OrderPrice"));
produces.setSolutionBizId(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].SolutionBizId"));
produces.setUserId(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].UserId"));
produces.setBizId(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].BizId"));
produces.setOrderTime(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].OrderTime"));
produces.setPartnerCode(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].PartnerCode"));
produces.setExtInfo(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].ExtInfo"));
produces.setBizType(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].BizType"));
produces.setIntentionBizId(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].IntentionBizId"));
produces.setOldOrder(_ctx.booleanValue("ListUserHistoryProducesResponse.Data["+ i +"].OldOrder"));
produces.setOrderId(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].OrderId"));
produces.setModifyTime(_ctx.stringValue("ListUserHistoryProducesResponse.Data["+ i +"].ModifyTime"));
data.add(produces);
}
listUserHistoryProducesResponse.setData(data);
return listUserHistoryProducesResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/ListUserProduceOperateLogsResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.ListUserProduceOperateLogsResponse;
import com.aliyuncs.copyright.model.v20190123.ListUserProduceOperateLogsResponse.OpateLogs;
import com.aliyuncs.transform.UnmarshallerContext;
public class ListUserProduceOperateLogsResponseUnmarshaller {
public static ListUserProduceOperateLogsResponse unmarshall(ListUserProduceOperateLogsResponse listUserProduceOperateLogsResponse, UnmarshallerContext _ctx) {
listUserProduceOperateLogsResponse.setRequestId(_ctx.stringValue("ListUserProduceOperateLogsResponse.RequestId"));
listUserProduceOperateLogsResponse.setPageNum(_ctx.integerValue("ListUserProduceOperateLogsResponse.PageNum"));
listUserProduceOperateLogsResponse.setSuccess(_ctx.booleanValue("ListUserProduceOperateLogsResponse.Success"));
listUserProduceOperateLogsResponse.setTotalItemNum(_ctx.integerValue("ListUserProduceOperateLogsResponse.TotalItemNum"));
listUserProduceOperateLogsResponse.setPageSize(_ctx.integerValue("ListUserProduceOperateLogsResponse.PageSize"));
listUserProduceOperateLogsResponse.setTotalPageNum(_ctx.integerValue("ListUserProduceOperateLogsResponse.TotalPageNum"));
List<OpateLogs> data = new ArrayList<OpateLogs>();
for (int i = 0; i < _ctx.lengthValue("ListUserProduceOperateLogsResponse.Data.Length"); i++) {
OpateLogs opateLogs = new OpateLogs();
opateLogs.setOperateTime(_ctx.longValue("ListUserProduceOperateLogsResponse.Data["+ i +"].OperateTime"));
opateLogs.setOperateUserType(_ctx.stringValue("ListUserProduceOperateLogsResponse.Data["+ i +"].OperateUserType"));
opateLogs.setBizId(_ctx.stringValue("ListUserProduceOperateLogsResponse.Data["+ i +"].BizId"));
opateLogs.setNote(_ctx.stringValue("ListUserProduceOperateLogsResponse.Data["+ i +"].Note"));
opateLogs.setOperateName(_ctx.stringValue("ListUserProduceOperateLogsResponse.Data["+ i +"].OperateName"));
opateLogs.setBizStatus(_ctx.integerValue("ListUserProduceOperateLogsResponse.Data["+ i +"].BizStatus"));
opateLogs.setToBizStatus(_ctx.integerValue("ListUserProduceOperateLogsResponse.Data["+ i +"].ToBizStatus"));
opateLogs.setBizType(_ctx.stringValue("ListUserProduceOperateLogsResponse.Data["+ i +"].BizType"));
data.add(opateLogs);
}
listUserProduceOperateLogsResponse.setData(data);
return listUserProduceOperateLogsResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/ListUserProducesResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.ListUserProducesResponse;
import com.aliyuncs.copyright.model.v20190123.ListUserProducesResponse.Produces;
import com.aliyuncs.transform.UnmarshallerContext;
public class ListUserProducesResponseUnmarshaller {
public static ListUserProducesResponse unmarshall(ListUserProducesResponse listUserProducesResponse, UnmarshallerContext _ctx) {
listUserProducesResponse.setRequestId(_ctx.stringValue("ListUserProducesResponse.RequestId"));
listUserProducesResponse.setPageNum(_ctx.integerValue("ListUserProducesResponse.PageNum"));
listUserProducesResponse.setSuccess(_ctx.booleanValue("ListUserProducesResponse.Success"));
listUserProducesResponse.setTotalItemNum(_ctx.integerValue("ListUserProducesResponse.TotalItemNum"));
listUserProducesResponse.setPageSize(_ctx.integerValue("ListUserProducesResponse.PageSize"));
listUserProducesResponse.setTotalPageNum(_ctx.integerValue("ListUserProducesResponse.TotalPageNum"));
List<Produces> data = new ArrayList<Produces>();
for (int i = 0; i < _ctx.lengthValue("ListUserProducesResponse.Data.Length"); i++) {
Produces produces = new Produces();
produces.setStatus(_ctx.integerValue("ListUserProducesResponse.Data["+ i +"].Status"));
produces.setOrderPrice(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].OrderPrice"));
produces.setSolutionBizId(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].SolutionBizId"));
produces.setUserId(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].UserId"));
produces.setBizId(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].BizId"));
produces.setOrderTime(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].OrderTime"));
produces.setPartnerCode(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].PartnerCode"));
produces.setExtInfo(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].ExtInfo"));
produces.setBizType(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].BizType"));
produces.setIntentionBizId(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].IntentionBizId"));
produces.setEndTime(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].EndTime"));
produces.setStartTime(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].StartTime"));
produces.setOrderId(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].OrderId"));
produces.setModifyTime(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].ModifyTime"));
produces.setOrderInstanceId(_ctx.stringValue("ListUserProducesResponse.Data["+ i +"].OrderInstanceId"));
data.add(produces);
}
listUserProducesResponse.setData(data);
return listUserProducesResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/OpenPatentStatisticsResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.OpenPatentStatisticsResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class OpenPatentStatisticsResponseUnmarshaller {
public static OpenPatentStatisticsResponse unmarshall(OpenPatentStatisticsResponse openPatentStatisticsResponse, UnmarshallerContext _ctx) {
openPatentStatisticsResponse.setRequestId(_ctx.stringValue("OpenPatentStatisticsResponse.RequestId"));
openPatentStatisticsResponse.setSuccess(_ctx.booleanValue("OpenPatentStatisticsResponse.Success"));
return openPatentStatisticsResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/OperateFeeOrderResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.OperateFeeOrderResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class OperateFeeOrderResponseUnmarshaller {
public static OperateFeeOrderResponse unmarshall(OperateFeeOrderResponse operateFeeOrderResponse, UnmarshallerContext _ctx) {
operateFeeOrderResponse.setRequestId(_ctx.stringValue("OperateFeeOrderResponse.RequestId"));
operateFeeOrderResponse.setSuccess(_ctx.booleanValue("OperateFeeOrderResponse.Success"));
return operateFeeOrderResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/OperateProduceForPartnerResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.OperateProduceForPartnerResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class OperateProduceForPartnerResponseUnmarshaller {
public static OperateProduceForPartnerResponse unmarshall(OperateProduceForPartnerResponse operateProduceForPartnerResponse, UnmarshallerContext _ctx) {
operateProduceForPartnerResponse.setRequestId(_ctx.stringValue("OperateProduceForPartnerResponse.RequestId"));
operateProduceForPartnerResponse.setErrorMsg(_ctx.stringValue("OperateProduceForPartnerResponse.ErrorMsg"));
operateProduceForPartnerResponse.setSuccess(_ctx.booleanValue("OperateProduceForPartnerResponse.Success"));
operateProduceForPartnerResponse.setErrorCode(_ctx.stringValue("OperateProduceForPartnerResponse.ErrorCode"));
return operateProduceForPartnerResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/OperateProduceForUserResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.OperateProduceForUserResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class OperateProduceForUserResponseUnmarshaller {
public static OperateProduceForUserResponse unmarshall(OperateProduceForUserResponse operateProduceForUserResponse, UnmarshallerContext _ctx) {
operateProduceForUserResponse.setRequestId(_ctx.stringValue("OperateProduceForUserResponse.RequestId"));
operateProduceForUserResponse.setErrorMsg(_ctx.stringValue("OperateProduceForUserResponse.ErrorMsg"));
operateProduceForUserResponse.setSuccess(_ctx.booleanValue("OperateProduceForUserResponse.Success"));
operateProduceForUserResponse.setErrorCode(_ctx.stringValue("OperateProduceForUserResponse.ErrorCode"));
return operateProduceForUserResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/PatentInfoCallBackResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.PatentInfoCallBackResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class PatentInfoCallBackResponseUnmarshaller {
public static PatentInfoCallBackResponse unmarshall(PatentInfoCallBackResponse patentInfoCallBackResponse, UnmarshallerContext _ctx) {
patentInfoCallBackResponse.setRequestId(_ctx.stringValue("PatentInfoCallBackResponse.RequestId"));
patentInfoCallBackResponse.setSuccess(_ctx.booleanValue("PatentInfoCallBackResponse.Success"));
return patentInfoCallBackResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/QueryDataFromTairResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.QueryDataFromTairResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class QueryDataFromTairResponseUnmarshaller {
public static QueryDataFromTairResponse unmarshall(QueryDataFromTairResponse queryDataFromTairResponse, UnmarshallerContext _ctx) {
queryDataFromTairResponse.setRequestId(_ctx.stringValue("QueryDataFromTairResponse.RequestId"));
queryDataFromTairResponse.setSuccess(_ctx.booleanValue("QueryDataFromTairResponse.Success"));
queryDataFromTairResponse.setMessage(_ctx.stringValue("QueryDataFromTairResponse.Message"));
queryDataFromTairResponse.setModule(_ctx.stringValue("QueryDataFromTairResponse.Module"));
return queryDataFromTairResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/QueryPatentAppearanceCacheResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.QueryPatentAppearanceCacheResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class QueryPatentAppearanceCacheResponseUnmarshaller {
public static QueryPatentAppearanceCacheResponse unmarshall(QueryPatentAppearanceCacheResponse queryPatentAppearanceCacheResponse, UnmarshallerContext _ctx) {
queryPatentAppearanceCacheResponse.setRequestId(_ctx.stringValue("QueryPatentAppearanceCacheResponse.RequestId"));
queryPatentAppearanceCacheResponse.setSuccess(_ctx.booleanValue("QueryPatentAppearanceCacheResponse.Success"));
queryPatentAppearanceCacheResponse.setMessage(_ctx.stringValue("QueryPatentAppearanceCacheResponse.Message"));
queryPatentAppearanceCacheResponse.setBizType(_ctx.stringValue("QueryPatentAppearanceCacheResponse.BizType"));
queryPatentAppearanceCacheResponse.setData(_ctx.stringValue("QueryPatentAppearanceCacheResponse.Data"));
return queryPatentAppearanceCacheResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/QueryPatentServiceStatusResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.QueryPatentServiceStatusResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class QueryPatentServiceStatusResponseUnmarshaller {
public static QueryPatentServiceStatusResponse unmarshall(QueryPatentServiceStatusResponse queryPatentServiceStatusResponse, UnmarshallerContext _ctx) {
queryPatentServiceStatusResponse.setRequestId(_ctx.stringValue("QueryPatentServiceStatusResponse.RequestId"));
queryPatentServiceStatusResponse.setSuccess(_ctx.booleanValue("QueryPatentServiceStatusResponse.Success"));
queryPatentServiceStatusResponse.setStatus(_ctx.stringValue("QueryPatentServiceStatusResponse.Status"));
queryPatentServiceStatusResponse.setMessage(_ctx.stringValue("QueryPatentServiceStatusResponse.Message"));
return queryPatentServiceStatusResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/QuerySupplementInfoListResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.QuerySupplementInfoListResponse;
import com.aliyuncs.copyright.model.v20190123.QuerySupplementInfoListResponse.DataItem;
import com.aliyuncs.transform.UnmarshallerContext;
public class QuerySupplementInfoListResponseUnmarshaller {
public static QuerySupplementInfoListResponse unmarshall(QuerySupplementInfoListResponse querySupplementInfoListResponse, UnmarshallerContext _ctx) {
querySupplementInfoListResponse.setRequestId(_ctx.stringValue("QuerySupplementInfoListResponse.RequestId"));
querySupplementInfoListResponse.setSuccess(_ctx.booleanValue("QuerySupplementInfoListResponse.Success"));
querySupplementInfoListResponse.setMessage(_ctx.stringValue("QuerySupplementInfoListResponse.Message"));
List<DataItem> data = new ArrayList<DataItem>();
for (int i = 0; i < _ctx.lengthValue("QuerySupplementInfoListResponse.Data.Length"); i++) {
DataItem dataItem = new DataItem();
dataItem.setBizId(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].BizId"));
dataItem.setSupplementId(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].SupplementId"));
dataItem.setSupplementReason(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].SupplementReason"));
dataItem.setReceiveTimestamp(_ctx.longValue("QuerySupplementInfoListResponse.Data["+ i +"].ReceiveTimestamp"));
dataItem.setSupplementFields(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].SupplementFields"));
dataItem.setSupplementType(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].SupplementType"));
dataItem.setSupplementFileUrl(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].SupplementFileUrl"));
dataItem.setAdditionalReason(_ctx.stringValue("QuerySupplementInfoListResponse.Data["+ i +"].AdditionalReason"));
data.add(dataItem);
}
querySupplementInfoListResponse.setData(data);
return querySupplementInfoListResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/RecognizeGeneralTextResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.RecognizeGeneralTextResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class RecognizeGeneralTextResponseUnmarshaller {
public static RecognizeGeneralTextResponse unmarshall(RecognizeGeneralTextResponse recognizeGeneralTextResponse, UnmarshallerContext _ctx) {
recognizeGeneralTextResponse.setRequestId(_ctx.stringValue("RecognizeGeneralTextResponse.RequestId"));
recognizeGeneralTextResponse.setSuccess(_ctx.booleanValue("RecognizeGeneralTextResponse.Success"));
recognizeGeneralTextResponse.setData(_ctx.stringValue("RecognizeGeneralTextResponse.Data"));
return recognizeGeneralTextResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/RegisterNumberCheckResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.RegisterNumberCheckResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class RegisterNumberCheckResponseUnmarshaller {
public static RegisterNumberCheckResponse unmarshall(RegisterNumberCheckResponse registerNumberCheckResponse, UnmarshallerContext _ctx) {
registerNumberCheckResponse.setRequestId(_ctx.stringValue("RegisterNumberCheckResponse.RequestId"));
registerNumberCheckResponse.setSuccess(_ctx.booleanValue("RegisterNumberCheckResponse.Success"));
registerNumberCheckResponse.setMessage(_ctx.stringValue("RegisterNumberCheckResponse.Message"));
registerNumberCheckResponse.setR11Registered(_ctx.booleanValue("RegisterNumberCheckResponse.R11Registered"));
registerNumberCheckResponse.setR41RegisterNumber(_ctx.stringValue("RegisterNumberCheckResponse.R41RegisterNumber"));
registerNumberCheckResponse.setCompleteDate(_ctx.longValue("RegisterNumberCheckResponse.CompleteDate"));
registerNumberCheckResponse.setFirstAppearDate(_ctx.longValue("RegisterNumberCheckResponse.FirstAppearDate"));
registerNumberCheckResponse.setPublishStatus(_ctx.stringValue("RegisterNumberCheckResponse.PublishStatus"));
registerNumberCheckResponse.setSoftwareFullName(_ctx.stringValue("RegisterNumberCheckResponse.SoftwareFullName"));
registerNumberCheckResponse.setSoftwareShortName(_ctx.stringValue("RegisterNumberCheckResponse.SoftwareShortName"));
registerNumberCheckResponse.setVersion(_ctx.stringValue("RegisterNumberCheckResponse.Version"));
return registerNumberCheckResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SaveCopyrightPersonResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.SaveCopyrightPersonResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class SaveCopyrightPersonResponseUnmarshaller {
public static SaveCopyrightPersonResponse unmarshall(SaveCopyrightPersonResponse saveCopyrightPersonResponse, UnmarshallerContext _ctx) {
saveCopyrightPersonResponse.setRequestId(_ctx.stringValue("SaveCopyrightPersonResponse.RequestId"));
saveCopyrightPersonResponse.setPersonId(_ctx.longValue("SaveCopyrightPersonResponse.PersonId"));
saveCopyrightPersonResponse.setSuccess(_ctx.booleanValue("SaveCopyrightPersonResponse.Success"));
return saveCopyrightPersonResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SaveOrUpdatePatentAppearanceCacheResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.SaveOrUpdatePatentAppearanceCacheResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class SaveOrUpdatePatentAppearanceCacheResponseUnmarshaller {
public static SaveOrUpdatePatentAppearanceCacheResponse unmarshall(SaveOrUpdatePatentAppearanceCacheResponse saveOrUpdatePatentAppearanceCacheResponse, UnmarshallerContext _ctx) {
saveOrUpdatePatentAppearanceCacheResponse.setRequestId(_ctx.stringValue("SaveOrUpdatePatentAppearanceCacheResponse.RequestId"));
saveOrUpdatePatentAppearanceCacheResponse.setSuccess(_ctx.booleanValue("SaveOrUpdatePatentAppearanceCacheResponse.Success"));
saveOrUpdatePatentAppearanceCacheResponse.setMessage(_ctx.stringValue("SaveOrUpdatePatentAppearanceCacheResponse.Message"));
saveOrUpdatePatentAppearanceCacheResponse.setBizType(_ctx.stringValue("SaveOrUpdatePatentAppearanceCacheResponse.BizType"));
saveOrUpdatePatentAppearanceCacheResponse.setData(_ctx.stringValue("SaveOrUpdatePatentAppearanceCacheResponse.Data"));
return saveOrUpdatePatentAppearanceCacheResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SaveOrUpdatePatentPlanResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.SaveOrUpdatePatentPlanResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class SaveOrUpdatePatentPlanResponseUnmarshaller {
public static SaveOrUpdatePatentPlanResponse unmarshall(SaveOrUpdatePatentPlanResponse saveOrUpdatePatentPlanResponse, UnmarshallerContext _ctx) {
saveOrUpdatePatentPlanResponse.setRequestId(_ctx.stringValue("SaveOrUpdatePatentPlanResponse.RequestId"));
List<String> id = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("SaveOrUpdatePatentPlanResponse.Id.Length"); i++) {
id.add(_ctx.stringValue("SaveOrUpdatePatentPlanResponse.Id["+ i +"]"));
}
saveOrUpdatePatentPlanResponse.setId(id);
return saveOrUpdatePatentPlanResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SaveOrUpdateUserSearchCompanyResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.SaveOrUpdateUserSearchCompanyResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class SaveOrUpdateUserSearchCompanyResponseUnmarshaller {
public static SaveOrUpdateUserSearchCompanyResponse unmarshall(SaveOrUpdateUserSearchCompanyResponse saveOrUpdateUserSearchCompanyResponse, UnmarshallerContext _ctx) {
saveOrUpdateUserSearchCompanyResponse.setRequestId(_ctx.stringValue("SaveOrUpdateUserSearchCompanyResponse.RequestId"));
saveOrUpdateUserSearchCompanyResponse.setId(_ctx.longValue("SaveOrUpdateUserSearchCompanyResponse.Id"));
return saveOrUpdateUserSearchCompanyResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SavePatentContactResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.SavePatentContactResponse;
import com.aliyuncs.copyright.model.v20190123.SavePatentContactResponse.Produces;
import com.aliyuncs.transform.UnmarshallerContext;
public class SavePatentContactResponseUnmarshaller {
public static SavePatentContactResponse unmarshall(SavePatentContactResponse savePatentContactResponse, UnmarshallerContext _ctx) {
savePatentContactResponse.setRequestId(_ctx.stringValue("SavePatentContactResponse.RequestId"));
savePatentContactResponse.setPageNum(_ctx.integerValue("SavePatentContactResponse.PageNum"));
savePatentContactResponse.setSuccess(_ctx.booleanValue("SavePatentContactResponse.Success"));
savePatentContactResponse.setTotalItemNum(_ctx.integerValue("SavePatentContactResponse.TotalItemNum"));
savePatentContactResponse.setPageSize(_ctx.integerValue("SavePatentContactResponse.PageSize"));
savePatentContactResponse.setTotalPageNum(_ctx.integerValue("SavePatentContactResponse.TotalPageNum"));
List<Produces> data = new ArrayList<Produces>();
for (int i = 0; i < _ctx.lengthValue("SavePatentContactResponse.Data.Length"); i++) {
Produces produces = new Produces();
produces.setEmail(_ctx.stringValue("SavePatentContactResponse.Data["+ i +"].Email"));
produces.setName(_ctx.stringValue("SavePatentContactResponse.Data["+ i +"].Name"));
produces.setMobile(_ctx.stringValue("SavePatentContactResponse.Data["+ i +"].Mobile"));
produces.setId(_ctx.longValue("SavePatentContactResponse.Data["+ i +"].Id"));
data.add(produces);
}
savePatentContactResponse.setData(data);
return savePatentContactResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SavePatentMonitorTaskResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.SavePatentMonitorTaskResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class SavePatentMonitorTaskResponseUnmarshaller {
public static SavePatentMonitorTaskResponse unmarshall(SavePatentMonitorTaskResponse savePatentMonitorTaskResponse, UnmarshallerContext _ctx) {
savePatentMonitorTaskResponse.setRequestId(_ctx.stringValue("SavePatentMonitorTaskResponse.RequestId"));
savePatentMonitorTaskResponse.setErrorMsg(_ctx.booleanValue("SavePatentMonitorTaskResponse.ErrorMsg"));
savePatentMonitorTaskResponse.setMessage(_ctx.stringValue("SavePatentMonitorTaskResponse.Message"));
savePatentMonitorTaskResponse.setTaskId(_ctx.stringValue("SavePatentMonitorTaskResponse.TaskId"));
savePatentMonitorTaskResponse.setErrorCode(_ctx.stringValue("SavePatentMonitorTaskResponse.ErrorCode"));
return savePatentMonitorTaskResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SavePatentRecycleResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.SavePatentRecycleResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class SavePatentRecycleResponseUnmarshaller {
public static SavePatentRecycleResponse unmarshall(SavePatentRecycleResponse savePatentRecycleResponse, UnmarshallerContext _ctx) {
savePatentRecycleResponse.setRequestId(_ctx.stringValue("SavePatentRecycleResponse.RequestId"));
List<String> id = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("SavePatentRecycleResponse.Id.Length"); i++) {
id.add(_ctx.stringValue("SavePatentRecycleResponse.Id["+ i +"]"));
}
savePatentRecycleResponse.setId(id);
return savePatentRecycleResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/SaveTransferItemResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.SaveTransferItemResponse;
import com.aliyuncs.copyright.model.v20190123.SaveTransferItemResponse.Module;
import com.aliyuncs.transform.UnmarshallerContext;
public class SaveTransferItemResponseUnmarshaller {
public static SaveTransferItemResponse unmarshall(SaveTransferItemResponse saveTransferItemResponse, UnmarshallerContext _ctx) {
saveTransferItemResponse.setRequestId(_ctx.stringValue("SaveTransferItemResponse.RequestId"));
saveTransferItemResponse.setHttpStatusCode(_ctx.integerValue("SaveTransferItemResponse.HttpStatusCode"));
saveTransferItemResponse.setDynamicCode(_ctx.stringValue("SaveTransferItemResponse.DynamicCode"));
saveTransferItemResponse.setDynamicMessage(_ctx.stringValue("SaveTransferItemResponse.DynamicMessage"));
saveTransferItemResponse.setErrorMsg(_ctx.stringValue("SaveTransferItemResponse.ErrorMsg"));
saveTransferItemResponse.setErrorCode(_ctx.stringValue("SaveTransferItemResponse.ErrorCode"));
saveTransferItemResponse.setSuccess(_ctx.booleanValue("SaveTransferItemResponse.Success"));
saveTransferItemResponse.setAllowRetry(_ctx.booleanValue("SaveTransferItemResponse.AllowRetry"));
saveTransferItemResponse.setAppName(_ctx.stringValue("SaveTransferItemResponse.AppName"));
List<String> errorArgs = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("SaveTransferItemResponse.ErrorArgs.Length"); i++) {
errorArgs.add(_ctx.stringValue("SaveTransferItemResponse.ErrorArgs["+ i +"]"));
}
saveTransferItemResponse.setErrorArgs(errorArgs);
Module module = new Module();
module.setStockId(_ctx.integerValue("SaveTransferItemResponse.Module.StockId"));
module.setTransactionId(_ctx.stringValue("SaveTransferItemResponse.Module.TransactionId"));
module.setTranHash(_ctx.stringValue("SaveTransferItemResponse.Module.TranHash"));
module.setItemId(_ctx.integerValue("SaveTransferItemResponse.Module.ItemId"));
module.setUserId(_ctx.integerValue("SaveTransferItemResponse.Module.UserId"));
module.setNo(_ctx.stringValue("SaveTransferItemResponse.Module.No"));
module.setAddress(_ctx.stringValue("SaveTransferItemResponse.Module.Address"));
module.setShardId(_ctx.longValue("SaveTransferItemResponse.Module.ShardId"));
module.setShardKey(_ctx.stringValue("SaveTransferItemResponse.Module.ShardKey"));
saveTransferItemResponse.setModule(module);
return saveTransferItemResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/UpdateSupplementFileResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.UpdateSupplementFileResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class UpdateSupplementFileResponseUnmarshaller {
public static UpdateSupplementFileResponse unmarshall(UpdateSupplementFileResponse updateSupplementFileResponse, UnmarshallerContext _ctx) {
updateSupplementFileResponse.setRequestId(_ctx.stringValue("UpdateSupplementFileResponse.RequestId"));
updateSupplementFileResponse.setSuccess(_ctx.booleanValue("UpdateSupplementFileResponse.Success"));
updateSupplementFileResponse.setMessage(_ctx.stringValue("UpdateSupplementFileResponse.Message"));
return updateSupplementFileResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/UserBindResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import java.util.ArrayList;
import java.util.List;
import com.aliyuncs.copyright.model.v20190123.UserBindResponse;
import com.aliyuncs.copyright.model.v20190123.UserBindResponse.Module;
import com.aliyuncs.transform.UnmarshallerContext;
public class UserBindResponseUnmarshaller {
public static UserBindResponse unmarshall(UserBindResponse userBindResponse, UnmarshallerContext _ctx) {
userBindResponse.setRequestId(_ctx.stringValue("UserBindResponse.RequestId"));
userBindResponse.setHttpStatusCode(_ctx.integerValue("UserBindResponse.HttpStatusCode"));
userBindResponse.setDynamicCode(_ctx.stringValue("UserBindResponse.DynamicCode"));
userBindResponse.setDynamicMessage(_ctx.stringValue("UserBindResponse.DynamicMessage"));
userBindResponse.setErrorMsg(_ctx.stringValue("UserBindResponse.ErrorMsg"));
userBindResponse.setErrorCode(_ctx.stringValue("UserBindResponse.ErrorCode"));
userBindResponse.setSuccess(_ctx.booleanValue("UserBindResponse.Success"));
userBindResponse.setAllowRetry(_ctx.booleanValue("UserBindResponse.AllowRetry"));
userBindResponse.setAppName(_ctx.stringValue("UserBindResponse.AppName"));
List<String> errorArgs = new ArrayList<String>();
for (int i = 0; i < _ctx.lengthValue("UserBindResponse.ErrorArgs.Length"); i++) {
errorArgs.add(_ctx.stringValue("UserBindResponse.ErrorArgs["+ i +"]"));
}
userBindResponse.setErrorArgs(errorArgs);
Module module = new Module();
module.setChainUserId(_ctx.stringValue("UserBindResponse.Module.ChainUserId"));
userBindResponse.setModule(module);
return userBindResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform
|
java-sources/com/aliyun/aliyun-java-sdk-copyright/1.0.13/com/aliyuncs/copyright/transform/v20190123/VerifyOwnerInfoResponseUnmarshaller.java
|
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.copyright.transform.v20190123;
import com.aliyuncs.copyright.model.v20190123.VerifyOwnerInfoResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class VerifyOwnerInfoResponseUnmarshaller {
public static VerifyOwnerInfoResponse unmarshall(VerifyOwnerInfoResponse verifyOwnerInfoResponse, UnmarshallerContext _ctx) {
verifyOwnerInfoResponse.setRequestId(_ctx.stringValue("VerifyOwnerInfoResponse.RequestId"));
verifyOwnerInfoResponse.setBirthDate(_ctx.stringValue("VerifyOwnerInfoResponse.BirthDate"));
verifyOwnerInfoResponse.setSuccess(_ctx.booleanValue("VerifyOwnerInfoResponse.Success"));
verifyOwnerInfoResponse.setMessage(_ctx.stringValue("VerifyOwnerInfoResponse.Message"));
verifyOwnerInfoResponse.setVerifyResult(_ctx.booleanValue("VerifyOwnerInfoResponse.VerifyResult"));
verifyOwnerInfoResponse.setPhone(_ctx.stringValue("VerifyOwnerInfoResponse.Phone"));
return verifyOwnerInfoResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/AcsError.java
|
package com.aliyuncs;
import com.aliyuncs.transform.UnmarshallerContext;
import java.util.Map;
public class AcsError extends AcsResponse {
private int statusCode;
private String errorCode;
private String errorMessage;
private String requestId;
private String errorDescription;
private Map<String, Object> accessDeniedDetail;
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public String getErrorDescription() {
return errorDescription;
}
public void setErrorDescription(String errorDescription) {
this.errorDescription = errorDescription;
}
@Override
public AcsError getInstance(UnmarshallerContext context) {
return AcsErrorUnmarshaller.unmarshall(this, context);
}
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public Map<String, Object> getAccessDeniedDetail() {
return accessDeniedDetail;
}
public void setAccessDeniedDetail(Map<String, Object> accessDeniedDetail) {
this.accessDeniedDetail = accessDeniedDetail;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("AcsError{");
sb.append("statusCode=").append(statusCode);
sb.append(", errorCode='").append(errorCode).append('\'');
sb.append(", errorMessage='").append(errorMessage).append('\'');
sb.append(", requestId='").append(requestId).append('\'');
sb.append(", errorDescription='").append(errorDescription).append('\'');
if (null != accessDeniedDetail) {
sb.append(", accessDeniedDetail='").append(accessDeniedDetail).append('\'');
}
sb.append('}');
return sb.toString();
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/AcsErrorUnmarshaller.java
|
package com.aliyuncs;
import com.aliyuncs.transform.UnmarshallerContext;
import java.util.HashMap;
import java.util.Map;
public class AcsErrorUnmarshaller {
public static AcsError unmarshall(AcsError error, UnmarshallerContext context) {
Map<String, String> map = context.getResponseMap();
error.setStatusCode(context.getHttpStatus());
error.setRequestId(map.get("Error.RequestId") == null ? map.get("Error.requestId") : map.get("Error.RequestId"));
error.setErrorCode(map.get("Error.Code") == null ? map.get("Error.code") : map.get("Error.Code"));
error.setErrorMessage(map.get("Error.Message") == null ? map.get("Error.message") : map.get("Error.Message"));
error.setErrorDescription(map.get("Error.Description") == null ? map.get("Error.description") : map.get("Error.Description"));
Map<String, Object> accessDeniedDetail = new HashMap<String, Object>();
Map<Object, Object> tmp = context.mapValue("Error.AccessDeniedDetail");
for (Map.Entry<Object, Object> entry : tmp.entrySet()) {
accessDeniedDetail.put((String) entry.getKey(), entry.getValue());
}
error.setAccessDeniedDetail(accessDeniedDetail);
return error;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/AcsRequest.java
|
package com.aliyuncs;
import com.aliyuncs.auth.*;
import com.aliyuncs.auth.signers.SignatureAlgorithm;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.HttpRequest;
import com.aliyuncs.http.ProtocolType;
import com.aliyuncs.http.UserAgentConfig;
import com.aliyuncs.regions.ProductDomain;
import com.aliyuncs.utils.ParameterHelper;
import com.aliyuncs.utils.StringUtils;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.Map.Entry;
public abstract class AcsRequest<T extends AcsResponse> extends HttpRequest {
private final Map<String, String> queryParameters = new HashMap<String, String>();
private final Map<String, String> domainParameters = new HashMap<String, String>();
private final Map<String, String> bodyParameters = new HashMap<String, String>();
private UserAgentConfig userAgentConfig;
protected ISignatureComposer composer = null;
private String version = null;
private String product;
private String actionName = null;
private String regionId = null;
private String securityToken = null;
private FormatType acceptFormat = null;
private ProtocolType protocol = null;
private String locationProduct;
private String endpointType;
private ProductDomain productDomain = null;
protected String strToSign;
public HashMap<String, String> productEndpointMap = null;
public String productEndpointRegional = null;
public String productNetwork = "public";
public String productSuffix = "";
private SignatureVersion signatureVersion;
private SignatureAlgorithm signatureAlgorithm;
public AcsRequest(String product) {
super(null);
this.headers.put("x-sdk-client", "Java/2.0.0");
this.headers.put("x-sdk-invoke-type", "normal");
this.product = product;
}
public void resolveSignatureComposer() {
if (signatureVersion == SignatureVersion.V3) {
this.composer = V3SignatureComposer.getComposer();
}
}
protected String getSysSignedHeaders(Map<String, String> headers) {
String[] keys = headers.keySet().toArray(new String[headers.size()]);
Arrays.sort(keys);
List<String> canonicalizedKeys = new ArrayList<String>();
for (String key : keys) {
String lowerKey = key.toLowerCase();
if (lowerKey.startsWith("x-acs-") || lowerKey.equals("host")
|| lowerKey.equals("content-type")) {
if (!canonicalizedKeys.contains(lowerKey)) {
canonicalizedKeys.add(lowerKey);
}
}
}
String[] canonicalizedKeysArray = canonicalizedKeys.toArray(new String[canonicalizedKeys.size()]);
return StringUtils.join(";", Arrays.asList(canonicalizedKeysArray));
}
public static String concatQueryString(Map<String, String> parameters) throws UnsupportedEncodingException {
if (null == parameters) {
return null;
}
StringBuilder urlBuilder = new StringBuilder();
for (Entry<String, String> entry : parameters.entrySet()) {
String key = entry.getKey();
String val = entry.getValue();
urlBuilder.append(AcsURLEncoder.encode(key));
if (val != null) {
urlBuilder.append("=").append(AcsURLEncoder.encode(val));
}
urlBuilder.append("&");
}
int strIndex = urlBuilder.length();
if (parameters.size() > 0) {
urlBuilder.deleteCharAt(strIndex - 1);
}
return urlBuilder.toString();
}
/**
* @deprecated : Use setSysEndpoint instead of this
*/
@Deprecated
public void setEndpoint(String endpoint) {
ProductDomain productDomain = new ProductDomain(product, endpoint);
setProductDomain(productDomain);
}
/**
* @deprecated : Use getSysVersion instead of this
*/
@Deprecated
public String getVersion() {
return version;
}
/**
* @deprecated : Use setSysVersion instead of this
*/
@Deprecated
public void setVersion(String version) {
this.version = version;
}
/**
* @deprecated : Use getSysProduct instead of this
*/
@Deprecated
public String getProduct() {
return product;
}
/**
* @deprecated : Use getSysActionName instead of this
*/
@Deprecated
public String getActionName() {
return actionName;
}
/**
* @deprecated : Use setSysActionName instead of this
*/
@Deprecated
public void setActionName(String actionName) {
this.actionName = actionName;
}
/**
* @deprecated : Use getSysRegionId instead of this
*/
@Deprecated
public String getRegionId() {
return regionId;
}
/**
* @deprecated : Use setSysRegionId instead of this
*/
@Deprecated
public void setRegionId(String regionId) {
ParameterHelper.validateParameter(regionId, "regionId");
this.regionId = regionId;
}
/**
* @deprecated : Use getSysSecurityToken instead of this
*/
@Deprecated
public String getSecurityToken() {
return securityToken;
}
/**
* @deprecated : Use setSysSecurityToken instead of this
*/
@Deprecated
public void setSecurityToken(String securityToken) {
this.securityToken = securityToken;
putQueryParameter("SecurityToken", securityToken);
}
/**
* @deprecated : Use getSysAcceptFormat instead of this
*/
@Deprecated
public FormatType getAcceptFormat() {
return acceptFormat;
}
/**
* @deprecated : Use setSysAcceptFormat instead of this
*/
@Deprecated
public void setAcceptFormat(FormatType acceptFormat) {
this.acceptFormat = acceptFormat;
this.putHeaderParameter("Accept", FormatType.mapFormatToAccept(acceptFormat));
}
/**
* @deprecated : Use getSysProtocol instead of this
*/
@Deprecated
public ProtocolType getProtocol() {
return protocol;
}
/**
* @deprecated : Use setSysProtocol instead of this
*/
@Deprecated
public void setProtocol(ProtocolType protocol) {
this.protocol = protocol;
}
/**
* @deprecated : Use getSysQueryParameters instead of this
*/
@Deprecated
public Map<String, String> getQueryParameters() {
return Collections.unmodifiableMap(queryParameters);
}
public Map<String, String> getSysQueryParameters() {
return Collections.unmodifiableMap(queryParameters);
}
public <K> void putQueryParameter(String name, K value) {
setParameter(this.queryParameters, name, value);
}
protected void putQueryParameter(String name, String value) {
setParameter(this.queryParameters, name, value);
}
/**
* @deprecated : Use getSysDomainParameters instead of this
*/
@Deprecated
public Map<String, String> getDomainParameters() {
return Collections.unmodifiableMap(domainParameters);
}
public Map<String, String> getSysDomainParameters() {
return Collections.unmodifiableMap(domainParameters);
}
protected void putDomainParameter(String name, Object value) {
setParameter(this.domainParameters, name, value);
}
/**
* @deprecated : Use getSysBodyParameters instead of this
*/
@Deprecated
public Map<String, String> getBodyParameters() {
return Collections.unmodifiableMap(bodyParameters);
}
public Map<String, String> getSysBodyParameters() {
return Collections.unmodifiableMap(bodyParameters);
}
protected void putDomainParameter(String name, String value) {
setParameter(this.domainParameters, name, value);
}
protected void putBodyParameter(String name, Object value) {
setParameter(this.bodyParameters, name, value);
}
protected void setParameter(Map<String, String> map, String name, Object value) {
if (null == map || name == null || value == null) {
return;
}
map.put(name, String.valueOf(value));
}
/**
* @deprecated : Use getSysLocationProduct instead of this
*/
@Deprecated
public String getLocationProduct() {
return locationProduct;
}
/**
* @deprecated : Use setSysLocationProduct instead of this
*/
@Deprecated
public void setLocationProduct(String locationProduct) {
this.locationProduct = locationProduct;
putQueryParameter("ServiceCode", locationProduct);
}
/**
* @deprecated : Use getSysEndpointType instead of this
*/
@Deprecated
public String getEndpointType() {
return endpointType;
}
/**
* @deprecated : Use setSysEndpointType instead of this
*/
@Deprecated
public void setEndpointType(String endpointType) {
this.endpointType = endpointType;
putQueryParameter("Type", endpointType);
}
/**
* @deprecated : Use getSysProductDomain instead of this
*/
@Deprecated
public ProductDomain getProductDomain() {
return productDomain;
}
/**
* @deprecated : Use setSysProductDomain instead of this
*/
@Deprecated
public void setProductDomain(ProductDomain productDomain) {
this.productDomain = productDomain;
}
public abstract HttpRequest signRequest(Signer signer, AlibabaCloudCredentials credentials, FormatType format,
ProductDomain domain)
throws InvalidKeyException, IllegalStateException, UnsupportedEncodingException, NoSuchAlgorithmException;
public abstract String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException;
public abstract Class<T> getResponseClass();
public String getSysVersion() {
return version;
}
public void setSysVersion(String version) {
this.version = version;
}
public String getSysProduct() {
return product;
}
public String getSysActionName() {
return actionName;
}
public void setSysActionName(String actionName) {
this.actionName = actionName;
}
public String getSysRegionId() {
return regionId;
}
public void setSysRegionId(String regionId) {
ParameterHelper.validateParameter(regionId, "regionId");
this.regionId = regionId;
}
public String getSysSecurityToken() {
return securityToken;
}
public void setSysSecurityToken(String securityToken) {
this.securityToken = securityToken;
putQueryParameter("SecurityToken", securityToken);
}
public FormatType getSysAcceptFormat() {
return acceptFormat;
}
public void setSysAcceptFormat(FormatType acceptFormat) {
this.acceptFormat = acceptFormat;
this.putHeaderParameter("Accept", FormatType.mapFormatToAccept(acceptFormat));
}
public ProtocolType getSysProtocol() {
return protocol;
}
public void setSysProtocol(ProtocolType protocol) {
this.protocol = protocol;
}
public void setSysEndpoint(String endpoint) {
ProductDomain productDomain = new ProductDomain(product, endpoint);
setSysProductDomain(productDomain);
}
public String getSysLocationProduct() {
return locationProduct;
}
public void setSysLocationProduct(String locationProduct) {
this.locationProduct = locationProduct;
}
public String getSysEndpointType() {
return endpointType;
}
public void setSysEndpointType(String endpointType) {
this.endpointType = endpointType;
}
public ProductDomain getSysProductDomain() {
return productDomain;
}
public void setSysProductDomain(ProductDomain productDomain) {
this.productDomain = productDomain;
}
public UserAgentConfig getSysUserAgentConfig() {
return userAgentConfig;
}
public void appendUserAgent(String key, String value) {
if (this.userAgentConfig == null) {
this.userAgentConfig = new UserAgentConfig();
}
this.userAgentConfig.append(key, value);
}
public SignatureVersion getSysSignatureVersion() {
return signatureVersion;
}
public void setSysSignatureVersion(SignatureVersion signatureVersion) {
this.signatureVersion = signatureVersion;
}
public SignatureAlgorithm getSysSignatureAlgorithm() {
return signatureAlgorithm;
}
public void setSysSignatureAlgorithm(SignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
}
@Override
public String getSysStrToSign() {
return this.strToSign;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/AcsResponse.java
|
package com.aliyuncs;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.transform.UnmarshallerContext;
public abstract class AcsResponse {
public abstract AcsResponse getInstance(UnmarshallerContext context) throws ClientException, ServerException;
public boolean checkShowJsonItemName() {
return true;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/CommonRequest.java
|
package com.aliyuncs;
import com.aliyuncs.auth.SignatureVersion;
import com.aliyuncs.auth.signers.SignatureAlgorithm;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.http.ProtocolType;
import com.aliyuncs.policy.retry.RetryPolicy;
import com.aliyuncs.regions.ProductDomain;
import java.util.HashMap;
import java.util.Map;
public class CommonRequest {
private final Map<String, String> queryParameters = new HashMap<String, String>();
private final Map<String, String> bodyParameters = new HashMap<String, String>();
private final Map<String, String> headParameters = new HashMap<String, String>();
private String version = null;
private String product = null;
private String action = null;
private String locationProduct = null;
private String endpointType = null;
private String regionId = null;
private ProtocolType protocol = null;
private Integer connectTimeout = null;
private Integer readTimeout = null;
private MethodType method = null;
private FormatType httpContentType = null;
private byte[] httpContent = null;
private String encoding = null;
private FormatType accept = FormatType.JSON;
private String uriPattern = null;
private Map<String, String> pathParameters = new HashMap<String, String>();
private String domain = null;
private SignatureVersion signatureVersion;
private SignatureAlgorithm signatureAlgorithm;
private RetryPolicy retryPolicy = null;
@SuppressWarnings("rawtypes")
public AcsRequest buildRequest() {
if (uriPattern != null) {
CommonRoaRequest request = new CommonRoaRequest(product);
request.setSysUriPattern(uriPattern);
request.setSysSignatureVersion(signatureVersion);
request.setSysSignatureAlgorithm(signatureAlgorithm);
request.setSysRetryPolicy(retryPolicy);
for (String pathParamKey : pathParameters.keySet()) {
request.putPathParameter(pathParamKey, pathParameters.get(pathParamKey));
}
fillParams(request);
return request;
} else {
CommonRpcRequest request = new CommonRpcRequest(product);
request.setSysSignatureVersion(signatureVersion);
request.setSysSignatureAlgorithm(signatureAlgorithm);
request.setSysRetryPolicy(retryPolicy);
fillParams(request);
return request;
}
}
@SuppressWarnings("rawtypes")
private void fillParams(AcsRequest request) {
request.putHeaderParameter("x-sdk-invoke-type", "common");
if (version != null) {
request.setSysVersion(version);
}
if (action != null) {
request.setSysActionName(action);
}
if (regionId != null) {
request.setSysRegionId(regionId);
}
if (locationProduct != null) {
request.setSysLocationProduct(locationProduct);
}
if (endpointType != null) {
request.setSysEndpointType(endpointType);
}
if (connectTimeout != null) {
request.setSysConnectTimeout(connectTimeout);
}
if (readTimeout != null) {
request.setSysReadTimeout(readTimeout);
}
if (method != null) {
request.setSysMethod(method);
}
if (protocol != null) {
request.setSysProtocol(protocol);
}
request.setSysAcceptFormat(accept);
if (domain != null) {
ProductDomain productDomain = new ProductDomain(product, domain);
request.setSysProductDomain(productDomain);
}
if (bodyParameters.size() > 0 && httpContentType != null) {
request.setHttpContentType(httpContentType);
}
if (httpContent != null) {
request.setHttpContent(httpContent, encoding, httpContentType);
}
for (String queryParamKey : queryParameters.keySet()) {
request.putQueryParameter(queryParamKey, queryParameters.get(queryParamKey));
}
for (String bodyParamKey : bodyParameters.keySet()) {
request.putBodyParameter(bodyParamKey, bodyParameters.get(bodyParamKey));
}
for (String headParamKey : headParameters.keySet()) {
request.putHeaderParameter(headParamKey, headParameters.get(headParamKey));
}
}
/**
* @Deprecated : Use getSysVersion instead of this
*/
@Deprecated
public String getVersion() {
return version;
}
/**
* @Deprecated : Use setSysVersion instead of this
*/
@Deprecated
public void setVersion(String version) {
this.version = version;
}
/**
* @Deprecated : Use getSysProduct instead of this
*/
@Deprecated
public String getProduct() {
return product;
}
/**
* @Deprecated : Use setSysProduct instead of this
*/
@Deprecated
public void setProduct(String product) {
this.product = product;
}
/**
* @Deprecated : Use getSysAction instead of this
*/
@Deprecated
public String getAction() {
return action;
}
/**
* @Deprecated : Use setSysAction instead of this
*/
@Deprecated
public void setAction(String action) {
this.action = action;
}
/**
* @Deprecated : Use getSysLocationProduct instead of this
*/
@Deprecated
public String getLocationProduct() {
return locationProduct;
}
/**
* @Deprecated : Use setSysLocationProduct instead of this
*/
@Deprecated
public void setLocationProduct(String locationProduct) {
this.locationProduct = locationProduct;
}
/**
* @Deprecated : Use getSysEndpointType instead of this
*/
@Deprecated
public String getEndpointType() {
return endpointType;
}
/**
* @Deprecated : Use setSysEndpointType instead of this
*/
@Deprecated
public void setEndpointType(String endpointType) {
this.endpointType = endpointType;
}
/**
* @Deprecated : Use getSysRegionId instead of this
*/
@Deprecated
public String getRegionId() {
return regionId;
}
/**
* @Deprecated : Use setSysRegionId instead of this
*/
@Deprecated
public void setRegionId(String regionId) {
this.regionId = regionId;
}
/**
* @Deprecated : Use getSysProtocol instead of this
*/
@Deprecated
public ProtocolType getProtocol() {
return protocol;
}
/**
* @Deprecated : Use setSysProtocol instead of this
*/
@Deprecated
public void setProtocol(ProtocolType protocol) {
this.protocol = protocol;
}
public void putBodyParameter(String name, Object value) {
setParameter(this.bodyParameters, name, value);
}
public void putQueryParameter(String name, String value) {
setParameter(this.queryParameters, name, value);
}
public void putHeadParameter(String name, String value) {
setParameter(this.headParameters, name, value);
}
private void setParameter(Map<String, String> map, String name, Object value) {
if (null == map || name == null || value == null) {
return;
}
map.put(name, String.valueOf(value));
}
/**
* @Deprecated : Use getSysConnectTimeout instead of this
*/
@Deprecated
public Integer getConnectTimeout() {
return connectTimeout;
}
/**
* @Deprecated : Use setSysConnectTimeout instead of this
*/
@Deprecated
public void setConnectTimeout(Integer connectTimeout) {
this.connectTimeout = connectTimeout;
}
/**
* @Deprecated : Use getSysReadTimeout instead of this
*/
@Deprecated
public Integer getReadTimeout() {
return readTimeout;
}
/**
* @Deprecated : Use setSysReadTimeout instead of this
*/
@Deprecated
public void setReadTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
}
/**
* @Deprecated : Use getSysMethod instead of this
*/
@Deprecated
public MethodType getMethod() {
return method;
}
/**
* @Deprecated : Use setSysMethod instead of this
*/
@Deprecated
public void setMethod(MethodType method) {
this.method = method;
}
/**
* @Deprecated : Use getSysUriPattern instead of this
*/
@Deprecated
public String getUriPattern() {
return uriPattern;
}
/**
* @Deprecated : Use setSysUriPattern instead of this
*/
@Deprecated
public void setUriPattern(String uriPattern) {
this.uriPattern = uriPattern;
}
public void putPathParameter(String name, String value) {
setParameter(this.pathParameters, name, value);
}
/**
* @Deprecated : Use getSysDomain instead of this
*/
@Deprecated
public String getDomain() {
return domain;
}
/**
* @Deprecated : Use setSysDomain instead of this
*/
@Deprecated
public void setDomain(String domain) {
this.domain = domain;
}
public FormatType getHttpContentType() {
return httpContentType;
}
public void setHttpContentType(FormatType type) {
this.httpContentType = type;
}
public byte[] getHttpContent() {
return httpContent;
}
/**
* @Deprecated : Use getSysEncoding instead of this
*/
@Deprecated
public String getEncoding() {
return encoding;
}
/**
* @Deprecated : Use getSysQueryParameters instead of this
*/
@Deprecated
public Map<String, String> getQueryParameters() {
return queryParameters;
}
/**
* @Deprecated : Use getSysBodyParameters instead of this
*/
@Deprecated
public Map<String, String> getBodyParameters() {
return bodyParameters;
}
/**
* @Deprecated : Use getSysHeadParameters instead of this
*/
@Deprecated
public Map<String, String> getHeadParameters() {
return headParameters;
}
/**
* @Deprecated : Use getSysPathParameters instead of this
*/
@Deprecated
public Map<String, String> getPathParameters() {
return pathParameters;
}
public void setHttpContent(byte[] content, String encoding, FormatType format) {
if (content == null || encoding == null || format == null) {
return;
}
this.httpContent = content;
this.httpContentType = format;
this.encoding = encoding;
}
public String getSysVersion() {
return version;
}
public void setSysVersion(String version) {
this.version = version;
}
public String getSysProduct() {
return product;
}
public void setSysProduct(String product) {
this.product = product;
}
public String getSysAction() {
return action;
}
public void setSysAction(String action) {
this.action = action;
}
public String getSysLocationProduct() {
return locationProduct;
}
public void setSysLocationProduct(String locationProduct) {
this.locationProduct = locationProduct;
}
public String getSysEndpointType() {
return endpointType;
}
public void setSysEndpointType(String endpointType) {
this.endpointType = endpointType;
}
public String getSysRegionId() {
return regionId;
}
public void setSysRegionId(String regionId) {
this.regionId = regionId;
}
public ProtocolType getSysProtocol() {
return protocol;
}
public void setSysProtocol(ProtocolType protocol) {
this.protocol = protocol;
}
public Integer getSysConnectTimeout() {
return connectTimeout;
}
public void setSysConnectTimeout(Integer connectTimeout) {
this.connectTimeout = connectTimeout;
}
public Integer getSysReadTimeout() {
return readTimeout;
}
public void setSysReadTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
}
public MethodType getSysMethod() {
return method;
}
public void setSysMethod(MethodType method) {
this.method = method;
}
public String getSysUriPattern() {
return uriPattern;
}
public void setSysUriPattern(String uriPattern) {
this.uriPattern = uriPattern;
}
public String getSysDomain() {
return domain;
}
public void setSysDomain(String domain) {
this.domain = domain;
}
public String getSysEncoding() {
return encoding;
}
public Map<String, String> getSysQueryParameters() {
return queryParameters;
}
public Map<String, String> getSysBodyParameters() {
return bodyParameters;
}
public Map<String, String> getSysHeadParameters() {
return headParameters;
}
public Map<String, String> getSysPathParameters() {
return pathParameters;
}
public void setSysAccept(FormatType type) {
this.accept = type;
}
public FormatType getSysAccept() {
return this.accept;
}
public SignatureVersion getSysSignatureVersion() {
return signatureVersion;
}
public void setSysSignatureVersion(SignatureVersion signatureVersion) {
this.signatureVersion = signatureVersion;
}
public SignatureAlgorithm getSysSignatureAlgorithm() {
return signatureAlgorithm;
}
public void setSysSignatureAlgorithm(SignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
}
public RetryPolicy getSysRetryPolicy() {
return this.retryPolicy;
}
public void setSysRetryPolicy(RetryPolicy retryPolicy) {
this.retryPolicy = retryPolicy;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/CommonResponse.java
|
package com.aliyuncs;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class CommonResponse extends AcsResponse {
private String data;
private int httpStatus;
private HttpResponse httpResponse;
@Override
public AcsResponse getInstance(UnmarshallerContext context) throws ClientException, ServerException {
return null;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public int getHttpStatus() {
return httpStatus;
}
public void setHttpStatus(int httpStatus) {
this.httpStatus = httpStatus;
}
public HttpResponse getHttpResponse() {
return httpResponse;
}
public void setHttpResponse(HttpResponse httpResponse) {
this.httpResponse = httpResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/CommonRoaRequest.java
|
package com.aliyuncs;
public class CommonRoaRequest extends RoaAcsRequest<CommonResponse> {
public CommonRoaRequest(String product) {
super(product);
}
public CommonRoaRequest(String product, String version, String action) {
super(product, version, action);
}
public CommonRoaRequest(String product, String version, String action, String locationProduct) {
super(product, version, action, locationProduct);
}
public CommonRoaRequest(String product, String version, String action, String locationProduct,
String endpointType) {
super(product, version, action, locationProduct, endpointType);
}
@Override
public Class<CommonResponse> getResponseClass() {
return CommonResponse.class;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/CommonRpcRequest.java
|
package com.aliyuncs;
public class CommonRpcRequest extends RpcAcsRequest<CommonResponse> {
public CommonRpcRequest(String product) {
super(product);
}
public CommonRpcRequest(String product, String version, String action) {
super(product, version, action);
}
public CommonRpcRequest(String product, String version, String action, String locationProduct) {
super(product, version, action, locationProduct);
}
public CommonRpcRequest(String product, String version, String action, String locationProduct,
String endpointType) {
super(product, version, action, locationProduct, endpointType);
}
@Override
public Class<CommonResponse> getResponseClass() {
return CommonResponse.class;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/DefaultAcsClient.java
|
package com.aliyuncs;
import com.aliyuncs.auth.*;
import com.aliyuncs.auth.signers.SignatureAlgorithm;
import com.aliyuncs.endpoint.DefaultEndpointResolver;
import com.aliyuncs.endpoint.EndpointResolver;
import com.aliyuncs.endpoint.ResolveEndpointRequest;
import com.aliyuncs.exceptions.*;
import com.aliyuncs.http.*;
import com.aliyuncs.policy.retry.RetryPolicy;
import com.aliyuncs.policy.retry.RetryPolicyContext;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.aliyuncs.reader.Reader;
import com.aliyuncs.reader.ReaderFactory;
import com.aliyuncs.regions.ProductDomain;
import com.aliyuncs.transform.UnmarshallerContext;
import com.aliyuncs.unmarshaller.Unmarshaller;
import com.aliyuncs.unmarshaller.UnmarshallerFactory;
import com.aliyuncs.utils.*;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.propagation.Format;
import io.opentracing.tag.Tags;
import io.opentracing.util.GlobalTracer;
import org.slf4j.Logger;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.SocketTimeoutException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@SuppressWarnings("deprecation")
public class DefaultAcsClient implements IAcsClient {
// Now maxRetryNumber and autoRetry has no effect.
private int maxRetryNumber = 3;
private boolean autoRetry = true;
private IClientProfile clientProfile;
private AlibabaCloudCredentialsProvider credentialsProvider;
private IHttpClient httpClient;
private EndpointResolver endpointResolver;
private static final String SIGNATURE_BEGIN = "string to sign is:";
private final UserAgentConfig userAgentConfig = new UserAgentConfig();
private SignatureVersion signatureVersion = SignatureVersion.V1;
private SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.ACS3_HMAC_SHA256;
private final String SEPARATOR = "::";
private RetryPolicy retryPolicy = RetryPolicy.none();
/**
* @Deprecated : Use DefaultAcsClient(String regionId) instead of this
*/
@Deprecated
public DefaultAcsClient() throws ClientException {
this.clientProfile = DefaultProfile.getProfile();
this.httpClient = HttpClientFactory.buildClient(this.clientProfile);
}
public DefaultAcsClient(String regionId) throws ClientException {
this.clientProfile = DefaultProfile.getProfile(regionId);
this.httpClient = HttpClientFactory.buildClient(this.clientProfile);
this.credentialsProvider = new DefaultCredentialsProvider();
this.endpointResolver = new DefaultEndpointResolver(this);
this.appendUserAgent("HTTPClient", this.httpClient.getClass().getSimpleName());
}
public DefaultAcsClient(IClientProfile profile) {
this.clientProfile = profile;
AlibabaCloudCredentialsProvider provider = profile.getCredentialsProvider();
if (provider != null) {
this.credentialsProvider = provider;
} else {
this.credentialsProvider = new StaticCredentialsProvider(profile);
}
this.httpClient = HttpClientFactory.buildClient(profile);
this.endpointResolver = new DefaultEndpointResolver(this, profile);
this.appendUserAgent("HTTPClient", this.httpClient.getClass().getSimpleName());
}
public DefaultAcsClient(IClientProfile profile, AlibabaCloudCredentials credentials) {
this(profile, new StaticCredentialsProvider(credentials));
}
public DefaultAcsClient(IClientProfile profile, AlibabaCloudCredentialsProvider credentialsProvider) {
this.clientProfile = profile;
this.credentialsProvider = credentialsProvider;
this.clientProfile.setCredentialsProvider(this.credentialsProvider);
this.httpClient = HttpClientFactory.buildClient(this.clientProfile);
this.endpointResolver = new DefaultEndpointResolver(this, profile);
this.appendUserAgent("HTTPClient", this.httpClient.getClass().getSimpleName());
}
@Override
public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request)
throws ClientException, ServerException {
return this.doAction(request, autoRetry, maxRetryNumber, this.clientProfile);
}
@Override
public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, boolean autoRetry, int maxRetryCounts)
throws ClientException, ServerException {
return this.doAction(request, autoRetry, maxRetryCounts, this.clientProfile);
}
@Override
public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, IClientProfile profile)
throws ClientException, ServerException {
return this.doAction(request, this.autoRetry, this.maxRetryNumber, profile);
}
@Override
public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, String regionId, Credential credential)
throws ClientException, ServerException {
if (null == request.getSysSignatureVersion()) {
request.setSysSignatureVersion(this.signatureVersion);
}
if (null == request.getSysSignatureAlgorithm()) {
request.setSysSignatureAlgorithm(this.signatureAlgorithm);
}
Signer signer = Signer.getSigner(new LegacyCredentials(credential), request.getSysSignatureVersion(), request.getSysSignatureAlgorithm());
if (null == request.getSysRegionId()) {
request.setSysRegionId(regionId);
}
return doAction(request, regionId, new LegacyCredentials(credential), signer, null);
}
@Override
public <T extends AcsResponse> T getAcsResponse(AcsRequest<T> request) throws ServerException, ClientException {
HttpResponse baseResponse = this.doAction(request);
return parseAcsResponse(request, baseResponse);
}
@Override
public <T extends AcsResponse> T getAcsResponse(AcsRequest<T> request, boolean autoRetry, int maxRetryCounts)
throws ServerException, ClientException {
HttpResponse baseResponse = this.doAction(request, autoRetry, maxRetryCounts);
return parseAcsResponse(request, baseResponse);
}
@Override
public <T extends AcsResponse> T getAcsResponse(AcsRequest<T> request, IClientProfile profile)
throws ServerException, ClientException {
HttpResponse baseResponse = this.doAction(request, profile);
return parseAcsResponse(request, baseResponse);
}
@Override
public <T extends AcsResponse> T getAcsResponse(AcsRequest<T> request, String regionId, Credential credential)
throws ServerException, ClientException {
HttpResponse baseResponse = this.doAction(request, regionId, credential);
return parseAcsResponse(request, baseResponse);
}
@Override
public <T extends AcsResponse> T getAcsResponse(AcsRequest<T> request, String regionId)
throws ServerException, ClientException {
if (null == request.getSysRegionId()) {
request.setSysRegionId(regionId);
}
HttpResponse baseResponse = this.doAction(request);
return parseAcsResponse(request, baseResponse);
}
@SuppressWarnings("unchecked")
@Override
public CommonResponse getCommonResponse(CommonRequest request) throws ServerException, ClientException {
HttpResponse baseResponse = this.doAction(request.buildRequest());
if (baseResponse.isSuccess()) {
String stringContent = baseResponse.getHttpContentString();
CommonResponse response = new CommonResponse();
response.setData(stringContent);
response.setHttpStatus(baseResponse.getStatus());
response.setHttpResponse(baseResponse);
return response;
} else {
FormatType format = baseResponse.getHttpContentType();
AcsError error = readError(baseResponse, format);
if (500 <= baseResponse.getStatus()) {
throw new ServerException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId());
} else {
throw new ClientException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId(), error.getErrorDescription(), error.getAccessDeniedDetail());
}
}
}
@Override
public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, boolean autoRetry, int maxRetryCounts,
IClientProfile profile) throws ClientException, ServerException {
if (null == profile) {
throw new ClientException("SDK.InvalidProfile", "No active profile found.");
}
String region = profile.getRegionId();
if (null == request.getSysRegionId()) {
request.setSysRegionId(region);
}
AlibabaCloudCredentials credentials;
if (null == credentialsProvider) {
credentials = new AnonymousCredentials();
} else {
credentials = this.credentialsProvider.getCredentials();
}
if (null == request.getSysSignatureVersion()) {
request.setSysSignatureVersion(this.signatureVersion);
}
if (null == request.getSysSignatureAlgorithm()) {
request.setSysSignatureAlgorithm(this.signatureAlgorithm);
}
Signer signer = Signer.getSigner(credentials, request.getSysSignatureVersion(), request.getSysSignatureAlgorithm());
FormatType format = profile.getFormat();
return this.doAction(request, request.getSysRegionId(), credentials, signer, format);
}
private <T extends AcsResponse> T parseAcsResponse(AcsRequest<T> request, HttpResponse baseResponse)
throws ServerException, ClientException {
FormatType format = baseResponse.getHttpContentType();
if (FormatType.JSON != format && FormatType.XML != format) {
throw new ClientException(String.format("Server response has a bad format type: %s;\nThe original return is: %s;\n" +
"The original header is: %s;",
format, baseResponse.getHttpContentString(), baseResponse.getSysHeaders().toString()));
}
if (baseResponse.isSuccess()) {
return readResponse(request.getResponseClass(), baseResponse, format);
} else {
AcsError error = readError(baseResponse, format);
if (500 <= baseResponse.getStatus()) {
throw new ServerException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId());
} else if (400 == baseResponse.getStatus() && ("IncompleteSignature".equals(error.getErrorCode())
|| "SignatureDoesNotMatch".equals(error.getErrorCode()))) {
String errorMessage = error.getErrorMessage();
Pattern startPattern = Pattern.compile(SIGNATURE_BEGIN);
Matcher startMatcher = startPattern.matcher(errorMessage);
if (startMatcher.find()) {
int start = startMatcher.end();
String errorStrToSign = errorMessage.substring(start);
if (request.strToSign.equals(errorStrToSign)) {
throw new ClientException("SDK.InvalidAccessKeySecret",
"Specified Access Key Secret is not valid.", error.getRequestId());
}
}
}
throw new ClientException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId(), error.getErrorDescription(), error.getAccessDeniedDetail());
}
}
/**
* @Deprecated : Use other overload methods
*/
@Deprecated
public <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, boolean autoRetry, int maxRetryNumber,
String regionId, Credential credential, Signer signer, FormatType format)
throws ClientException, ServerException {
return doAction(request, regionId, new LegacyCredentials(credential), signer,
format);
}
public ProductDomain getDomain(AcsRequest request, String regionId)
throws ClientException {
ProductDomain domain;
if (request.getSysProductDomain() != null) {
domain = request.getSysProductDomain();
} else {
ResolveEndpointRequest resolveEndpointRequest = new ResolveEndpointRequest(regionId,
request.getSysProduct(), request.getSysLocationProduct(), request.getSysEndpointType());
resolveEndpointRequest.setProductEndpointMap(request.productEndpointMap);
resolveEndpointRequest.setProductEndpointRegional(request.productEndpointRegional);
resolveEndpointRequest.setProductNetwork(request.productNetwork);
resolveEndpointRequest.setProductSuffix(request.productSuffix);
String endpoint = endpointResolver.resolve(resolveEndpointRequest);
domain = new ProductDomain(request.getSysProduct(), endpoint);
if (endpoint.endsWith("endpoint-test.exception.com")) {
// For endpoint testability, if the endpoint is xxxx.endpoint-test.special.com
// throw a client exception with this endpoint
throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_TESTABILITY, endpoint);
}
}
return domain;
}
private <T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request,
String regionId, AlibabaCloudCredentials credentials, Signer signer, FormatType format)
throws ClientException, ServerException {
if (!GlobalTracer.isRegistered() || clientProfile.isCloseTrace()) {
return doRealAction(request, regionId, credentials, signer, format);
}
Tracer tracer = GlobalTracer.get();
Span activeSpan = tracer.activeSpan();
Tracer.SpanBuilder sb = tracer.buildSpan(request.getSysUrl());
if (activeSpan != null) {
sb.asChildOf(activeSpan);
}
Span span = sb.withTag(Tags.COMPONENT.getKey(), "aliyunApi")
.withTag("actionName", request.getSysActionName())
.withTag("queryParam", MapUtils.getMapString(request.getQueryParameters()))
.start();
tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new HttpHeadersInjectAdapter(request));
try {
HttpResponse response = doRealAction(request, regionId, credentials, signer, format);
span.setTag("status", response.getStatus());
span.setTag("ReasonPhrase", response.getReasonPhrase());
return response;
} catch (ClientException ex) {
TraceUtils.onError(ex, span);
throw ex;
} finally {
span.finish();
}
}
private <T extends AcsResponse> HttpResponse doRealAction(AcsRequest<T> request,
String regionId, AlibabaCloudCredentials credentials, Signer signer, FormatType format)
throws ClientException, ServerException {
doActionWithProxy(request.getSysProtocol(), System.getenv("HTTPS_PROXY"), System.getenv("HTTP_PROXY"));
doActionWithIgnoreSSL(request, X509TrustAll.ignoreSSLCerts);
Logger logger = clientProfile.getLogger();
String startTime = "";
String timeCost = "";
HttpResponse response = null;
String errorMessage = "";
try {
FormatType requestFormatType = request.getSysAcceptFormat();
if (null != requestFormatType) {
format = requestFormatType;
}
ProductDomain domain = getDomain(request, regionId);
if (request.getSysProtocol() == null) {
request.setSysProtocol(this.clientProfile.getHttpClientConfig().getProtocolType());
}
request.putHeaderParameter("User-Agent",
UserAgentConfig.resolve(request.getSysUserAgentConfig(), this.userAgentConfig));
request.putHeaderParameter("x-acs-version", request.getSysVersion());
if (null != request.getSysActionName()) {
request.putHeaderParameter("x-acs-action", request.getSysActionName());
}
String coordinate = credentials.getAccessKeyId() == null ? "" : credentials.getAccessKeyId()
+ SEPARATOR + request.getSysProduct()
+ SEPARATOR + request.getSysVersion()
+ SEPARATOR + request.getSysActionName()
+ SEPARATOR + request.getSysRegionId();
RetryPolicy retryPolicy = request.getSysRetryPolicy() != null ? request.getSysRetryPolicy() :
this.retryPolicy != null ? this.retryPolicy : RetryPolicy.none();
int retriesAttempted = 0;
RetryPolicyContext context = RetryPolicyContext.builder()
.coordinate(coordinate)
.retriesAttempted(retriesAttempted)
.build();
if (retryPolicy.enableAliyunThrottlingControl()) {
request.putHeaderParameter("x-sdk-throttling-control", "enable");
}
while (retryPolicy.shouldRetry(context)) {
TimeUnit.MILLISECONDS.sleep(retryPolicy.getBackoffDelay(context));
HttpRequest httpRequest = request.signRequest(signer, credentials, format, domain);
Exception ex;
try {
HttpUtil.debugHttpRequest(httpRequest);
startTime = LogUtils.localeNow();
long start = System.nanoTime();
response = this.httpClient.syncInvoke(httpRequest);
long end = System.nanoTime();
timeCost = TimeUnit.NANOSECONDS.toMillis(end - start) + "ms";
HttpUtil.debugHttpResponse(response);
if (response.isSuccess()) {
return response;
} else {
FormatType responseFormat = response.getHttpContentType();
AcsError error = readError(response, responseFormat);
if (500 <= response.getStatus()) {
ex = new ServerException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId());
} else {
ex = new ClientException(error.getErrorCode(), error.getErrorMessage(), error.getRequestId(), error.getErrorDescription(), error.getAccessDeniedDetail());
}
}
} catch (SocketTimeoutException exp) {
ex = exp;
} catch (IOException exp) {
ex = exp;
}
context = RetryPolicyContext.builder()
.coordinate(coordinate)
.retriesAttempted(++retriesAttempted)
.httpResponse(response)
.exception(ex)
.build();
}
if (context.httpResponse() != null) {
return context.httpResponse();
}
if (context.exception() != null) {
throw context.exception();
}
errorMessage = "Some errors occurred. Maybe the client triggered throttling policy.";
throw new ClientException("SDK.RequestTryOrRetryFailed", errorMessage, context.exception());
} catch (InterruptedException exp) {
errorMessage = exp.getMessage();
throw new ClientException("SDK.InterruptedException",
"Client has been interrupted: connection " + request.getSysUrl() + " failed", exp);
} catch (InvalidKeyException exp) {
errorMessage = exp.getMessage();
throw new ClientException("SDK.InvalidAccessSecret", "Specified access secret is not valid.", exp);
} catch (NoSuchAlgorithmException exp) {
errorMessage = exp.getMessage();
throw new ClientException("SDK.InvalidMD5Algorithm", "MD5 hash is not supported by client side.", exp);
} catch (UnsupportedEncodingException exp) {
errorMessage = exp.getMessage();
throw new ClientException("SDK.UnsupportedEncodingException", "UTF-8 encoding is not supported by client side.", exp);
} catch (Throwable exp) {
errorMessage = exp.getMessage();
if (SocketTimeoutException.class.isAssignableFrom(exp.getClass())) {
throw new ClientException("SDK.ReadTimeout",
"SocketTimeoutException has occurred on a socket read or accept.The url is " +
request.getSysUrl(), exp);
} else if (IOException.class.isAssignableFrom(exp.getClass())) {
throw new ClientException("SDK.ServerUnreachable",
"Server unreachable: connection " + request.getSysUrl() + " failed", exp);
} else if (ServerException.class.isAssignableFrom(exp.getClass())) {
throw (ServerException) exp;
} else if (ThrottlingException.class.isAssignableFrom(exp.getClass())) {
throw new ClientException("SDK.RequestTryOrRetryFailed", errorMessage, exp);
} else if (ClientException.class.isAssignableFrom(exp.getClass())) {
throw (ClientException) exp;
} else {
throw new ClientException("SDK.RequestTryOrRetryFailed",
"Some errors occurred. Error message for latest request is " + exp.getMessage(), exp);
}
} finally {
if (null != logger) {
try {
LogUtils.LogUnit logUnit = LogUtils.createLogUnit(request, response);
logUnit.setStartTime(startTime);
logUnit.setCost(timeCost);
logUnit.setError(errorMessage);
String logContent = LogUtils.fillContent(clientProfile.getLogFormat(), logUnit);
logger.info(logContent);
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}
/**
* 2019-01-03 change access control from private to protected, then subClass can
* override it and rewrite httpResponse processing
*/
protected <T extends AcsResponse> T readResponse(Class<T> clazz, HttpResponse httpResponse, FormatType format)
throws ClientException {
// new version response contains "@XmlRootElement" annotation
if (clazz.isAnnotationPresent(XmlRootElement.class)
&& !clientProfile.getHttpClientConfig().isCompatibleMode()) {
Unmarshaller unmarshaller = UnmarshallerFactory.getUnmarshaller(format);
return unmarshaller.unmarshal(clazz, httpResponse.getHttpContentString());
} else {
Reader reader = ReaderFactory.createInstance(format);
UnmarshallerContext context = new UnmarshallerContext();
T response;
String stringContent = httpResponse.getHttpContentString();
if (stringContent == null) {
throw new ClientException(ErrorCodeConstant.SDK_INVALID_SERVER_RESPONSE,
ErrorMessageConstant.SERVER_RESPONSE_HTTP_BODY_EMPTY);
}
try {
response = clazz.newInstance();
} catch (Exception e) {
throw new ClientException("SDK.InvalidResponseClass",
"Unable to allocate " + clazz.getName() + " class");
}
String responseEndpoint = clazz.getName().substring(clazz.getName().lastIndexOf(".") + 1);
if (response.checkShowJsonItemName()) {
context.setResponseMap(reader.read(stringContent, responseEndpoint));
} else {
context.setResponseMap(reader.readForHideArrayItem(stringContent, responseEndpoint));
}
context.setHttpResponse(httpResponse);
response.getInstance(context);
return response;
}
}
private AcsError readError(HttpResponse httpResponse, FormatType format) throws ClientException {
AcsError error = new AcsError();
String stringContent = httpResponse.getHttpContentString();
if (stringContent == null) {
error.setErrorCode("(null)");
error.setErrorMessage("(null)");
error.setRequestId("(null)");
error.setStatusCode(httpResponse.getStatus());
return error;
} else {
try {
String responseEndpoint = "Error";
Reader reader = ReaderFactory.createInstance(format);
UnmarshallerContext context = new UnmarshallerContext();
context.setResponseMap(reader.read(stringContent, responseEndpoint));
return error.getInstance(context);
} catch (Exception e) {
stringContent = "Server response has a bad format type: " + format + ";\nThe original return is: \n" + stringContent;
error.setErrorCode("(null)");
error.setErrorMessage(stringContent);
error.setRequestId("(null)");
error.setStatusCode(httpResponse.getStatus());
return error;
}
}
}
/**
* Compatible with previous versions of proxy Settings
*/
public void doActionWithProxy(ProtocolType protocolType, String httpsProxy, String httpProxy) {
HttpClientConfig config = this.clientProfile.getHttpClientConfig();
if (protocolType == ProtocolType.HTTP && httpProxy != null) {
config.setHttpProxy(httpProxy);
return;
}
if (protocolType == ProtocolType.HTTPS && httpsProxy != null) {
config.setHttpsProxy(httpsProxy);
return;
}
return;
}
/**
* Compatible with previous versions of SSL Settings
*/
public void doActionWithIgnoreSSL(AcsRequest request, boolean isIgnore) {
if (isIgnore) {
request.setIgnoreSSLCerts(true);
}
}
@Deprecated
public boolean isAutoRetry() {
return autoRetry;
}
@Deprecated
public void setAutoRetry(boolean autoRetry) {
this.autoRetry = autoRetry;
}
@Deprecated
public int getMaxRetryNumber() {
return maxRetryNumber;
}
@Deprecated
public void setMaxRetryNumber(int maxRetryNumber) {
this.maxRetryNumber = maxRetryNumber;
}
@Override
public void restoreSSLCertificate() {
this.httpClient.restoreSSLCertificate();
}
@Override
public void ignoreSSLCertificate() {
this.httpClient.ignoreSSLCertificate();
}
public void setEndpointResolver(EndpointResolver resolver) {
endpointResolver = resolver;
}
@Override
public void shutdown() {
if (!this.httpClient.isSingleton()) {
IOUtils.closeQuietly(this.httpClient);
this.httpClient = null;
}
}
public DefaultProfile getProfile() {
return (DefaultProfile) clientProfile;
}
public void appendUserAgent(String key, String value) {
this.userAgentConfig.append(key, value);
}
public UserAgentConfig getUserAgentConfig() {
return userAgentConfig;
}
public IHttpClient getHttpClient() {
return httpClient;
}
public void setHttpClient(IHttpClient httpClient) {
this.httpClient = httpClient;
}
public AlibabaCloudCredentialsProvider getCredentialsProvider() {
return credentialsProvider;
}
@Override
public SignatureVersion getSignatureVersion() {
return signatureVersion;
}
@Override
public void setSignatureVersion(SignatureVersion signatureVersion) {
this.signatureVersion = signatureVersion;
}
@Override
public SignatureAlgorithm getSignatureAlgorithm() {
return signatureAlgorithm;
}
@Override
public void setSignatureAlgorithm(SignatureAlgorithm signatureAlgorithm) {
this.signatureAlgorithm = signatureAlgorithm;
}
@Override
public RetryPolicy getSysRetryPolicy() {
return this.retryPolicy;
}
@Override
public void setSysRetryPolicy(RetryPolicy retryPolicy) {
this.retryPolicy = retryPolicy;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/IAcsClient.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs;
import com.aliyuncs.auth.Credential;
import com.aliyuncs.auth.SignatureVersion;
import com.aliyuncs.auth.signers.SignatureAlgorithm;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.policy.retry.RetryPolicy;
import com.aliyuncs.profile.IClientProfile;
public interface IAcsClient {
<T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request)
throws ClientException, ServerException;
<T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request,
boolean autoRetry, int maxRetryCounts)
throws ClientException, ServerException;
<T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, IClientProfile profile)
throws ClientException, ServerException;
<T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, String regionId,
Credential credential) throws ClientException, ServerException;
<T extends AcsResponse> T getAcsResponse(AcsRequest<T> request)
throws ServerException, ClientException;
<T extends AcsResponse> T getAcsResponse(AcsRequest<T> request,
boolean autoRetry, int maxRetryCounts)
throws ServerException, ClientException;
<T extends AcsResponse> T getAcsResponse(AcsRequest<T> request,
IClientProfile profile) throws ServerException, ClientException;
<T extends AcsResponse> T getAcsResponse(AcsRequest<T> request,
String regionId, Credential credential)
throws ServerException, ClientException;
<T extends AcsResponse> T getAcsResponse(AcsRequest<T> request,
String regionId)
throws ServerException, ClientException;
CommonResponse getCommonResponse(CommonRequest request) throws ServerException, ClientException;
<T extends AcsResponse> HttpResponse doAction(AcsRequest<T> request, boolean autoRetry,
int maxRetryCounts, IClientProfile profile)
throws ClientException, ServerException;
void restoreSSLCertificate();
void ignoreSSLCertificate();
void shutdown();
SignatureVersion getSignatureVersion();
void setSignatureVersion(SignatureVersion signatureVersion);
SignatureAlgorithm getSignatureAlgorithm();
void setSignatureAlgorithm(SignatureAlgorithm signatureAlgorithm);
RetryPolicy getSysRetryPolicy();
void setSysRetryPolicy(RetryPolicy retryPolicy);
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/RoaAcsRequest.java
|
package com.aliyuncs;
import com.aliyuncs.auth.*;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.HttpRequest;
import com.aliyuncs.regions.ProductDomain;
import com.aliyuncs.utils.ParameterHelper;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static com.aliyuncs.auth.AcsURLEncoder.hexEncode;
public abstract class RoaAcsRequest<T extends AcsResponse> extends AcsRequest<T> {
protected String uriPattern = null;
private Map<String, String> pathParameters = new HashMap<String, String>();
public RoaAcsRequest(String product) {
super(product);
initialize();
}
public RoaAcsRequest(String product, String version, String action) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
initialize();
}
public RoaAcsRequest(String product, String version, String action, SignatureVersion signatureVersion) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysSignatureVersion(signatureVersion);
initialize();
}
public RoaAcsRequest(String product, String version, String action, String locationProduct) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
initialize();
}
public RoaAcsRequest(String product, String version, String action, String locationProduct, SignatureVersion signatureVersion) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
this.setSysSignatureVersion(signatureVersion);
initialize();
}
public RoaAcsRequest(String product, String version, String action, String locationProduct, String endpointType) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
this.setSysEndpointType(endpointType);
initialize();
}
public RoaAcsRequest(String product, String version, String action, String locationProduct, String endpointType, SignatureVersion signatureVersion) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
this.setSysEndpointType(endpointType);
this.setSysSignatureVersion(signatureVersion);
initialize();
}
private void initialize() {
this.composer = RoaSignatureComposer.getComposer();
this.setHttpContentType(FormatType.FORM);
this.setHttpContent(new byte[0], "utf-8", null);
}
@Override
public void setVersion(String version) {
super.setVersion(version);
this.putHeaderParameter("x-acs-version", version);
}
@Override
public void setSecurityToken(String securityToken) {
super.setSecurityToken(securityToken);
this.putHeaderParameter("x-acs-security-token", securityToken);
}
@Override
public void setSysVersion(String version) {
super.setSysVersion(version);
this.putHeaderParameter("x-acs-version", version);
}
public Map<String, String> getPathParameters() {
return Collections.unmodifiableMap(pathParameters);
}
protected void putPathParameter(String name, Object value) {
setParameter(this.pathParameters, name, value);
}
protected void putPathParameter(String name, String value) {
setParameter(this.pathParameters, name, value);
}
@Override
public String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException {
Map<String, String> mapQueries = (queries == null) ? this.getSysQueryParameters() : queries;
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(this.getSysProtocol().toString());
urlBuilder.append("://").append(endpoint);
if (null != this.uriPattern) {
urlBuilder.append(RoaSignatureComposer.replaceOccupiedParameters(uriPattern, this.getPathParameters()));
}
if (-1 == urlBuilder.indexOf("?")) {
urlBuilder.append("?");
} else if (!urlBuilder.toString().endsWith("?")) {
urlBuilder.append("&");
}
String query = concatQueryString(mapQueries);
String url = urlBuilder.append(query).toString();
if (url.endsWith("?") || url.endsWith("&")) {
url = url.substring(0, url.length() - 1);
}
return url;
}
/**
* @Deprecated : Use getSysUriPattern instead of this
*/
@Deprecated
public String getUriPattern() {
return uriPattern;
}
/**
* @Deprecated : Use setSysUriPattern instead of this
*/
@Deprecated
public void setUriPattern(String uriPattern) {
this.uriPattern = uriPattern;
}
public String getSysUriPattern() {
return uriPattern;
}
public void setSysUriPattern(String uriPattern) {
this.uriPattern = uriPattern;
}
@Override
public HttpRequest signRequest(Signer signer, AlibabaCloudCredentials credentials, FormatType format,
ProductDomain domain) throws IllegalStateException,
UnsupportedEncodingException, NoSuchAlgorithmException {
this.resolveSignatureComposer();
Map<String, String> bodyParams = this.getSysBodyParameters();
String hashedRequestPayload = hexEncode(signer != null ? signer.hash("".getBytes("UTF-8")) : null);
if (bodyParams != null && !bodyParams.isEmpty()) {
byte[] data;
if (FormatType.JSON == this.getHttpContentType()) {
data = ParameterHelper.getJsonData(bodyParams);
} else if (FormatType.XML == this.getHttpContentType()) {
data = ParameterHelper.getXmlData(bodyParams);
} else {
// For contentType RAW and Form, the actual data format will be form
data = ParameterHelper.getFormData(bodyParams);
}
this.setHttpContent(data, "UTF-8", null);
hashedRequestPayload = hexEncode(signer != null ? signer.hash(data) : null);
}
Map<String, String> imutableMap = this.composer.refreshSignParameters(this.getSysHeaders(), signer, null,
format);
if (imutableMap.get("RegionId") == null) {
imutableMap.put("RegionId", getSysRegionId());
}
if (null != signer && null != credentials && !(credentials instanceof AnonymousCredentials)) {
if (credentials instanceof BearerTokenCredentials) {
String bearerToken = ((BearerTokenCredentials) credentials).getBearerToken();
if (null != bearerToken) {
imutableMap.put("x-acs-bearer-token", bearerToken);
imutableMap.put("x-acs-signature-type", "BEARERTOKEN");
}
} else if (credentials instanceof IDTokenCredentials) {
String idToken = ((IDTokenCredentials) credentials).getIDToken();
if (null != idToken) {
imutableMap.put("x-acs-zero-trust-idtoken", idToken);
}
} else {
String accessKeyId = credentials.getAccessKeyId();
if (credentials instanceof BasicSessionCredentials) {
String sessionToken = ((BasicSessionCredentials) credentials).getSessionToken();
if (null != sessionToken) {
imutableMap.put("x-acs-accesskey-id", accessKeyId);
imutableMap.put("x-acs-security-token", sessionToken);
}
}
if (signer.getContent() != null && hashedRequestPayload != null) {
imutableMap.put(signer.getContent(), hashedRequestPayload);
}
String strToSign = this.composer.composeStringToSign(this.getSysMethod(), this.getSysUriPattern(), signer,
this.getSysQueryParameters(), imutableMap, this.getPathParameters());
if (this.getSysSignatureVersion() == SignatureVersion.V3) {
strToSign += "\n" + hashedRequestPayload;
strToSign = signer.getSignerName() + "\n" + hexEncode(signer.hash(strToSign.getBytes("UTF-8")));
}
this.strToSign = strToSign;
String signature = signer.signString(strToSign, credentials);
imutableMap.put("Authorization", this.composer.getAuthorization(signer, accessKeyId, signature)
+ (this.getSysSignatureVersion() == SignatureVersion.V3 ? ",SignedHeaders=" + this.getSysSignedHeaders(imutableMap) : ""));
}
}
this.setSysUrl(this.composeUrl(domain.getDomainName(), this.getSysQueryParameters()));
this.headers = imutableMap;
return this;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/RpcAcsRequest.java
|
package com.aliyuncs;
import com.aliyuncs.auth.*;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.HttpRequest;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.regions.ProductDomain;
import com.aliyuncs.utils.ParameterHelper;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import static com.aliyuncs.auth.AcsURLEncoder.hexEncode;
public abstract class RpcAcsRequest<T extends AcsResponse> extends AcsRequest<T> {
public RpcAcsRequest(String product) {
super(product);
initialize();
}
public RpcAcsRequest(String product, String version, String action) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
initialize();
}
public RpcAcsRequest(String product, String version, String action, SignatureVersion signatureVersion) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysSignatureVersion(signatureVersion);
initialize();
}
public RpcAcsRequest(String product, String version, String action, String locationProduct) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
initialize();
}
public RpcAcsRequest(String product, String version, String action, String locationProduct, SignatureVersion signatureVersion) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
this.setSysSignatureVersion(signatureVersion);
initialize();
}
public RpcAcsRequest(String product, String version, String action, String locationProduct, String endpointType) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
this.setSysEndpointType(endpointType);
initialize();
}
public RpcAcsRequest(String product, String version, String action, String locationProduct, String endpointType, SignatureVersion signatureVersion) {
super(product);
this.setSysVersion(version);
this.setSysActionName(action);
this.setSysLocationProduct(locationProduct);
this.setSysEndpointType(endpointType);
this.setSysSignatureVersion(signatureVersion);
initialize();
}
private void initialize() {
this.setSysMethod(MethodType.GET);
this.setSysAcceptFormat(FormatType.JSON);
this.setHttpContentType(FormatType.FORM);
this.composer = RpcSignatureComposer.getComposer();
}
@Override
public void setActionName(String actionName) {
super.setActionName(actionName);
this.putQueryParameter("Action", actionName);
}
@Override
public void setVersion(String version) {
super.setVersion(version);
this.putQueryParameter("Version", version);
}
@Override
public void setSecurityToken(String securityToken) {
super.setSecurityToken(securityToken);
this.putQueryParameter("SecurityToken", securityToken);
}
@Override
public void setAcceptFormat(FormatType acceptFormat) {
super.setAcceptFormat(acceptFormat);
this.putQueryParameter("Format", acceptFormat.toString());
}
@Override
public void setSysActionName(String actionName) {
super.setSysActionName(actionName);
this.putQueryParameter("Action", actionName);
}
@Override
public void setSysVersion(String version) {
super.setSysVersion(version);
this.putQueryParameter("Version", version);
}
@Override
public void setSysAcceptFormat(FormatType acceptFormat) {
super.setSysAcceptFormat(acceptFormat);
this.putQueryParameter("Format", acceptFormat.toString());
}
@Override
public void setSysSecurityToken(String securityToken) {
super.setSysSecurityToken(securityToken);
this.putQueryParameter("SecurityToken", securityToken);
}
@Override
public String composeUrl(String endpoint, Map<String, String> queries) throws UnsupportedEncodingException {
Map<String, String> mapQueries = (queries == null) ? this.getSysQueryParameters() : queries;
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(this.getSysProtocol().toString());
urlBuilder.append("://").append(endpoint);
if (-1 == urlBuilder.indexOf("?")) {
urlBuilder.append("/?");
}
String query = concatQueryString(mapQueries);
return urlBuilder.append(query).toString();
}
@Override
public HttpRequest signRequest(Signer signer, AlibabaCloudCredentials credentials, FormatType format,
ProductDomain domain) throws InvalidKeyException, IllegalStateException,
UnsupportedEncodingException, NoSuchAlgorithmException {
this.resolveSignatureComposer();
Map<String, String> headerMap = new HashMap<String, String>();
Map<String, String> bodyParams = this.getSysBodyParameters();
String hashedRequestPayload = hexEncode(signer != null ? signer.hash("".getBytes("UTF-8")) : null);
if (bodyParams != null && !bodyParams.isEmpty()) {
byte[] data;
if (FormatType.JSON == this.getHttpContentType()) {
data = ParameterHelper.getJsonData(bodyParams);
} else if (FormatType.XML == this.getHttpContentType()) {
data = ParameterHelper.getXmlData(bodyParams);
} else {
// For contentType RAW and Form, the actual data format will be form
data = ParameterHelper.getFormData(bodyParams);
}
this.setHttpContent(data, "UTF-8", null);
hashedRequestPayload = hexEncode(signer != null ? signer.hash(data) : null);
}
Map<String, String> imutableMap = this.composer.refreshSignParameters(this.getSysQueryParameters(), signer, null,
format);
headerMap.putAll(this.getSysHeaders());
headerMap = this.composer.refreshSignParameters(headerMap, signer, null, null);
if (imutableMap.get("RegionId") == null && this.getSysRegionId() != null && !this.getSysRegionId().isEmpty()) {
if ((bodyParams == null || bodyParams.get("RegionId") == null)) {
imutableMap.put("RegionId", getSysRegionId());
}
}
if (null != signer && null != credentials && !(credentials instanceof AnonymousCredentials)) {
if (credentials instanceof BearerTokenCredentials) {
String bearerToken = ((BearerTokenCredentials) credentials).getBearerToken();
if (null != bearerToken) {
imutableMap.put("BearerToken", bearerToken);
imutableMap.put("SignatureType", "BEARERTOKEN");
headerMap.put("x-acs-bearer-token", bearerToken);
}
} else if (credentials instanceof IDTokenCredentials) {
String idToken = ((IDTokenCredentials) credentials).getIDToken();
if (null != idToken) {
headerMap.put("x-acs-zero-trust-idtoken", idToken);
}
} else {
String accessKeyId = credentials.getAccessKeyId();
String accessSecret = credentials.getAccessKeySecret();
if (credentials instanceof BasicSessionCredentials) {
String sessionToken = ((BasicSessionCredentials) credentials).getSessionToken();
if (null != sessionToken) {
imutableMap.put("SecurityToken", sessionToken);
headerMap.put("x-acs-security-token", sessionToken);
}
}
if (signer.getContent() != null && hashedRequestPayload != null) {
headerMap.put(signer.getContent(), hashedRequestPayload);
}
imutableMap.put("AccessKeyId", accessKeyId);
if (this.getSysSignatureVersion() == SignatureVersion.V3) {
String strToSign = this.composer.composeStringToSign(this.getSysMethod(), null, signer,
this.getSysQueryParameters(), headerMap, null) + "\n" + hashedRequestPayload;
this.strToSign = strToSign;
strToSign = signer.getSignerName() + "\n" + hexEncode(signer.hash(strToSign.getBytes("UTF-8")));
String signature = signer.signString(strToSign, accessSecret);
headerMap.put("Authorization", this.composer.getAuthorization(signer, accessKeyId, signature)
+ ",SignedHeaders=" + this.getSysSignedHeaders(headerMap));
imutableMap = this.getSysQueryParameters();
} else {
Map<String, String> paramsToSign = new HashMap<String, String>();
paramsToSign.putAll(bodyParams);
paramsToSign.putAll(imutableMap);
String strToSign = this.composer.composeStringToSign(
this.getSysMethod(), null, signer, paramsToSign, null, null);
this.strToSign = strToSign;
String signature;
if (credentials instanceof KeyPairCredentials) {
signature = signer.signString(strToSign, credentials);
} else {
signature = signer.signString(strToSign, accessSecret + "&");
}
imutableMap.put("Signature", this.composer.getAuthorization(signer, accessKeyId, signature));
headerMap.clear();
headerMap.putAll(this.getSysHeaders());
}
}
}
this.setSysUrl(this.composeUrl(domain.getDomainName(), imutableMap));
this.headers = headerMap;
return this;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/AcsURLEncoder.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
public class AcsURLEncoder {
public final static String URL_ENCODING = "UTF-8";
public static String encode(String value) throws UnsupportedEncodingException {
return URLEncoder.encode(value, URL_ENCODING).replace("+", "%20");
}
public static String percentEncode(String value) throws UnsupportedEncodingException {
return value != null ? URLEncoder.encode(value, URL_ENCODING).replace("+", "%20")
.replace("*", "%2A").replace("%7E", "~") : null;
}
public static String hexEncode(byte[] raw) {
if (raw == null) {
return null;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < raw.length; i++) {
String hex = Integer.toHexString(raw[i] & 0xFF);
if (hex.length() < 2) {
sb.append(0);
}
sb.append(hex);
}
return sb.toString();
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/AlibabaCloudCredentials.java
|
package com.aliyuncs.auth;
public interface AlibabaCloudCredentials {
String getAccessKeyId();
String getAccessKeySecret();
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/AlibabaCloudCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
public interface AlibabaCloudCredentialsProvider {
AlibabaCloudCredentials getCredentials() throws ClientException, ServerException;
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/AnonymousCredentials.java
|
package com.aliyuncs.auth;
public class AnonymousCredentials implements AlibabaCloudCredentials {
@Override
public String getAccessKeyId() {
return null;
}
@Override
public String getAccessKeySecret() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/AuthConstant.java
|
package com.aliyuncs.auth;
public class AuthConstant {
public static final String SYSTEM_ACCESSKEYID = "alibabacloud.accessKeyId";
public static final String SYSTEM_ACCESSKEYSECRET = "alibabacloud.accessKeyIdSecret";
public static final String SYSTEM_ACCESSKEY_SECRET = "alibabacloud.accessKeySecret";
public static final String SYSTEM_SESSION_TOKEN = "alibabacloud.sessionToken";
public static final String DEFAULT_CREDENTIALS_FILE_PATH = System.getProperty("user.home") +
"/.alibabacloud/credentials.ini";
public static final String INI_ACCESS_KEY_ID = "access_key_id";
public static final String INI_ACCESS_KEY_IDSECRET = "access_key_secret";
public static final String INI_TYPE = "type";
public static final String INI_TYPE_RAM = "ecs_ram_role";
public static final String INI_TYPE_ARN = "ram_role_arn";
public static final String INI_TYPE_OIDC = "oidc_role_arn";
public static final String INI_TYPE_KEY_PAIR = "rsa_key_pair";
public static final String INI_PUBLIC_KEY_ID = "public_key_id";
public static final String INI_PRIVATE_KEY_FILE = "private_key_file";
public static final String INI_PRIVATE_KEY = "private_key";
public static final String INI_ROLE_NAME = "role_name";
public static final String INI_ROLE_SESSION_NAME = "role_session_name";
public static final String INI_ROLE_ARN = "role_arn";
public static final String INI_POLICY = "policy";
public static final String INI_OIDC_PROVIDER_ARN = "oidc_provider_arn";
public static final String INI_OIDC_TOKEN_FILE_PATH = "oidc_token_file_path";
public static final long TSC_VALID_TIME_SECONDS = 3600L;
public static final String DEFAULT_REGION = "region_id";
public static final String INI_ENABLE = "enable";
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/BasicCredentials.java
|
package com.aliyuncs.auth;
public class BasicCredentials implements AlibabaCloudCredentials {
private final String accessKeyId;
private final String accessKeySecret;
public BasicCredentials(String accessKeyId, String accessKeySecret) {
if (accessKeyId == null) {
throw new IllegalArgumentException("Access key ID cannot be null.");
}
if (accessKeySecret == null) {
throw new IllegalArgumentException("Access key secret cannot be null.");
}
this.accessKeyId = accessKeyId;
this.accessKeySecret = accessKeySecret;
}
@Override
public String getAccessKeyId() {
return accessKeyId;
}
@Override
public String getAccessKeySecret() {
return accessKeySecret;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/BasicSessionCredentials.java
|
package com.aliyuncs.auth;
public class BasicSessionCredentials implements AlibabaCloudCredentials {
protected final long roleSessionDurationSeconds;
private final String accessKeyId;
private final String accessKeySecret;
private final String sessionToken;
private long sessionStartedTimeInMilliSeconds;
public BasicSessionCredentials(String accessKeyId, String accessKeySecret, String sessionToken) {
this(accessKeyId, accessKeySecret, sessionToken, 0);
}
public BasicSessionCredentials(String accessKeyId, String accessKeySecret, String sessionToken,
long roleSessionDurationSeconds) {
if (accessKeyId == null) {
throw new IllegalArgumentException("Access key ID cannot be null.");
}
if (accessKeySecret == null) {
throw new IllegalArgumentException("Access key secret cannot be null.");
}
this.accessKeyId = accessKeyId;
this.accessKeySecret = accessKeySecret;
this.sessionToken = sessionToken;
this.roleSessionDurationSeconds = roleSessionDurationSeconds;
this.sessionStartedTimeInMilliSeconds = System.currentTimeMillis();
}
@Override
public String getAccessKeyId() {
return accessKeyId;
}
@Override
public String getAccessKeySecret() {
return accessKeySecret;
}
public String getSessionToken() {
return sessionToken;
}
public boolean willSoonExpire() {
if (roleSessionDurationSeconds == 0) {
return false;
}
long now = System.currentTimeMillis();
double expireFact = 0.95;
return roleSessionDurationSeconds * expireFact < (now - sessionStartedTimeInMilliSeconds) / 1000.0;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/BearerTokenCredentials.java
|
package com.aliyuncs.auth;
public class BearerTokenCredentials implements AlibabaCloudCredentials {
private String bearerToken;
public BearerTokenCredentials(String bearerToken) {
this.bearerToken = bearerToken;
}
@Override
public String getAccessKeyId() {
return null;
}
@Override
public String getAccessKeySecret() {
return null;
}
public String getBearerToken() {
return bearerToken;
}
public void setBearerToken(String bearerToken) {
this.bearerToken = bearerToken;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/BearerTokenSigner.java
|
package com.aliyuncs.auth;
import java.security.NoSuchAlgorithmException;
@Deprecated
public class BearerTokenSigner extends Signer {
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return null;
}
@Override
public String signString(String stringToSign, String accessKeySecret) {
return null;
}
@Override
public String getSignerName() {
return null;
}
@Override
public String getSignerVersion() {
return null;
}
@Override
public String getSignerType() {
return "BEARERTOKEN";
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
return null;
}
@Override
public String getContent() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/CLIProfileCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.StringUtils;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
public class CLIProfileCredentialsProvider implements AlibabaCloudCredentialsProvider {
private final String CLI_CREDENTIALS_CONFIG_PATH = System.getProperty("user.home") +
"/.aliyun/config.json";
private volatile AlibabaCloudCredentialsProvider credentialsProvider;
private volatile String currentProfileName;
private final Object credentialsProviderLock = new Object();
private CLIProfileCredentialsProvider(Builder builder) {
this.currentProfileName = builder.profileName == null ? System.getenv("ALIBABA_CLOUD_PROFILE") : builder.profileName;
}
public static Builder builder() {
return new Builder();
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
if (AuthUtils.isDisableCLIProfile()) {
throw new ClientException("CLI credentials file is disabled.");
}
Config config = null;
try {
config = parseProfile(CLI_CREDENTIALS_CONFIG_PATH);
} catch (IOException e) {
throw new ClientException("Unable to get profile from CLI credentials file: " + e);
}
if (null == config) {
throw new ClientException("Unable to get profile from empty CLI credentials file.");
}
String refreshedProfileName = System.getenv("ALIBABA_CLOUD_PROFILE");
if (shouldReloadCredentialsProvider(refreshedProfileName)) {
synchronized (credentialsProviderLock) {
if (shouldReloadCredentialsProvider(refreshedProfileName)) {
if (!StringUtils.isEmpty(refreshedProfileName)) {
this.currentProfileName = refreshedProfileName;
}
this.credentialsProvider = reloadCredentialsProvider(config, this.currentProfileName);
}
}
}
return this.credentialsProvider.getCredentials();
}
AlibabaCloudCredentialsProvider reloadCredentialsProvider(Config config, String profileName) throws ClientException {
String currentProfileName = !StringUtils.isEmpty(profileName) ? profileName : config.getCurrent();
List<Profile> profiles = config.getProfiles();
if (profiles != null && !profiles.isEmpty()) {
for (Profile profile : profiles) {
if (!StringUtils.isEmpty(profile.getName()) && profile.getName().equals(currentProfileName)) {
String mode = profile.getMode();
if ("AK".equals(mode)) {
return new StaticCredentialsProvider(
new BasicCredentials(profile.getAccessKeyId(), profile.getAccessKeySecret()));
} else if ("StsToken".equals(mode)) {
return new StaticCredentialsProvider(
new BasicSessionCredentials(profile.getAccessKeyId(), profile.getAccessKeySecret(), profile.getSecurityToken()));
} else if ("RamRoleArn".equals(mode)) {
AlibabaCloudCredentialsProvider innerProvider = new StaticCredentialsProvider(
new BasicCredentials(profile.getAccessKeyId(), profile.getAccessKeySecret()));
return STSAssumeRoleSessionCredentialsProvider.builder()
.credentialsProvider(innerProvider)
.durationSeconds(profile.getDurationSeconds())
.roleArn(profile.getRoleArn())
.roleSessionName(profile.getRoleSessionName())
.stsRegionId(profile.getStsRegionId())
.enableVpc(profile.getEnableVpc())
.policy(profile.getPolicy())
.externalId(profile.getExternalId())
.build();
} else if ("EcsRamRole".equals(mode)) {
return InstanceProfileCredentialsProvider.builder()
.roleName(profile.getRamRoleName())
.build();
} else if ("OIDC".equals(mode)) {
return OIDCCredentialsProvider.builder()
.durationSeconds(profile.getDurationSeconds())
.roleArn(profile.getRoleArn())
.roleSessionName(profile.getRoleSessionName())
.oidcProviderArn(profile.getOidcProviderArn())
.oidcTokenFilePath(profile.getOidcTokenFile())
.stsRegionId(profile.getStsRegionId())
.enableVpc(profile.getEnableVpc())
.policy(profile.getPolicy())
.build();
} else if ("ChainableRamRoleArn".equals(mode)) {
AlibabaCloudCredentialsProvider previousProvider = reloadCredentialsProvider(config, profile.getSourceProfile());
return STSAssumeRoleSessionCredentialsProvider.builder()
.credentialsProvider(previousProvider)
.durationSeconds(profile.getDurationSeconds())
.roleArn(profile.getRoleArn())
.roleSessionName(profile.getRoleSessionName())
.stsRegionId(profile.getStsRegionId())
.enableVpc(profile.getEnableVpc())
.policy(profile.getPolicy())
.externalId(profile.getExternalId())
.build();
} else {
throw new ClientException(String.format("Unsupported profile mode '%s' form CLI credentials file.", mode));
}
}
}
}
throw new ClientException(String.format("Unable to get profile with '%s' form CLI credentials file.", currentProfileName));
}
Config parseProfile(String configFilePath) throws ClientException, IOException {
File configFile = new File(configFilePath);
if (!configFile.exists() || !configFile.isFile() || !configFile.canRead()) {
throw new ClientException(String.format("Unable to open credentials file: %s.", configFile.getAbsolutePath()));
}
Gson gson = new Gson();
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(configFile));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
String jsonContent = sb.toString();
return gson.fromJson(jsonContent, Config.class);
} catch (Exception e) {
throw new ClientException(String.format("Failed to parse credential form CLI credentials file: %s.", configFile.getAbsolutePath()));
} finally {
if (br != null) {
br.close();
}
}
}
boolean shouldReloadCredentialsProvider(String profileName) {
return this.credentialsProvider == null || (!StringUtils.isEmpty(this.currentProfileName) && !StringUtils.isEmpty(profileName) && !this.currentProfileName.equals(profileName));
}
String getProfileName() {
return this.currentProfileName;
}
static final class Builder {
private String profileName;
public Builder profileName(String profileName) {
this.profileName = profileName;
return this;
}
CLIProfileCredentialsProvider build() {
return new CLIProfileCredentialsProvider(this);
}
}
static class Config {
@SerializedName("current")
private String current;
@SerializedName("profiles")
private List<Profile> profiles;
public String getCurrent() {
return current;
}
public List<Profile> getProfiles() {
return profiles;
}
}
static class Profile {
@SerializedName("name")
private String name;
@SerializedName("mode")
private String mode;
@SerializedName("access_key_id")
private String accessKeyId;
@SerializedName("access_key_secret")
private String accessKeySecret;
@SerializedName("sts_token")
private String securityToken;
@SerializedName("ram_role_arn")
private String roleArn;
@SerializedName("ram_session_name")
private String roleSessionName;
@SerializedName("expired_seconds")
private Integer durationSeconds;
@SerializedName("sts_region")
private String stsRegionId;
@SerializedName("enable_vpc")
private Boolean enableVpc;
@SerializedName("ram_role_name")
private String ramRoleName;
@SerializedName("oidc_token_file")
private String oidcTokenFile;
@SerializedName("oidc_provider_arn")
private String oidcProviderArn;
@SerializedName("source_profile")
private String sourceProfile;
@SerializedName("policy")
private String policy;
@SerializedName("external_id")
private String externalId;
public String getName() {
return name;
}
public String getMode() {
return mode;
}
public String getAccessKeyId() {
return accessKeyId;
}
public String getAccessKeySecret() {
return accessKeySecret;
}
public String getSecurityToken() {
return securityToken;
}
public String getRoleArn() {
return roleArn;
}
public String getRoleSessionName() {
return roleSessionName;
}
public Integer getDurationSeconds() {
return durationSeconds;
}
public String getStsRegionId() {
return stsRegionId;
}
public Boolean getEnableVpc() {
return enableVpc;
}
public String getRamRoleName() {
return ramRoleName;
}
public String getOidcTokenFile() {
return oidcTokenFile;
}
public String getOidcProviderArn() {
return oidcProviderArn;
}
public String getSourceProfile() {
return sourceProfile;
}
public String getPolicy() {
return policy;
}
public String getExternalId() {
return externalId;
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/Credential.java
|
package com.aliyuncs.auth;
import java.util.Calendar;
import java.util.Date;
@Deprecated
public class Credential {
private final Date refreshDate;
private Date expiredDate;
private String accessKeyId;
private String accessSecret;
private String securityToken;
public Credential() {
this.refreshDate = new Date();
}
public Credential(String keyId, String secret) {
this.accessKeyId = keyId;
this.accessSecret = secret;
this.refreshDate = new Date();
}
public Credential(String keyId, String secret, String securityToken) {
this.accessKeyId = keyId;
this.accessSecret = secret;
this.securityToken = securityToken;
this.refreshDate = new Date();
}
public Credential(String keyId, String secret, int expiredHours) {
this.accessKeyId = keyId;
this.accessSecret = secret;
this.refreshDate = new Date();
setExpiredDate(expiredHours);
}
public Credential(String keyId, String secret, String securityToken, int expiredHours) {
this.accessKeyId = keyId;
this.accessSecret = secret;
this.securityToken = securityToken;
this.refreshDate = new Date();
setExpiredDate(expiredHours);
}
public String getAccessKeyId() {
return accessKeyId;
}
public void setAccessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
}
public String getAccessSecret() {
return accessSecret;
}
public void setAccessSecret(String accessSecret) {
this.accessSecret = accessSecret;
}
public boolean isExpired() {
return this.expiredDate == null || this.expiredDate.after(new Date());
}
public String getSecurityToken() {
return securityToken;
}
public void setSecurityToken(String securityToken) {
this.securityToken = securityToken;
}
public Date getRefreshDate() {
return refreshDate;
}
public Date getExpiredDate() {
return expiredDate;
}
private void setExpiredDate(int expiredHours) {
if (expiredHours > 0) {
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.HOUR, expiredHours);
expiredDate = cal.getTime();
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/CredentialsBackupCompatibilityAdaptor.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
@Deprecated
public class CredentialsBackupCompatibilityAdaptor extends Credential {
private final AlibabaCloudCredentialsProvider provider;
public CredentialsBackupCompatibilityAdaptor(AlibabaCloudCredentialsProvider provider) {
this.provider = provider;
}
private AlibabaCloudCredentials getCredentials() {
try {
AlibabaCloudCredentials credentials = this.provider.getCredentials();
return credentials;
} catch (ClientException e) {
throw new RuntimeException(e.toString());
}
}
@Override
public String getAccessKeyId() {
return getCredentials().getAccessKeyId();
}
@Override
public String getAccessSecret() {
return getCredentials().getAccessKeySecret();
}
@Override
public boolean isExpired() {
return false;
}
@Override
public String getSecurityToken() {
AlibabaCloudCredentials credentials = getCredentials();
if (credentials instanceof BasicSessionCredentials) {
return ((BasicSessionCredentials) credentials).getSessionToken();
} else {
return null;
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/CredentialsProviderFactory.java
|
package com.aliyuncs.auth;
public class CredentialsProviderFactory {
public <T extends AlibabaCloudCredentialsProvider> T createCredentialsProvider(T classInstance) {
return classInstance;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/DefaultCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
public class DefaultCredentialsProvider implements AlibabaCloudCredentialsProvider {
private List<AlibabaCloudCredentialsProvider> defaultProviders = new ArrayList<AlibabaCloudCredentialsProvider>();
private static final List<AlibabaCloudCredentialsProvider> USER_CONFIGURATION_PROVIDERS =
new Vector<AlibabaCloudCredentialsProvider>();
private volatile AlibabaCloudCredentialsProvider lastUsedCredentialsProvider;
private final Boolean reuseLastProviderEnabled;
public DefaultCredentialsProvider() throws ClientException {
this.reuseLastProviderEnabled = true;
createDefaultChain();
}
private DefaultCredentialsProvider(Builder builder) {
this.reuseLastProviderEnabled = builder.reuseLastProviderEnabled;
createDefaultChain();
}
public static Builder builder() {
return new Builder();
}
private void createDefaultChain() {
defaultProviders.add(new SystemPropertiesCredentialsProvider());
defaultProviders.add(new EnvironmentVariableCredentialsProvider());
if (AuthUtils.environmentEnableOIDC()) {
defaultProviders.add(OIDCCredentialsProvider.builder().build());
}
defaultProviders.add(CLIProfileCredentialsProvider.builder().build());
defaultProviders.add(new ProfileCredentialsProvider());
if (!AuthUtils.isDisableECSMetaData()) {
defaultProviders.add(InstanceProfileCredentialsProvider.builder().build());
}
String uri = AuthUtils.getEnvironmentCredentialsURI();
if (!StringUtils.isEmpty(uri)) {
defaultProviders.add(URLCredentialsProvider.builder()
.credentialsURI(uri)
.build());
}
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
if (this.reuseLastProviderEnabled && this.lastUsedCredentialsProvider != null) {
return this.lastUsedCredentialsProvider.getCredentials();
}
AlibabaCloudCredentials credential;
List<String> errorMessages = new ArrayList<String>();
if (USER_CONFIGURATION_PROVIDERS.size() > 0) {
for (AlibabaCloudCredentialsProvider provider : USER_CONFIGURATION_PROVIDERS) {
try {
credential = provider.getCredentials();
if (null != credential) {
this.lastUsedCredentialsProvider = provider;
return credential;
}
} catch (Exception e) {
errorMessages.add(provider.getClass().getName() + ": " + e.getMessage());
}
}
}
for (AlibabaCloudCredentialsProvider provider : defaultProviders) {
try {
credential = provider.getCredentials();
if (null != credential) {
this.lastUsedCredentialsProvider = provider;
return credential;
}
} catch (Exception e) {
errorMessages.add(provider.getClass().getName() + ": " + e.getMessage());
}
}
throw new ClientException("Unable to load credentials from any of the providers in the chain: " + errorMessages);
}
public static boolean addCredentialsProvider(AlibabaCloudCredentialsProvider provider) {
return DefaultCredentialsProvider.USER_CONFIGURATION_PROVIDERS.add(provider);
}
public static boolean removeCredentialsProvider(AlibabaCloudCredentialsProvider provider) {
return DefaultCredentialsProvider.USER_CONFIGURATION_PROVIDERS.remove(provider);
}
public static boolean containsCredentialsProvider(AlibabaCloudCredentialsProvider provider) {
return DefaultCredentialsProvider.USER_CONFIGURATION_PROVIDERS.contains(provider);
}
public static void clearCredentialsProvider() {
DefaultCredentialsProvider.USER_CONFIGURATION_PROVIDERS.clear();
}
public static final class Builder {
private Boolean reuseLastProviderEnabled = true;
public Builder reuseLastProviderEnabled(Boolean reuseLastProviderEnabled) {
this.reuseLastProviderEnabled = reuseLastProviderEnabled;
return this;
}
DefaultCredentialsProvider build() {
return new DefaultCredentialsProvider(this);
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/ECSMetadataServiceCredentialsFetcher.java
|
package com.aliyuncs.auth;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.HttpRequest;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.http.clients.CompatibleUrlConnClient;
import com.aliyuncs.utils.StringUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class ECSMetadataServiceCredentialsFetcher {
private static final String URL_IN_ECS_METADATA = "/latest/meta-data/ram/security-credentials/";
private static final String URL_IN_METADATA_TOKEN = "/latest/api/token";
private static final int DEFAULT_TIMEOUT_IN_MILLISECONDS = 1000;
private static final String ECS_METADATA_FETCH_ERROR_MSG = "Failed to get RAM session credentials from ECS metadata service.";
private static final int DEFAULT_ECS_SESSION_TOKEN_DURATION_SECONDS = 3600 * 6;
private URL credentialUrl;
private String roleName;
private String metadataServiceHost = "100.100.100.200";
private final boolean disableIMDSv1;
private final int metadataTokenDuration = 21600;
private int connectionTimeout;
private int readTimeout;
public ECSMetadataServiceCredentialsFetcher() {
this.connectionTimeout = DEFAULT_TIMEOUT_IN_MILLISECONDS;
this.readTimeout = DEFAULT_TIMEOUT_IN_MILLISECONDS;
this.disableIMDSv1 = false;
}
public ECSMetadataServiceCredentialsFetcher(String roleName, Boolean disableIMDSv1, Integer connectionTimeout, Integer readTimeout) {
this.connectionTimeout = connectionTimeout == null ? 1000 : connectionTimeout;
this.readTimeout = readTimeout == null ? 1000 : readTimeout;
this.disableIMDSv1 = disableIMDSv1 == null ? false : disableIMDSv1;
this.roleName = roleName;
}
@Deprecated
public void setRoleName(String roleName) {
if (null == roleName) {
throw new IllegalArgumentException("You must specify a valid role name.");
}
this.roleName = roleName;
setCredentialUrl();
}
private void setCredentialUrl() {
try {
this.credentialUrl = new URL("http://" + metadataServiceHost + URL_IN_ECS_METADATA + roleName);
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Deprecated
public ECSMetadataServiceCredentialsFetcher withECSMetadataServiceHost(String host) {
System.err.println("withECSMetadataServiceHost() method is only for testing, please don't use it");
this.metadataServiceHost = host;
setCredentialUrl();
return this;
}
@Deprecated
public ECSMetadataServiceCredentialsFetcher withConnectionTimeout(int milliseconds) {
this.connectionTimeout = milliseconds;
this.readTimeout = milliseconds;
return this;
}
@Deprecated
public String getMetadata() throws ClientException {
return getMetadata(credentialUrl.toString());
}
private String getMetadata(String url) throws ClientException {
HttpRequest request = new HttpRequest(url);
request.setSysMethod(MethodType.GET);
request.setSysConnectTimeout(connectionTimeout);
request.setSysReadTimeout(readTimeout);
String metadataToken = this.getMetadataToken();
if (metadataToken != null) {
request.putHeaderParameter("X-aliyun-ecs-metadata-token", metadataToken);
}
HttpResponse response;
try {
response = CompatibleUrlConnClient.compatibleGetResponse(request);
} catch (Exception e) {
throw new ClientException("Failed to connect ECS Metadata Service: " + e.toString());
}
if (response.getStatus() == HttpURLConnection.HTTP_NOT_FOUND) {
throw new ClientException("The role name was not found in the instance.");
}
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
throw new ClientException(ECS_METADATA_FETCH_ERROR_MSG + " HttpCode=" + response.getStatus());
}
return new String(response.getHttpContent());
}
public InstanceProfileCredentials fetch() throws ClientException {
String roleName = this.roleName;
if (StringUtils.isEmpty(this.roleName)) {
roleName = getMetadata("http://" + metadataServiceHost + URL_IN_ECS_METADATA);
}
String jsonContent = getMetadata("http://" + metadataServiceHost + URL_IN_ECS_METADATA + roleName);
JsonObject jsonObject = JsonParser.parseString(jsonContent).getAsJsonObject();
if (!jsonObject.has("Code") || !jsonObject.has("AccessKeyId") || !jsonObject.has("AccessKeySecret") || !jsonObject
.has("SecurityToken") || !jsonObject.has("Expiration")) {
throw new ClientException("Invalid json got from ECS Metadata service.");
}
if (!"Success".equals(jsonObject.get("Code").getAsString())) {
throw new ClientException(ECS_METADATA_FETCH_ERROR_MSG);
}
return new InstanceProfileCredentials(
jsonObject.get("AccessKeyId").getAsString(),
jsonObject.get("AccessKeySecret").getAsString(),
jsonObject.get("SecurityToken").getAsString(),
jsonObject.get("Expiration").getAsString(),
DEFAULT_ECS_SESSION_TOKEN_DURATION_SECONDS);
}
public InstanceProfileCredentials fetch(int retryTimes) throws ClientException {
for (int i = 0; i <= retryTimes; i++) {
try {
return fetch();
} catch (ClientException e) {
if (i == retryTimes) {
throw e;
}
}
}
throw new ClientException("Failed to connect ECS Metadata Service: Max retry times exceeded.");
}
private String getMetadataToken() throws ClientException {
try {
HttpRequest request = new HttpRequest("http://" + metadataServiceHost + URL_IN_METADATA_TOKEN);
request.setSysMethod(MethodType.PUT);
request.setSysConnectTimeout(connectionTimeout);
request.setSysReadTimeout(readTimeout);
request.putHeaderParameter("X-aliyun-ecs-metadata-token-ttl-seconds", String.valueOf(this.metadataTokenDuration));
HttpResponse response;
try {
response = CompatibleUrlConnClient.compatibleGetResponse(request);
;
} catch (Exception e) {
throw new ClientException("Failed to connect ECS Metadata Service: " + e);
}
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
throw new ClientException("Failed to get token from ECS Metadata Service. HttpCode=" + response.getStatus() + ", ResponseMessage=" + response.getHttpContentString());
}
return new String(response.getHttpContent());
} catch (Exception ex) {
return throwErrorOrReturn(ex);
}
}
private String throwErrorOrReturn(Exception e) throws ClientException {
if (this.disableIMDSv1) {
throw new ClientException("Failed to get token from ECS Metadata Service, and fallback to IMDS v1 is disabled via the disableIMDSv1 configuration is turned on. Original error: " + e.getMessage());
}
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/EnvironmentVariableCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.StringUtils;
public class EnvironmentVariableCredentialsProvider implements AlibabaCloudCredentialsProvider {
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
if (!"default".equals(AuthUtils.getClientType())) {
return null;
}
String accessKeyId = AuthUtils.getEnvironmentAccessKeyId();
String accessKeySecret = AuthUtils.getEnvironmentAccessKeySecret();
String securityToken = AuthUtils.getEnvironmentSecurityToken();
if (StringUtils.isEmpty(accessKeyId)) {
throw new ClientException("Environment variable accessKeyId cannot be empty.");
}
if (StringUtils.isEmpty(accessKeySecret)) {
throw new ClientException("Environment variable accessKeySecret cannot be empty.");
}
if (!StringUtils.isEmpty(securityToken)) {
return new BasicSessionCredentials(accessKeyId, accessKeySecret, securityToken);
}
return new BasicCredentials(accessKeyId, accessKeySecret);
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/HmacSHA1Signer.java
|
package com.aliyuncs.auth;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@Deprecated
public class HmacSHA1Signer extends Signer {
public static final String ENCODING = "UTF-8";
private static final String ALGORITHM_NAME = "HmacSHA1";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
Mac mac = Mac.getInstance(ALGORITHM_NAME);
mac.init(new SecretKeySpec(accessKeySecret.getBytes(ENCODING), ALGORITHM_NAME));
byte[] signData = mac.doFinal(stringToSign.getBytes(ENCODING));
return DatatypeConverter.printBase64Binary(signData);
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e.toString());
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return "HMAC-SHA1";
}
@Override
public String getSignerVersion() {
return "1.0";
}
@Override
public String getSignerType() {
return null;
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
return null;
}
@Override
public String getContent() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/ICredentialProvider.java
|
package com.aliyuncs.auth;
@Deprecated
/**
* @Deprecated : Use AlibabaCloudCredentialsProvider instead of this
*/
public interface ICredentialProvider {
Credential fresh();
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/IDTokenCredentials.java
|
package com.aliyuncs.auth;
public class IDTokenCredentials implements AlibabaCloudCredentials {
private String idToken;
public IDTokenCredentials(String idToken) {
this.idToken = idToken;
}
@Override
public String getAccessKeyId() {
return null;
}
@Override
public String getAccessKeySecret() {
return null;
}
public String getIDToken() {
return idToken;
}
public void setIDToken(String idToken) {
this.idToken = idToken;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/ISignatureComposer.java
|
package com.aliyuncs.auth;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.MethodType;
import java.util.Map;
public interface ISignatureComposer {
Map<String, String> refreshSignParameters(Map<String, String> parameters, Signer signer, String accessKeyId,
FormatType format);
String composeStringToSign(MethodType method, String uriPattern, Signer signer, Map<String, String> queries,
Map<String, String> headers, Map<String, String> paths);
String getAuthorization(Signer signer, String accessKeyId, String signature);
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/ISigner.java
|
package com.aliyuncs.auth;
import java.security.InvalidKeyException;
@Deprecated
public interface ISigner {
String getSignerName();
String getSignerVersion();
String signString(String source, String accessSecret) throws InvalidKeyException, IllegalStateException;
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/InstanceProfileCredentials.java
|
package com.aliyuncs.auth;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class InstanceProfileCredentials extends BasicSessionCredentials {
private final long expiration;
private final double expireFact = 0.95;
private final long refreshIntervalInMillSeconds = 180000;
private long lastFailedRefreshTime = 0;
public InstanceProfileCredentials(String accessKeyId, String accessKeySecret, String sessionToken,
String expiration, long roleSessionDurationSeconds) {
super(accessKeyId, accessKeySecret, sessionToken, roleSessionDurationSeconds);
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
parser.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
Date date = parser.parse(expiration.replace('T', ' ').replace('Z', ' '));
this.expiration = date.getTime();
} catch (ParseException e) {
throw new IllegalArgumentException("Failed to get valid expiration time from ECS Metadata service.");
}
}
@Override
public boolean willSoonExpire() {
long now = System.currentTimeMillis();
return this.roleSessionDurationSeconds * (1 - expireFact) > (expiration - now) / 1000;
}
public boolean isExpired() {
long now = System.currentTimeMillis();
return now >= expiration - refreshIntervalInMillSeconds;
}
public boolean shouldRefresh() {
long now = System.currentTimeMillis();
return now - lastFailedRefreshTime > refreshIntervalInMillSeconds;
}
public void setLastFailedRefreshTime() {
lastFailedRefreshTime = System.currentTimeMillis();
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/InstanceProfileCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.utils.AuthUtils;
public class InstanceProfileCredentialsProvider implements AlibabaCloudCredentialsProvider {
private static final int MAX_ECS_METADATA_FETCH_RETRY_TIMES = 3;
private final String roleName;
public int ecsMetadataServiceFetchCount = 0;
private InstanceProfileCredentials credentials = null;
private ECSMetadataServiceCredentialsFetcher fetcher;
public InstanceProfileCredentialsProvider(String roleName) {
if (null == roleName) {
throw new NullPointerException("You must specify a valid role name.");
}
this.roleName = roleName;
this.fetcher = new ECSMetadataServiceCredentialsFetcher();
this.fetcher.setRoleName(this.roleName);
}
public InstanceProfileCredentialsProvider withFetcher(ECSMetadataServiceCredentialsFetcher fetcher) {
this.fetcher = fetcher;
this.fetcher.setRoleName(roleName);
return this;
}
private InstanceProfileCredentialsProvider(BuilderImpl builder) {
if (AuthUtils.isDisableECSMetaData()) {
throw new IllegalArgumentException("IMDS credentials is disabled.");
}
this.roleName = builder.roleName == null ? AuthUtils.getEnvironmentECSMetaData() : builder.roleName;
boolean disableIMDSv1 = builder.disableIMDSv1 == null ? AuthUtils.getDisableECSIMDSv1() : builder.disableIMDSv1;
this.fetcher = new ECSMetadataServiceCredentialsFetcher(
roleName,
disableIMDSv1,
builder.connectionTimeout,
builder.readTimeout);
}
public static Builder builder() {
return new BuilderImpl();
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
if (credentials == null || credentials.isExpired()) {
ecsMetadataServiceFetchCount += 1;
credentials = fetcher.fetch(MAX_ECS_METADATA_FETCH_RETRY_TIMES);
} else if (credentials.willSoonExpire() && credentials.shouldRefresh()) {
try {
ecsMetadataServiceFetchCount += 1;
credentials = fetcher.fetch();
} catch (ClientException e) {
// Use the current expiring session token and wait for next round
credentials.setLastFailedRefreshTime();
}
}
return credentials;
}
public interface Builder {
Builder roleName(String roleName);
Builder disableIMDSv1(Boolean disableIMDSv1);
Builder connectionTimeout(Integer connectionTimeout);
Builder readTimeout(Integer readTimeout);
InstanceProfileCredentialsProvider build();
}
private static final class BuilderImpl implements Builder {
private String roleName;
private Boolean disableIMDSv1;
private Integer connectionTimeout;
private Integer readTimeout;
@Override
public Builder roleName(String roleName) {
this.roleName = roleName;
return this;
}
@Override
public Builder disableIMDSv1(Boolean disableIMDSv1) {
this.disableIMDSv1 = disableIMDSv1;
return this;
}
@Override
public Builder connectionTimeout(Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
return this;
}
@Override
public Builder readTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
return this;
}
@Override
public InstanceProfileCredentialsProvider build() {
return new InstanceProfileCredentialsProvider(this);
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/KeyPairCredentials.java
|
package com.aliyuncs.auth;
public class KeyPairCredentials implements AlibabaCloudCredentials {
private String privateKeySecret;
private String publicKeyId;
public KeyPairCredentials(String publicKeyId, String privateKeySecret) {
if (publicKeyId == null || privateKeySecret == null) {
throw new IllegalArgumentException(
"You must provide a valid pair of Public Key ID and Private Key Secret.");
}
this.publicKeyId = publicKeyId;
this.privateKeySecret = privateKeySecret;
}
@Override
public String getAccessKeyId() {
return publicKeyId;
}
@Override
public String getAccessKeySecret() {
return privateKeySecret;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/LegacyCredentials.java
|
package com.aliyuncs.auth;
@SuppressWarnings("deprecation")
public class LegacyCredentials implements AlibabaCloudCredentials {
private final Credential legacyCredential;
public LegacyCredentials(Credential legacyCredential) {
this.legacyCredential = legacyCredential;
}
@Override
public String getAccessKeyId() {
return legacyCredential.getAccessKeyId();
}
@Override
public String getAccessKeySecret() {
return legacyCredential.getAccessSecret();
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/OIDCCredentialsProvider.java
|
package com.aliyuncs.auth;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.HttpRequest;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.http.UserAgentConfig;
import com.aliyuncs.http.clients.CompatibleUrlConnClient;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.ParameterHelper;
import com.aliyuncs.utils.StringUtils;
import com.google.gson.Gson;
public class OIDCCredentialsProvider implements AlibabaCloudCredentialsProvider {
private String roleArn;
String getRoleArn() {
return roleArn;
}
void setRoleArn(String roleArn) {
this.roleArn = roleArn;
}
private String oidcProviderArn;
String getOidcProviderArn() {
return oidcProviderArn;
}
void setOidcProviderArn(String oidcProviderArn) {
this.oidcProviderArn = oidcProviderArn;
}
private String oidcTokenFilePath;
String getOidcTokenFilePath() {
return oidcTokenFilePath;
}
void setOidcTokenFilePath(String oidcTokenFilePath) {
this.oidcTokenFilePath = oidcTokenFilePath;
}
private String roleSessionName;
String getRoleSessionName() {
return roleSessionName;
}
void setRoleSessionName(String roleSessionName) {
this.roleSessionName = roleSessionName;
}
private String policy;
String getPolicy() {
return policy;
}
void setPolicy(String policy) {
this.policy = policy;
}
private String stsEndpoint;
private long durationSeconds;
private int connectTimeout;
private int readTimeout;
// inner cache
private BasicSessionCredentials credentials;
public OIDCCredentialsProvider(String roleArn, String providerArn, String oidcTokenFilePath, String roleSessionName, String regionId) throws ClientException {
this.roleArn = !StringUtils.isEmpty(roleArn) ? roleArn : AuthUtils.getEnvironmentRoleArn();
if (StringUtils.isEmpty(this.roleArn)) {
throw new ClientException("roleArn does not exist and env ALIBABA_CLOUD_ROLE_ARN is null.");
}
this.oidcProviderArn = !StringUtils.isEmpty(providerArn) ? providerArn : AuthUtils.getEnvironmentOIDCProviderArn();
if (StringUtils.isEmpty(this.oidcProviderArn)) {
throw new ClientException("OIDCProviderArn does not exist and env ALIBABA_CLOUD_OIDC_PROVIDER_ARN is null.");
}
this.oidcTokenFilePath = !StringUtils.isEmpty(oidcTokenFilePath) ? oidcTokenFilePath : AuthUtils.getEnvironmentOIDCTokenFilePath();
if (StringUtils.isEmpty(this.oidcTokenFilePath)) {
throw new ClientException("OIDCTokenFilePath does not exist and env ALIBABA_CLOUD_OIDC_TOKEN_FILE is null.");
}
this.roleSessionName = !StringUtils.isEmpty(roleSessionName) ? roleSessionName : AuthUtils.getEnvironmentRoleSessionName();
if (StringUtils.isEmpty(this.roleSessionName)) {
this.roleSessionName = "aliyun-java-sdk-" + System.currentTimeMillis();
}
if (StringUtils.isEmpty(regionId)) {
this.stsEndpoint = "https://sts.aliyuncs.com/";
} else {
this.stsEndpoint = String.format("https://sts.%s.aliyuncs.com/", regionId);
}
this.durationSeconds = 3600L;
this.connectTimeout = 5000;
this.readTimeout = 10000;
}
private OIDCCredentialsProvider(Builder builder) {
this.roleSessionName = builder.roleSessionName == null ? !StringUtils.isEmpty(AuthUtils.getEnvironmentRoleSessionName()) ?
AuthUtils.getEnvironmentRoleSessionName() : "aliyun-java-sdk-" + System.currentTimeMillis() : builder.roleSessionName;
this.durationSeconds = builder.durationSeconds == null ? 3600 : builder.durationSeconds;
if (this.durationSeconds < 900) {
throw new IllegalArgumentException("Session duration should be in the range of 900s - max session duration.");
}
this.roleArn = builder.roleArn == null ? AuthUtils.getEnvironmentRoleArn() : builder.roleArn;
if (StringUtils.isEmpty(this.roleArn)) {
throw new IllegalArgumentException("RoleArn or environment variable ALIBABA_CLOUD_ROLE_ARN cannot be empty.");
}
this.oidcProviderArn = builder.oidcProviderArn == null ? AuthUtils.getEnvironmentOIDCProviderArn() : builder.oidcProviderArn;
if (StringUtils.isEmpty(this.oidcProviderArn)) {
throw new IllegalArgumentException("OIDCProviderArn or environment variable ALIBABA_CLOUD_OIDC_PROVIDER_ARN cannot be empty.");
}
this.oidcTokenFilePath = builder.oidcTokenFilePath == null ? AuthUtils.getEnvironmentOIDCTokenFilePath() : builder.oidcTokenFilePath;
if (StringUtils.isEmpty(this.oidcTokenFilePath)) {
throw new IllegalArgumentException("OIDCTokenFilePath or environment variable ALIBABA_CLOUD_OIDC_TOKEN_FILE cannot be empty.");
}
this.policy = builder.policy;
this.connectTimeout = builder.connectionTimeout == null ? 5000 : builder.connectionTimeout;
this.readTimeout = builder.readTimeout == null ? 10000 : builder.readTimeout;
String prefix = builder.enableVpc != null ? (builder.enableVpc ? "sts-vpc" : "sts") : AuthUtils.isEnableVpcEndpoint() ? "sts-vpc" : "sts";
if (!StringUtils.isEmpty(builder.stsRegionId)) {
this.stsEndpoint = String.format("https://%s.%s.aliyuncs.com", prefix, builder.stsRegionId);
} else if (!StringUtils.isEmpty(AuthUtils.getEnvironmentSTSRegion())) {
this.stsEndpoint = String.format("https://%s.%s.aliyuncs.com", prefix, AuthUtils.getEnvironmentSTSRegion());
} else {
this.stsEndpoint = "https://sts.aliyuncs.com";
}
}
public static Builder builder() {
return new Builder();
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException, ServerException {
if (credentials == null || credentials.willSoonExpire()) {
String body = this.invokeAssumeRoleWithOIDC();
credentials = parseCredentials(body, this.durationSeconds);
}
return credentials;
}
private static BasicSessionCredentials parseCredentials(String body, long durationSeconds) throws ClientException {
Gson gson = new Gson();
Map<String, Object> map = gson.fromJson(body, Map.class);
if (null == map) {
throw new ClientException("Invalid JSON");
} else if (map.containsKey("Credentials")) {
Map<String, String> result = (Map<String, String>) map.get("Credentials");
String accessKeyId = result.get("AccessKeyId");
String accessKeySecret = result.get("AccessKeySecret");
String securityToken = result.get("SecurityToken");
return new BasicSessionCredentials(accessKeyId, accessKeySecret, securityToken, durationSeconds);
} else {
throw new ClientException("AssumeRoleWithOIDC failed: " + body);
}
}
private String invokeAssumeRoleWithOIDC() throws ClientException {
Map<String, String> queries = new HashMap<String, String>();
queries.put("Action", "AssumeRoleWithOIDC");
queries.put("Format", "JSON");
queries.put("Version", "2015-04-01");
queries.put("Timestamp", ParameterHelper.getISO8601Time(new Date()));
String url;
try {
url = this.stsEndpoint + "?" + new String(ParameterHelper.getFormData(queries));
} catch (UnsupportedEncodingException e) {
throw new ClientException("AssumeRoleWithOIDC failed " + e.toString());
}
HttpRequest httpRequest = new HttpRequest(url);
httpRequest.setSysMethod(MethodType.POST);
httpRequest.setHttpContentType(FormatType.FORM);
httpRequest.setSysConnectTimeout(connectTimeout);
httpRequest.setSysReadTimeout(readTimeout);
httpRequest.putHeaderParameter("UserAgent", UserAgentConfig.resolve(null, null));
String oidcToken = AuthUtils.readFile(oidcTokenFilePath);
if (oidcToken == null) {
throw new ClientException("Read OIDC token failed");
}
Map<String, String> body = new HashMap<String, String>();
body.put("DurationSeconds", String.valueOf(durationSeconds));
body.put("RoleArn", this.roleArn);
body.put("OIDCProviderArn", this.oidcProviderArn);
body.put("OIDCToken", oidcToken);
body.put("RoleSessionName", this.roleSessionName);
if (policy != null) {
body.put("Policy", this.policy);
}
StringBuilder content = new StringBuilder();
try {
boolean first = true;
for (Map.Entry<String, String> entry : body.entrySet()) {
if (StringUtils.isEmpty(entry.getValue())) {
continue;
}
if (first) {
first = false;
} else {
content.append("&");
}
content.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
content.append("=");
content.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
}
httpRequest.setHttpContent(content.toString().getBytes("UTF-8"), "UTF-8", FormatType.FORM);
} catch (UnsupportedEncodingException e) {
throw new ClientException("AssumeRoleWithOIDC failed " + e.toString());
}
HttpResponse response;
try {
response = CompatibleUrlConnClient.compatibleGetResponse(httpRequest);
} catch (Exception e) {
throw new ClientException(e);
}
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
String responseBody = response.getHttpContentString();
Gson gson = new Gson();
Map<String, Object> map = gson.fromJson(responseBody, Map.class);
String requestID = (String)map.get("RequestId");
String message = String.format("%s(RequestID: %s, Code: %s)", (String)map.get("Message"), requestID, (String)map.get("Code"));
throw new ClientException("AssumeRoleWithOIDC failed: " + message);
}
return new String(response.getHttpContent());
}
public static final class Builder {
private String roleSessionName;
private Integer durationSeconds;
private String roleArn;
private String oidcProviderArn;
private String oidcTokenFilePath;
private String policy;
private Integer connectionTimeout;
private Integer readTimeout;
private String stsRegionId;
private Boolean enableVpc;
public Builder roleSessionName(String roleSessionName) {
this.roleSessionName = roleSessionName;
return this;
}
public Builder durationSeconds(Integer durationSeconds) {
this.durationSeconds = durationSeconds;
return this;
}
public Builder roleArn(String roleArn) {
this.roleArn = roleArn;
return this;
}
public Builder oidcProviderArn(String oidcProviderArn) {
this.oidcProviderArn = oidcProviderArn;
return this;
}
public Builder oidcTokenFilePath(String oidcTokenFilePath) {
this.oidcTokenFilePath = oidcTokenFilePath;
return this;
}
public Builder policy(String policy) {
this.policy = policy;
return this;
}
public Builder connectionTimeout(Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
return this;
}
public Builder readTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
return this;
}
public Builder stsRegionId(String stsRegionId) {
this.stsRegionId = stsRegionId;
return this;
}
public Builder enableVpc(Boolean enableVpc) {
this.enableVpc = enableVpc;
return this;
}
public OIDCCredentialsProvider build() {
return new OIDCCredentialsProvider(this);
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/ProfileCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.ProfileUtils;
import com.aliyuncs.utils.StringUtils;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class ProfileCredentialsProvider implements AlibabaCloudCredentialsProvider {
private static volatile Map<String, Map<String, String>> ini;
private static Map<String, Map<String, String>> getIni(String filePath) throws IOException {
if (null == ini) {
synchronized (ProfileCredentialsProvider.class) {
if (null == ini) {
ini = ProfileUtils.parseFile(filePath);
}
}
}
return ini;
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
String filePath = AuthUtils.getEnvironmentCredentialsFile();
if (filePath == null) {
filePath = AuthConstant.DEFAULT_CREDENTIALS_FILE_PATH;
}
if (filePath.isEmpty()) {
throw new ClientException("The specified credentials file is empty");
}
Map<String, Map<String, String>> ini;
try {
ini = getIni(filePath);
} catch (IOException e) {
return null;
}
Map<String, Map<String, String>> client = loadIni(ini);
Map<String, String> clientConfig = client.get(AuthUtils.getClientType());
if (clientConfig == null) {
throw new ClientException("Client is not open in the specified credentials file");
}
CredentialsProviderFactory credentialsProviderFactory = new CredentialsProviderFactory();
return createCredential(clientConfig, credentialsProviderFactory);
}
private Map<String, Map<String, String>> loadIni(Map<String, Map<String, String>> ini) {
Map<String, Map<String, String>> client = new HashMap<String, Map<String, String>>();
String enable;
for (Map.Entry<String, Map<String, String>> clientType : ini.entrySet()) {
enable = clientType.getValue().get(AuthConstant.INI_ENABLE);
if (Boolean.parseBoolean(enable)) {
Map<String, String> clientConfig = new HashMap<String, String>();
clientConfig.putAll(clientType.getValue());
client.put(clientType.getKey(), clientConfig);
}
}
return client;
}
private AlibabaCloudCredentials createCredential(Map<String, String> clientConfig,
CredentialsProviderFactory factory) throws ClientException {
String configType = clientConfig.get(AuthConstant.INI_TYPE);
if (StringUtils.isEmpty(configType)) {
throw new ClientException("The configured client type is empty");
}
if (AuthConstant.INI_TYPE_ARN.equals(configType)) {
return getSTSAssumeRoleSessionCredentials(clientConfig, factory);
}
if (AuthConstant.INI_TYPE_KEY_PAIR.equals(configType)) {
return getSTSGetSessionAccessKeyCredentials(clientConfig, factory);
}
if (AuthConstant.INI_TYPE_RAM.equals(configType)) {
return getInstanceProfileCredentials(clientConfig, factory);
}
if (AuthConstant.INI_TYPE_OIDC.equals(configType)) {
return getSTSOIDCRoleSessionCredentials(clientConfig, factory);
}
String accessKeyId = clientConfig.get(AuthConstant.INI_ACCESS_KEY_ID);
String accessKeySecret = clientConfig.get(AuthConstant.INI_ACCESS_KEY_IDSECRET);
if (StringUtils.isEmpty(accessKeyId) || StringUtils.isEmpty(accessKeySecret)) {
throw new ClientException("The configured access_key_id or access_key_secret is empty.");
}
return new BasicCredentials(accessKeyId, accessKeySecret);
}
private AlibabaCloudCredentials getSTSAssumeRoleSessionCredentials(Map<String, String> clientConfig,
CredentialsProviderFactory factory)
throws ClientException {
String accessKeyId = clientConfig.get(AuthConstant.INI_ACCESS_KEY_ID);
String accessKeySecret = clientConfig.get(AuthConstant.INI_ACCESS_KEY_IDSECRET);
String roleSessionName = clientConfig.get(AuthConstant.INI_ROLE_SESSION_NAME);
String roleArn = clientConfig.get(AuthConstant.INI_ROLE_ARN);
String regionId = clientConfig.get(AuthConstant.DEFAULT_REGION);
String policy = clientConfig.get(AuthConstant.INI_POLICY);
if (StringUtils.isEmpty(accessKeyId) || StringUtils.isEmpty(accessKeySecret)) {
throw new ClientException("The configured access_key_id or access_key_secret is empty");
}
if (StringUtils.isEmpty(roleSessionName) || StringUtils.isEmpty(roleArn)) {
throw new ClientException("The configured role_session_name or role_arn is empty");
}
STSAssumeRoleSessionCredentialsProvider provider =
factory.createCredentialsProvider(new STSAssumeRoleSessionCredentialsProvider(accessKeyId,
accessKeySecret, roleSessionName, roleArn, regionId, policy));
return provider.getCredentials();
}
private AlibabaCloudCredentials getSTSOIDCRoleSessionCredentials(Map<String, String> clientConfig,
CredentialsProviderFactory factory) throws ClientException {
String roleSessionName = clientConfig.get(AuthConstant.INI_ROLE_SESSION_NAME);
String roleArn = clientConfig.get(AuthConstant.INI_ROLE_ARN);
String OIDCProviderArn = clientConfig.get(AuthConstant.INI_OIDC_PROVIDER_ARN);
String OIDCTokenFilePath = clientConfig.get(AuthConstant.INI_OIDC_TOKEN_FILE_PATH);
String policy = clientConfig.get(AuthConstant.INI_POLICY);
if (StringUtils.isEmpty(roleArn)) {
throw new ClientException("The configured role_arn is empty.");
}
if (StringUtils.isEmpty(OIDCProviderArn)) {
throw new ClientException("The configured oidc_provider_arn is empty.");
}
OIDCCredentialsProvider provider = factory.createCredentialsProvider(
OIDCCredentialsProvider.builder()
.roleArn(roleArn)
.roleSessionName(roleSessionName)
.oidcProviderArn(OIDCProviderArn)
.oidcTokenFilePath(OIDCTokenFilePath)
.policy(policy)
.build());
return provider.getCredentials();
}
private AlibabaCloudCredentials getSTSGetSessionAccessKeyCredentials(Map<String, String> clientConfig,
CredentialsProviderFactory factory)
throws ClientException {
String publicKeyId = clientConfig.get(AuthConstant.INI_PUBLIC_KEY_ID);
String privateKeyFile = clientConfig.get(AuthConstant.INI_PRIVATE_KEY_FILE);
if (StringUtils.isEmpty(privateKeyFile)) {
throw new ClientException("The configured private_key_file is empty");
}
String privateKey = AuthUtils.readFile(privateKeyFile);
if (StringUtils.isEmpty(publicKeyId) || StringUtils.isEmpty(privateKey)) {
throw new ClientException("The configured public_key_id or private_key_file content is empty");
}
STSGetSessionAccessKeyCredentialsProvider provider =
factory.createCredentialsProvider(new STSGetSessionAccessKeyCredentialsProvider(publicKeyId, privateKey));
return provider.getCredentials();
}
private AlibabaCloudCredentials getInstanceProfileCredentials(Map<String, String> clientConfig,
CredentialsProviderFactory factory)
throws ClientException {
String roleName = clientConfig.get(AuthConstant.INI_ROLE_NAME);
if (StringUtils.isEmpty(roleName)) {
throw new ClientException("The configured role_name is empty");
}
InstanceProfileCredentialsProvider provider =
factory.createCredentialsProvider(new InstanceProfileCredentialsProvider(roleName));
return provider.getCredentials();
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/RoaSignatureComposer.java
|
package com.aliyuncs.auth;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.utils.ParameterHelper;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class RoaSignatureComposer implements ISignatureComposer {
protected final static String QUERY_SEPARATOR = "&";
protected final static String HEADER_SEPARATOR = "\n";
private static ISignatureComposer composer = null;
public static String replaceOccupiedParameters(String url, Map<String, String> paths) {
String result = url;
for (Map.Entry<String, String> entry : paths.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String target = "[" + key + "]";
result = result.replace(target, value);
}
return result;
}
public static ISignatureComposer getComposer() {
if (null == composer) {
composer = new RoaSignatureComposer();
}
return composer;
}
@Override
public Map<String, String> refreshSignParameters(Map<String, String> parameters, Signer signer, String accessKeyId,
FormatType format) {
Map<String, String> immutableMap = new HashMap<String, String>(parameters);
immutableMap.put("Date", ParameterHelper.getRFC2616Date(new Date()));
if (null == format) {
format = FormatType.JSON;
}
immutableMap.put("Accept", FormatType.mapFormatToAccept(format));
immutableMap.put("x-acs-signature-method", signer.getSignerName());
immutableMap.put("x-acs-signature-version", signer.getSignerVersion());
immutableMap.put("x-acs-signature-nonce", ParameterHelper.getUniqueNonce());
if (signer.getSignerType() != null) {
immutableMap.put("x-acs-signature-type", signer.getSignerType());
}
return immutableMap;
}
private String[] splitSubResource(String uri) {
int queIndex = uri.indexOf("?");
String[] uriParts = new String[2];
if (-1 != queIndex) {
uriParts[0] = uri.substring(0, queIndex);
uriParts[1] = uri.substring(queIndex + 1);
} else {
uriParts[0] = uri;
}
return uriParts;
}
private String buildQueryString(String uri, Map<String, String> queries) {
String[] uriParts = splitSubResource(uri);
Map<String, String> sortMap = new TreeMap<String, String>(queries);
if (null != uriParts[1]) {
sortMap.put(uriParts[1], null);
}
StringBuilder queryBuilder = new StringBuilder(uriParts[0]);
if (0 < sortMap.size()) {
queryBuilder.append("?");
}
for (Map.Entry<String, String> e : sortMap.entrySet()) {
queryBuilder.append(e.getKey());
String value = e.getValue();
if (value == null || value.isEmpty()) {
queryBuilder.append(QUERY_SEPARATOR);
continue;
}
queryBuilder.append("=").append(e.getValue()).append(QUERY_SEPARATOR);
}
String queryString = queryBuilder.toString();
if (queryString.endsWith(QUERY_SEPARATOR)) {
queryString = queryString.substring(0, queryString.length() - 1);
}
return queryString;
}
protected String buildCanonicalHeaders(Map<String, String> headers, String headerBegin) {
Map<String, String> sortMap = new TreeMap<String, String>();
for (Map.Entry<String, String> e : headers.entrySet()) {
String key = e.getKey().toLowerCase();
String val = e.getValue();
if (key.startsWith(headerBegin)) {
sortMap.put(key, val);
}
}
StringBuilder headerBuilder = new StringBuilder();
for (Map.Entry<String, String> e : sortMap.entrySet()) {
headerBuilder.append(e.getKey());
headerBuilder.append(':').append(e.getValue());
headerBuilder.append(HEADER_SEPARATOR);
}
return headerBuilder.toString();
}
@Override
public String composeStringToSign(MethodType method, String uriPattern, Signer signer, Map<String, String> queries,
Map<String, String> headers, Map<String, String> paths) {
StringBuilder sb = new StringBuilder();
sb.append(method).append(HEADER_SEPARATOR);
if (headers.get("Accept") != null) {
sb.append(headers.get("Accept"));
}
sb.append(HEADER_SEPARATOR);
if (headers.get("Content-MD5") != null) {
sb.append(headers.get("Content-MD5"));
}
sb.append(HEADER_SEPARATOR);
if (headers.get("Content-Type") != null) {
sb.append(headers.get("Content-Type"));
}
sb.append(HEADER_SEPARATOR);
if (headers.get("Date") != null) {
sb.append(headers.get("Date"));
}
sb.append(HEADER_SEPARATOR);
String uri = replaceOccupiedParameters(uriPattern, paths);
sb.append(buildCanonicalHeaders(headers, "x-acs-"));
sb.append(buildQueryString(uri, queries));
return sb.toString();
}
@Override
public String getAuthorization(Signer signer, String accessKeyId, String signature) {
return "acs " + accessKeyId + ":" + signature;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/RpcSignatureComposer.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.utils.ParameterHelper;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class RpcSignatureComposer implements ISignatureComposer {
private final static String SEPARATOR = "&";
private static ISignatureComposer composer = null;
private RpcSignatureComposer() {
}
public static ISignatureComposer getComposer() {
if (null == composer) {
composer = new RpcSignatureComposer();
}
return composer;
}
@Override
public Map<String, String> refreshSignParameters(Map<String, String> parameters,
Signer signer, String accessKeyId, FormatType format) {
Map<String, String> immutableMap = new HashMap<String, String>(parameters);
immutableMap.put("Timestamp", ParameterHelper.getISO8601Time(new Date()));
immutableMap.put("SignatureMethod", signer.getSignerName());
immutableMap.put("SignatureVersion", signer.getSignerVersion());
immutableMap.put("SignatureNonce", ParameterHelper.getUniqueNonce());
if (null != format) {
immutableMap.put("Format", format.toString());
}
if (signer.getSignerType() != null) {
immutableMap.put("SignatureType", signer.getSignerType());
}
return immutableMap;
}
@Override
public String composeStringToSign(MethodType method, String uriPattern,
Signer signer, Map<String, String> queries,
Map<String, String> headers, Map<String, String> paths) {
String[] sortedKeys = queries.keySet().toArray(new String[]{});
Arrays.sort(sortedKeys);
StringBuilder canonicalizedQueryString = new StringBuilder();
try {
for (String key : sortedKeys) {
canonicalizedQueryString.append("&")
.append(AcsURLEncoder.percentEncode(key)).append("=")
.append(AcsURLEncoder.percentEncode(queries.get(key)));
}
StringBuilder stringToSign = new StringBuilder();
stringToSign.append(method.toString());
stringToSign.append(SEPARATOR);
stringToSign.append(AcsURLEncoder.percentEncode("/"));
stringToSign.append(SEPARATOR);
stringToSign.append(AcsURLEncoder.percentEncode(
canonicalizedQueryString.toString().substring(1)));
return stringToSign.toString();
} catch (UnsupportedEncodingException exp) {
throw new RuntimeException("UTF-8 encoding is not supported.");
}
}
@Override
public String getAuthorization(Signer signer, String accessKeyId, String signature) {
return signature;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/SHA256withRSASigner.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
@Deprecated
public class SHA256withRSASigner extends Signer {
public static final String ENCODING = "UTF-8";
private static final String ALGORITHM_NAME = "SHA256withRSA";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
Signature rsaSign = Signature.getInstance("SHA256withRSA");
KeyFactory kf = KeyFactory.getInstance("RSA");
byte[] keySpec = DatatypeConverter.parseBase64Binary(accessKeySecret);
PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(keySpec));
rsaSign.initSign(privateKey);
rsaSign.update(stringToSign.getBytes(ENCODING));
byte[] sign = rsaSign.sign();
return DatatypeConverter.printBase64Binary(sign);
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeySpecException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e.toString());
} catch (SignatureException e) {
throw new IllegalArgumentException(e.toString());
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return ALGORITHM_NAME;
}
@Override
public String getSignerVersion() {
return "1.0";
}
@Override
public String getSignerType() {
return "PRIVATEKEY";
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
return null;
}
@Override
public String getContent() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/STSAssumeRoleSessionCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.auth.sts.AssumeRoleRequest;
import com.aliyuncs.auth.sts.AssumeRoleResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.StringUtils;
/**
* This implementation of AlibabaCloudCredentialsProvider accesses Alibaba Cloud STS service to assume a Role and get
* back a temporary session for authentication.
*/
public class STSAssumeRoleSessionCredentialsProvider implements AlibabaCloudCredentialsProvider {
/**
* Default duration for started sessions.
*/
public static final int DEFAULT_DURATION_SECONDS = 3600;
/**
* The arn of the role to be assumed.
*/
private String roleArn;
/**
* For test
* To know how many rounds AssumeRole has been called
*/
public long assumeRoleRound = 0;
/**
* The client for starting STS sessions.
*/
private IAcsClient stsClient;
/**
* An identifier for the assumed role session.
*/
private String roleSessionName;
/**
* The Duration for assume role sessions.
*/
private long roleSessionDurationSeconds;
private String policy;
private String externalId;
private BasicSessionCredentials credentials = null;
/**
* Unit of millisecond
*/
private int connectTimeout;
private int readTimeout;
private String stsEndpoint;
public STSAssumeRoleSessionCredentialsProvider(AlibabaCloudCredentials longLivedCredentials,
String roleArn, IClientProfile clientProfile) {
this(new StaticCredentialsProvider(longLivedCredentials), roleArn, clientProfile);
}
public STSAssumeRoleSessionCredentialsProvider(AlibabaCloudCredentialsProvider longLivedCredentialsProvider,
String roleArn, IClientProfile clientProfile) {
if (roleArn == null) {
throw new NullPointerException(
"You must specify a value for roleArn.");
}
this.roleArn = roleArn;
this.roleSessionName = getNewRoleSessionName();
this.stsClient = new DefaultAcsClient(clientProfile, longLivedCredentialsProvider);
this.roleSessionDurationSeconds = DEFAULT_DURATION_SECONDS;
this.connectTimeout = 5000;
this.readTimeout = 10000;
}
public STSAssumeRoleSessionCredentialsProvider(String accessKeyId, String accessKeySecret, String roleSessionName,
String roleArn, String regionId) {
this.roleArn = roleArn;
this.roleSessionName = roleSessionName;
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
this.stsClient = new DefaultAcsClient(profile);
this.roleSessionDurationSeconds = AuthConstant.TSC_VALID_TIME_SECONDS;
this.connectTimeout = 5000;
this.readTimeout = 10000;
}
public STSAssumeRoleSessionCredentialsProvider(String accessKeyId, String accessKeySecret, String roleSessionName,
String roleArn, String regionId, String policy) {
this(accessKeyId, accessKeySecret, roleSessionName, roleArn, regionId);
this.policy = policy;
}
public static String getNewRoleSessionName() {
return "aliyun-java-sdk-" + System.currentTimeMillis();
}
public STSAssumeRoleSessionCredentialsProvider withRoleSessionName(String roleSessionName) {
this.roleSessionName = roleSessionName;
return this;
}
public STSAssumeRoleSessionCredentialsProvider withRoleSessionDurationSeconds(long roleSessionDurationSeconds) {
if (roleSessionDurationSeconds < 900) {
throw new IllegalArgumentException(
"Assume Role session duration should be in the range of 15min - max");
}
this.roleSessionDurationSeconds = roleSessionDurationSeconds;
return this;
}
public STSAssumeRoleSessionCredentialsProvider withSTSClient(IAcsClient client) {
this.stsClient = client;
return this;
}
private STSAssumeRoleSessionCredentialsProvider(Builder builder) {
this.roleSessionName = builder.roleSessionName == null ? !StringUtils.isEmpty(AuthUtils.getEnvironmentRoleSessionName()) ?
AuthUtils.getEnvironmentRoleSessionName() : getNewRoleSessionName() : builder.roleSessionName;
this.roleSessionDurationSeconds = builder.durationSeconds == null ? 3600 : builder.durationSeconds;
if (this.roleSessionDurationSeconds < 900) {
throw new IllegalArgumentException("Session duration should be in the range of 900s - max session duration.");
}
this.roleArn = builder.roleArn == null ? AuthUtils.getEnvironmentRoleArn() : builder.roleArn;
if (StringUtils.isEmpty(this.roleArn)) {
throw new IllegalArgumentException("RoleArn or environment variable ALIBABA_CLOUD_ROLE_ARN cannot be empty.");
}
this.policy = builder.policy;
this.externalId = builder.externalId;
this.connectTimeout = builder.connectionTimeout == null ? 5000 : builder.connectionTimeout;
this.readTimeout = builder.readTimeout == null ? 10000 : builder.readTimeout;
String prefix = builder.enableVpc != null ? (builder.enableVpc ? "sts-vpc" : "sts") : AuthUtils.isEnableVpcEndpoint() ? "sts-vpc" : "sts";
if (!StringUtils.isEmpty(builder.stsRegionId)) {
this.stsEndpoint = String.format("%s.%s.aliyuncs.com", prefix, builder.stsRegionId);
} else if (!StringUtils.isEmpty(AuthUtils.getEnvironmentSTSRegion())) {
this.stsEndpoint = String.format("%s.%s.aliyuncs.com", prefix, AuthUtils.getEnvironmentSTSRegion());
} else {
this.stsEndpoint = "sts.aliyuncs.com";
}
DefaultProfile profile = DefaultProfile.getProfile(builder.stsRegionId);
if (null != builder.credentialsProvider) {
this.stsClient = new DefaultAcsClient(profile, builder.credentialsProvider);
} else if (!StringUtils.isEmpty(builder.securityToken)) {
AlibabaCloudCredentialsProvider credentialsProvider = new StaticCredentialsProvider(
new BasicSessionCredentials(builder.accessKeyId, builder.accessKeySecret, builder.securityToken));
this.stsClient = new DefaultAcsClient(profile, credentialsProvider);
} else {
AlibabaCloudCredentialsProvider credentialsProvider = new StaticCredentialsProvider(
new BasicCredentials(builder.accessKeyId, builder.accessKeySecret));
this.stsClient = new DefaultAcsClient(profile, credentialsProvider);
}
}
public static Builder builder() {
return new Builder();
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException, ServerException {
if (credentials == null || credentials.willSoonExpire()) {
credentials = getNewSessionCredentials();
}
return credentials;
}
private BasicSessionCredentials getNewSessionCredentials() throws ClientException, ServerException {
assumeRoleRound += 1;
AssumeRoleRequest assumeRoleRequest = new AssumeRoleRequest();
assumeRoleRequest.setRoleArn(roleArn);
assumeRoleRequest.setRoleSessionName(roleSessionName);
assumeRoleRequest.setDurationSeconds(roleSessionDurationSeconds);
assumeRoleRequest.setSysConnectTimeout(connectTimeout);
assumeRoleRequest.setSysReadTimeout(readTimeout);
if (!StringUtils.isEmpty(stsEndpoint)) {
assumeRoleRequest.setSysEndpoint(stsEndpoint);
}
if (null != policy) {
assumeRoleRequest.setPolicy(policy);
}
if (null != externalId) {
assumeRoleRequest.setExternalId(externalId);
}
AssumeRoleResponse response = stsClient.getAcsResponse(assumeRoleRequest);
return new BasicSessionCredentials(
response.getCredentials().getAccessKeyId(),
response.getCredentials().getAccessKeySecret(),
response.getCredentials().getSecurityToken(),
roleSessionDurationSeconds
);
}
public static final class Builder {
private String roleSessionName;
private Integer durationSeconds;
private String roleArn;
private String policy;
private Integer connectionTimeout;
private Integer readTimeout;
private String stsRegionId;
private Boolean enableVpc;
private String accessKeyId;
private String accessKeySecret;
private String securityToken;
private AlibabaCloudCredentialsProvider credentialsProvider;
private String externalId;
public Builder roleSessionName(String roleSessionName) {
this.roleSessionName = roleSessionName;
return this;
}
public Builder durationSeconds(Integer durationSeconds) {
this.durationSeconds = durationSeconds;
return this;
}
public Builder roleArn(String roleArn) {
this.roleArn = roleArn;
return this;
}
public Builder policy(String policy) {
this.policy = policy;
return this;
}
public Builder connectionTimeout(Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
return this;
}
public Builder readTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
return this;
}
public Builder stsRegionId(String stsRegionId) {
this.stsRegionId = stsRegionId;
return this;
}
public Builder enableVpc(Boolean enableVpc) {
this.enableVpc = enableVpc;
return this;
}
public Builder accessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
return this;
}
public Builder accessKeySecret(String accessKeySecret) {
this.accessKeySecret = accessKeySecret;
return this;
}
public Builder securityToken(String securityToken) {
this.securityToken = securityToken;
return this;
}
public Builder credentialsProvider(AlibabaCloudCredentialsProvider credentialsProvider) {
this.credentialsProvider = credentialsProvider;
return this;
}
public Builder externalId(String externalId) {
this.externalId = externalId;
return this;
}
public STSAssumeRoleSessionCredentialsProvider build() {
return new STSAssumeRoleSessionCredentialsProvider(this);
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/STSGetSessionAccessKeyCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.auth.sts.GenerateSessionAccessKeyResponse;
import com.aliyuncs.auth.sts.GetSessionAccessKeyRequest;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.ProtocolType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
public class STSGetSessionAccessKeyCredentialsProvider implements AlibabaCloudCredentialsProvider {
public static final int DEFAULT_DURATION_SECONDS = 3600;
private KeyPairCredentials keyPairCredentials;
private String publicKeyId;
private IAcsClient stsClient;
private long sessionDurationSeconds = DEFAULT_DURATION_SECONDS;
private BasicSessionCredentials sessionCredentials = null;
public STSGetSessionAccessKeyCredentialsProvider(KeyPairCredentials keyPairCredentials,
IClientProfile profile) {
this.keyPairCredentials = keyPairCredentials;
this.stsClient = new DefaultAcsClient(profile, keyPairCredentials);
}
public STSGetSessionAccessKeyCredentialsProvider(String publicKeyId, String privateKey) {
this.publicKeyId = publicKeyId;
DefaultProfile profile = DefaultProfile.getProfile("ap-northeast-1", publicKeyId, privateKey);
this.stsClient = new DefaultAcsClient(profile);
}
public STSGetSessionAccessKeyCredentialsProvider withDurationSeconds(long seconds) {
this.sessionDurationSeconds = seconds;
return this;
}
public STSGetSessionAccessKeyCredentialsProvider withSTSClient(IAcsClient client) {
this.stsClient = client;
return this;
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException, ServerException {
if (sessionCredentials == null || sessionCredentials.willSoonExpire()) {
sessionCredentials = getNewSessionCredentials();
}
return sessionCredentials;
}
private BasicSessionCredentials getNewSessionCredentials() throws ClientException, ServerException {
GetSessionAccessKeyRequest request = new GetSessionAccessKeyRequest();
if (null != publicKeyId) {
request.setPublicKeyId(publicKeyId);
} else {
request.setPublicKeyId(keyPairCredentials.getAccessKeyId());
}
request.setDurationSeconds((int) sessionDurationSeconds);
request.setSysProtocol(ProtocolType.HTTPS);
GenerateSessionAccessKeyResponse response = this.stsClient.getAcsResponse(request);
return new BasicSessionCredentials(
response.getSessionAccessKey().getSessionAccessKeyId(),
response.getSessionAccessKey().getSessionAccessKeySecret(),
null,
sessionDurationSeconds
);
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/SignatureVersion.java
|
package com.aliyuncs.auth;
public enum SignatureVersion {
V1,
V3
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/Signer.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth;
import com.aliyuncs.auth.signers.*;
import java.security.NoSuchAlgorithmException;
public abstract class Signer {
private final static Signer HMACSHA1_SIGNER = new com.aliyuncs.auth.signers.HmacSHA1Signer();
private final static Signer SHA256_WITH_RSA_SIGNER = new com.aliyuncs.auth.signers.SHA256withRSASigner();
private final static Signer BEARER_TOKEN_SIGNER = new com.aliyuncs.auth.signers.BearerTokenSigner();
// Signature V3
private final static Signer RSA_SHA256 = new NewSHA256withRSASigner();
private final static Signer HMAC_SM3 = new HmacSM3Signer();
private final static Signer HMAC_SHA256 = new HmacSHA256Signer();
public static Signer getSigner(AlibabaCloudCredentials credentials) {
if (credentials instanceof KeyPairCredentials) {
return SHA256_WITH_RSA_SIGNER;
} else if (credentials instanceof BearerTokenCredentials) {
return BEARER_TOKEN_SIGNER;
} else {
return HMACSHA1_SIGNER;
}
}
public static Signer getSigner(AlibabaCloudCredentials credentials, SignatureVersion signatureVersion, SignatureAlgorithm signatureAlgorithm) {
switch (signatureVersion) {
case V3:
switch (signatureAlgorithm) {
case ACS3_RSA_SHA256:
return RSA_SHA256;
case ACS3_HMAC_SM3:
return HMAC_SM3;
case ACS3_HMAC_SHA256:
return HMAC_SHA256;
}
case V1:
default:
if (credentials instanceof KeyPairCredentials) {
return SHA256_WITH_RSA_SIGNER;
} else if (credentials instanceof BearerTokenCredentials) {
return BEARER_TOKEN_SIGNER;
} else {
return HMACSHA1_SIGNER;
}
}
}
public abstract String signString(String stringToSign, AlibabaCloudCredentials credentials);
public abstract String signString(String stringToSign, String accessKeySecret);
public abstract String getSignerName();
public abstract String getSignerVersion();
public abstract String getSignerType();
public abstract byte[] hash(byte[] raw) throws NoSuchAlgorithmException;
public abstract String getContent();
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/StaticCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.profile.IClientProfile;
public class StaticCredentialsProvider implements AlibabaCloudCredentialsProvider {
private AlibabaCloudCredentials credentials;
public StaticCredentialsProvider(AlibabaCloudCredentials credentials) {
this.credentials = credentials;
}
@SuppressWarnings("deprecation")
public StaticCredentialsProvider(IClientProfile clientProfile) {
Credential credential = clientProfile.getCredential();
if (credential == null) {
this.credentials = new AnonymousCredentials();
} else if (null != credential.getSecurityToken()) {
this.credentials = new BasicSessionCredentials(
credential.getAccessKeyId(),
credential.getAccessSecret(),
credential.getSecurityToken());
} else {
this.credentials = new LegacyCredentials(credential);
}
}
@Override
public AlibabaCloudCredentials getCredentials() {
return this.credentials;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/SystemPropertiesCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.StringUtils;
public class SystemPropertiesCredentialsProvider implements AlibabaCloudCredentialsProvider {
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
if (!"default".equals(AuthUtils.getClientType())) {
return null;
}
String accessKeyId = System.getProperty(AuthConstant.SYSTEM_ACCESSKEYID);
String accessKeySecret = System.getProperty(AuthConstant.SYSTEM_ACCESSKEY_SECRET);
if (!StringUtils.isEmpty(System.getProperty(AuthConstant.SYSTEM_ACCESSKEYSECRET))) {
accessKeySecret = System.getProperty(AuthConstant.SYSTEM_ACCESSKEYSECRET);
}
String securityToken = System.getProperty(AuthConstant.SYSTEM_SESSION_TOKEN);
if (StringUtils.isEmpty(accessKeyId)) {
throw new ClientException("System property alibabacloud.accessKeyId cannot be empty.");
}
if (StringUtils.isEmpty(accessKeySecret)) {
throw new ClientException("System property alibabacloud.accessKeySecret cannot be empty.");
}
if (!StringUtils.isEmpty(securityToken)) {
return new BasicSessionCredentials(accessKeyId, accessKeySecret, securityToken);
}
return new BasicCredentials(accessKeyId, accessKeySecret);
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/URLCredentialsProvider.java
|
package com.aliyuncs.auth;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.HttpRequest;
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.http.clients.CompatibleUrlConnClient;
import com.aliyuncs.utils.AuthUtils;
import com.aliyuncs.utils.ParameterHelper;
import com.aliyuncs.utils.StringUtils;
import com.google.gson.Gson;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.util.Map;
public class URLCredentialsProvider implements AlibabaCloudCredentialsProvider {
private final URL credentialsURI;
/**
* Unit of millisecond
*/
private final int connectTimeout;
private final int readTimeout;
private URLCredentialsProvider(Builder builder) {
String credentialsURI = builder.credentialsURI == null ? AuthUtils.getEnvironmentCredentialsURI() : builder.credentialsURI;
if (StringUtils.isEmpty(credentialsURI)) {
throw new IllegalArgumentException("Credential URI or environment variable ALIBABA_CLOUD_CREDENTIALS_URI cannot be empty.");
}
try {
this.credentialsURI = new URL(credentialsURI);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Credential URI is not valid.");
}
this.connectTimeout = builder.connectionTimeout == null ? 5000 : builder.connectionTimeout;
this.readTimeout = builder.readTimeout == null ? 10000 : builder.readTimeout;
}
public static Builder builder() {
return new Builder();
}
@Override
public AlibabaCloudCredentials getCredentials() throws ClientException {
HttpRequest request = new HttpRequest(this.credentialsURI.toString());
request.setSysMethod(MethodType.GET);
request.setSysConnectTimeout(connectTimeout);
request.setSysReadTimeout(readTimeout);
HttpResponse response;
try {
response = CompatibleUrlConnClient.compatibleGetResponse(request);
} catch (Exception e) {
throw new ClientException("Failed to connect Server: " + e);
}
if (response.getStatus() != HttpURLConnection.HTTP_OK) {
throw new ClientException("Failed to get credentials from server: " + this.credentialsURI
+ "\nHttpCode=" + response.getStatus()
+ "\nHttpRAWContent=" + response.getHttpContentString());
}
Gson gson = new Gson();
Map<String, String> map;
try {
map = gson.fromJson(response.getHttpContentString(), Map.class);
} catch (Exception e) {
throw new ClientException("Failed to parse credentials from server: " + this.credentialsURI
+ "\nHttpCode=" + response.getStatus()
+ "\nHttpRAWContent=" + response.getHttpContentString());
}
if (null == map || !map.containsKey("Code") || !map.get("Code").equals("Success")) {
throw new ClientException(String.format("Error retrieving credentials from url: %s, result: %s.", this.credentialsURI, response.getHttpContentString()));
}
if (!map.containsKey("AccessKeyId") || !map.containsKey("AccessKeySecret") || !map.containsKey("SecurityToken") || !map.containsKey("Expiration")) {
throw new ClientException(String.format("Error retrieving credentials from url: %s, result: %s.", this.credentialsURI, response.getHttpContentString()));
}
long expiration;
try {
expiration = ParameterHelper.parseISO8601(map.get("Expiration")).getTime();
} catch (ParseException e) {
throw new ClientException(String.format("Error retrieving credentials expiration time from url: %s, result: %s.", this.credentialsURI, response.getHttpContentString()));
}
String accessKeyId = map.get("AccessKeyId");
String accessKeySecret = map.get("AccessKeySecret");
String securityToken = map.get("SecurityToken");
return new BasicSessionCredentials(accessKeyId, accessKeySecret, securityToken, expiration - System.currentTimeMillis());
}
public static final class Builder {
private String credentialsURI;
private Integer connectionTimeout;
private Integer readTimeout;
public Builder credentialsURI(URL credentialsURI) {
this.credentialsURI = credentialsURI.toString();
return this;
}
public Builder credentialsURI(String credentialsURI) {
this.credentialsURI = credentialsURI;
return this;
}
public Builder connectionTimeout(Integer connectionTimeout) {
this.connectionTimeout = connectionTimeout;
return this;
}
public Builder readTimeout(Integer readTimeout) {
this.readTimeout = readTimeout;
return this;
}
public URLCredentialsProvider build() {
return new URLCredentialsProvider(this);
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/V3SignatureComposer.java
|
package com.aliyuncs.auth;
import com.aliyuncs.http.FormatType;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.utils.ParameterHelper;
import com.aliyuncs.utils.StringUtils;
import java.io.UnsupportedEncodingException;
import java.util.*;
import static com.aliyuncs.auth.AcsURLEncoder.percentEncode;
public class V3SignatureComposer implements ISignatureComposer {
protected final static String QUERY_SEPARATOR = "&";
protected final static String HEADER_SEPARATOR = "\n";
private final static String DELIMITER = ";";
private static ISignatureComposer composer = null;
private final static String SIGNED_HEADERS = "signedHeaders";
private final static String CANONICAL_HEADERS = "canonicalHeaders";
private final static String prefix = "x-acs-";
private final static String CONTENT_TYPE = "content-type";
private final static String HOST = "host";
public static ISignatureComposer getComposer() {
if (null == composer) {
composer = new V3SignatureComposer();
}
return composer;
}
public static String replaceOccupiedParameters(String url, Map<String, String> paths) {
if (null == paths || paths.isEmpty()) {
return url;
}
String result = url;
for (Map.Entry<String, String> entry : paths.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String target = "[" + key + "]";
result = result.replace(target, value);
}
return result;
}
@Override
public Map<String, String> refreshSignParameters(Map<String, String> parameters, Signer signer, String accessKeyId,
FormatType format) {
Map<String, String> immutableMap = new HashMap<String, String>(parameters);
immutableMap.put("x-acs-date", ParameterHelper.getISO8601Time(new Date()));
immutableMap.put("x-acs-signature-nonce", ParameterHelper.getUniqueNonce());
return immutableMap;
}
private Map<String, String> getCanonicalizedHeadersMap(Map<String, String> headers) {
Map<String, String> result = new HashMap<String, String>();
String[] keys = headers.keySet().toArray(new String[headers.size()]);
Arrays.sort(keys);
List<String> canonicalizedKeys = new ArrayList<String>();
Map<String, String> valueMap = new HashMap<String, String>();
for (String key : keys) {
String lowerKey = key.toLowerCase();
if (lowerKey.startsWith(prefix) || lowerKey.equals(HOST)
|| lowerKey.equals(CONTENT_TYPE)) {
if (!canonicalizedKeys.contains(lowerKey)) {
canonicalizedKeys.add(lowerKey);
}
valueMap.put(lowerKey, !StringUtils.isEmpty(headers.get(key)) ? headers.get(key).trim() : null);
}
}
String[] canonicalizedKeysArray = canonicalizedKeys.toArray(new String[canonicalizedKeys.size()]);
String signedHeaders = StringUtils.join(DELIMITER, Arrays.asList(canonicalizedKeysArray));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < canonicalizedKeysArray.length; i++) {
String key = canonicalizedKeysArray[i];
sb.append(key);
sb.append(":");
sb.append(valueMap.get(key));
sb.append("\n");
}
result.put(CANONICAL_HEADERS, sb.toString());
result.put(SIGNED_HEADERS, signedHeaders);
return result;
}
private String getCanonicalizedResource(Map<String, String> query) {
if (query == null || query.isEmpty()) {
return "";
}
String[] keys = query.keySet().toArray(new String[query.size()]);
Arrays.sort(keys);
StringBuilder queryString = new StringBuilder();
try {
for (int i = 0; i < keys.length; i++) {
queryString.append(percentEncode(keys[i]));
queryString.append("=");
if (!StringUtils.isEmpty(query.get(keys[i]))) {
queryString.append(percentEncode(query.get(keys[i])));
}
queryString.append(QUERY_SEPARATOR);
}
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
}
return queryString.length() > 0 ? queryString.deleteCharAt(queryString.length() - 1).toString() : "";
}
@Override
public String composeStringToSign(MethodType method, String uriPattern, Signer signer, Map<String, String> queries,
Map<String, String> headers, Map<String, String> paths) {
String canonicalURI = replaceOccupiedParameters(uriPattern, paths);
if (StringUtils.isEmpty(canonicalURI)) {
canonicalURI = "/";
}
Map<String, String> cannoicalHeaders = getCanonicalizedHeadersMap(headers);
String queryString = getCanonicalizedResource(queries);
StringBuilder sb = new StringBuilder(String.valueOf(method));
sb.append("\n").append(canonicalURI)
.append("\n").append(queryString)
.append("\n").append(cannoicalHeaders.get(CANONICAL_HEADERS))
.append("\n").append(cannoicalHeaders.get(SIGNED_HEADERS));
return sb.toString();
}
@Override
public String getAuthorization(Signer signer, String accessKeyId, String signature) {
return signer.getSignerName() + " Credential=" + accessKeyId + ",Signature=" + signature;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/BearerTokenSigner.java
|
package com.aliyuncs.auth.signers;
import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.Signer;
import java.security.NoSuchAlgorithmException;
public class BearerTokenSigner extends Signer {
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return null;
}
@Override
public String signString(String stringToSign, String accessKeySecret) {
return null;
}
@Override
public String getSignerName() {
return null;
}
@Override
public String getSignerVersion() {
return null;
}
@Override
public String getSignerType() {
return "BEARERTOKEN";
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
return null;
}
@Override
public String getContent() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/HmacSHA1Signer.java
|
package com.aliyuncs.auth.signers;
import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.Signer;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;
public class HmacSHA1Signer extends Signer {
public static final String ENCODING = "UTF-8";
private static final String ALGORITHM_NAME = "HmacSHA1";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
Mac mac = Mac.getInstance(ALGORITHM_NAME);
mac.init(new SecretKeySpec(accessKeySecret.getBytes(ENCODING), ALGORITHM_NAME));
byte[] signData = mac.doFinal(stringToSign.getBytes(ENCODING));
return DatatypeConverter.printBase64Binary(signData);
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e.toString());
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return "HMAC-SHA1";
}
@Override
public String getSignerVersion() {
return "1.0";
}
@Override
public String getSignerType() {
return null;
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
return null;
}
@Override
public String getContent() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/HmacSHA256Signer.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth.signers;
import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.Signer;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import static com.aliyuncs.auth.AcsURLEncoder.hexEncode;
public class HmacSHA256Signer extends Signer {
private static final String ALGORITHM_NAME = "HmacSHA256";
private static String HASH_SHA256 = "SHA-256";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
Mac sha256_HMAC = Mac.getInstance(ALGORITHM_NAME);
SecretKeySpec secret_key = new SecretKeySpec(accessKeySecret.getBytes(), ALGORITHM_NAME);
sha256_HMAC.init(secret_key);
return hexEncode(sha256_HMAC.doFinal(stringToSign.getBytes()));
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return "ACS3-HMAC-SHA256";
}
@Override
public String getSignerVersion() {
return "3.0";
}
@Override
public String getSignerType() {
return null;
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
if(null == raw){
return null;
}
MessageDigest digest = MessageDigest.getInstance(HASH_SHA256);
return digest.digest(raw);
}
@Override
public String getContent() {
return "x-acs-content-sha256";
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/HmacSM3Signer.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth.signers;
import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.Signer;
import org.bouncycastle.crypto.digests.SM3Digest;
import org.bouncycastle.crypto.macs.HMac;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import static com.aliyuncs.auth.AcsURLEncoder.hexEncode;
public class HmacSM3Signer extends Signer {
public static final String ENCODING = "UTF-8";
private static final String ALGORITHM_NAME = "HMAC-SM3";
private static String HASH_SM3 = "SM3";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
SecretKey key = new SecretKeySpec((accessKeySecret).getBytes(ENCODING), ALGORITHM_NAME);
HMac mac = new HMac(new SM3Digest());
byte[] sign = new byte[mac.getMacSize()];
byte[] inputBytes = stringToSign.getBytes(ENCODING);
mac.init(new KeyParameter(key.getEncoded()));
mac.update(inputBytes, 0, inputBytes.length);
mac.doFinal(sign, 0);
return hexEncode(sign);
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return "ACS3-HMAC-SM3";
}
@Override
public String getSignerVersion() {
return "3.0";
}
@Override
public String getSignerType() {
return null;
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
if(null == raw){
return null;
}
BouncyCastleProvider provider = new BouncyCastleProvider();
MessageDigest digest = MessageDigest.getInstance(HASH_SM3, provider);
return digest.digest(raw);
}
@Override
public String getContent() {
return "x-acs-content-sm3";
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/NewSHA256withRSASigner.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth.signers;
import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.Signer;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import static com.aliyuncs.auth.AcsURLEncoder.hexEncode;
public class NewSHA256withRSASigner extends Signer {
public static final String ENCODING = "UTF-8";
private static final String ALGORITHM_NAME = "SHA256withRSA";
private static String HASH_SHA256 = "SHA-256";
private final static String PEM_BEGIN = "-----BEGIN RSA PRIVATE KEY-----\n";
private final static String PEM_END = "\n-----END RSA PRIVATE KEY-----";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
Signature rsaSign = Signature.getInstance(ALGORITHM_NAME);
KeyFactory kf = KeyFactory.getInstance("RSA");
byte[] keySpec = DatatypeConverter.parseBase64Binary(checkRSASecret(accessKeySecret));
PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(keySpec));
rsaSign.initSign(privateKey);
rsaSign.update(stringToSign.getBytes(ENCODING));
byte[] sign = rsaSign.sign();
return hexEncode(sign);
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeySpecException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e.toString());
} catch (SignatureException e) {
throw new IllegalArgumentException(e.toString());
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
}
}
private String checkRSASecret(String accessKeySecret) {
if (accessKeySecret != null) {
if (accessKeySecret.startsWith(PEM_BEGIN)) {
accessKeySecret = accessKeySecret.replace(PEM_BEGIN, "");
}
while (accessKeySecret.endsWith("\n") || accessKeySecret.endsWith("\r")) {
accessKeySecret = accessKeySecret.substring(0, accessKeySecret.length() - 1);
}
if (accessKeySecret.endsWith(PEM_END)) {
accessKeySecret = accessKeySecret.replace(PEM_END, "");
}
}
return accessKeySecret;
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return "ACS3-RSA-SHA256";
}
@Override
public String getSignerVersion() {
return "3.0";
}
@Override
public String getSignerType() {
return null;
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
if(null == raw){
return null;
}
MessageDigest digest = MessageDigest.getInstance(HASH_SHA256);
return digest.digest(raw);
}
@Override
public String getContent() {
return "x-acs-content-sha256";
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/SHA256withRSASigner.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth.signers;
import com.aliyuncs.auth.AlibabaCloudCredentials;
import com.aliyuncs.auth.Signer;
import javax.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
public class SHA256withRSASigner extends Signer {
public static final String ENCODING = "UTF-8";
private static final String ALGORITHM_NAME = "SHA256withRSA";
@Override
public String signString(String stringToSign, String accessKeySecret) {
try {
Signature rsaSign = Signature.getInstance("SHA256withRSA");
KeyFactory kf = KeyFactory.getInstance("RSA");
byte[] keySpec = DatatypeConverter.parseBase64Binary(accessKeySecret);
PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(keySpec));
rsaSign.initSign(privateKey);
rsaSign.update(stringToSign.getBytes(ENCODING));
byte[] sign = rsaSign.sign();
String signature = DatatypeConverter.printBase64Binary(sign);
return signature;
} catch (NoSuchAlgorithmException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeySpecException e) {
throw new IllegalArgumentException(e.toString());
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e.toString());
} catch (SignatureException e) {
throw new IllegalArgumentException(e.toString());
} catch (UnsupportedEncodingException e) {
throw new IllegalArgumentException(e.toString());
}
}
@Override
public String signString(String stringToSign, AlibabaCloudCredentials credentials) {
return signString(stringToSign, credentials.getAccessKeySecret());
}
@Override
public String getSignerName() {
return ALGORITHM_NAME;
}
@Override
public String getSignerVersion() {
return "1.0";
}
@Override
public String getSignerType() {
return "PRIVATEKEY";
}
@Override
public byte[] hash(byte[] raw) throws NoSuchAlgorithmException {
return null;
}
@Override
public String getContent() {
return null;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/signers/SignatureAlgorithm.java
|
package com.aliyuncs.auth.signers;
public enum SignatureAlgorithm {
ACS3_HMAC_SHA256("V3"),
ACS3_HMAC_SM3("V3"),
ACS3_RSA_SHA256("V1,V3");
private final String scope;
SignatureAlgorithm(String scope){
this.scope = scope;
}
public String scope() {
return scope;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/sts/AssumeRoleRequest.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth.sts;
import com.aliyuncs.RpcAcsRequest;
import com.aliyuncs.http.ProtocolType;
public class AssumeRoleRequest extends RpcAcsRequest<AssumeRoleResponse> {
private Long durationSeconds;
private String policy;
private String externalId;
private String roleArn;
private String roleSessionName;
public AssumeRoleRequest() {
super("Sts", "2015-04-01", "AssumeRole");
setSysProtocol(ProtocolType.HTTPS);
}
public Long getDurationSeconds() {
return this.durationSeconds;
}
public void setDurationSeconds(Long durationSeconds) {
this.durationSeconds = durationSeconds;
putQueryParameter("DurationSeconds", String.valueOf(durationSeconds));
}
public String getPolicy() {
return this.policy;
}
public void setPolicy(String policy) {
this.policy = policy;
putQueryParameter("Policy", policy);
}
public String getExternalId() {
return this.externalId;
}
public void setExternalId(String externalId) {
this.externalId = externalId;
putQueryParameter("ExternalId", externalId);
}
public String getRoleArn() {
return this.roleArn;
}
public void setRoleArn(String roleArn) {
this.roleArn = roleArn;
putQueryParameter("RoleArn", roleArn);
}
public String getRoleSessionName() {
return this.roleSessionName;
}
public void setRoleSessionName(String roleSessionName) {
this.roleSessionName = roleSessionName;
putQueryParameter("RoleSessionName", roleSessionName);
}
@Override
public Class<AssumeRoleResponse> getResponseClass() {
return AssumeRoleResponse.class;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/sts/AssumeRoleResponse.java
|
package com.aliyuncs.auth.sts;
import com.aliyuncs.AcsResponse;
import com.aliyuncs.transform.UnmarshallerContext;
public class AssumeRoleResponse extends AcsResponse {
private String requestId;
private Credentials credentials;
private AssumedRoleUser assumedRoleUser;
public String getRequestId() {
return this.requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public Credentials getCredentials() {
return this.credentials;
}
public void setCredentials(Credentials credentials) {
this.credentials = credentials;
}
public AssumedRoleUser getAssumedRoleUser() {
return this.assumedRoleUser;
}
public void setAssumedRoleUser(AssumedRoleUser assumedRoleUser) {
this.assumedRoleUser = assumedRoleUser;
}
@Override
public AssumeRoleResponse getInstance(UnmarshallerContext context) {
return AssumeRoleResponseUnmarshaller.unmarshall(this, context);
}
public static class Credentials {
private String securityToken;
private String accessKeySecret;
private String accessKeyId;
private String expiration;
public String getSecurityToken() {
return this.securityToken;
}
public void setSecurityToken(String securityToken) {
this.securityToken = securityToken;
}
public String getAccessKeySecret() {
return this.accessKeySecret;
}
public void setAccessKeySecret(String accessKeySecret) {
this.accessKeySecret = accessKeySecret;
}
public String getAccessKeyId() {
return this.accessKeyId;
}
public void setAccessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
}
public String getExpiration() {
return this.expiration;
}
public void setExpiration(String expiration) {
this.expiration = expiration;
}
}
public static class AssumedRoleUser {
private String arn;
private String assumedRoleId;
public String getArn() {
return this.arn;
}
public void setArn(String arn) {
this.arn = arn;
}
public String getAssumedRoleId() {
return this.assumedRoleId;
}
public void setAssumedRoleId(String assumedRoleId) {
this.assumedRoleId = assumedRoleId;
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/sts/AssumeRoleResponseUnmarshaller.java
|
package com.aliyuncs.auth.sts;
import com.aliyuncs.auth.sts.AssumeRoleResponse.AssumedRoleUser;
import com.aliyuncs.auth.sts.AssumeRoleResponse.Credentials;
import com.aliyuncs.transform.UnmarshallerContext;
public class AssumeRoleResponseUnmarshaller {
public static AssumeRoleResponse unmarshall(AssumeRoleResponse assumeRoleResponse, UnmarshallerContext context) {
assumeRoleResponse.setRequestId(context.stringValue("AssumeRoleResponse.RequestId"));
Credentials credentials = new Credentials();
credentials.setSecurityToken(context.stringValue("AssumeRoleResponse.Credentials.SecurityToken"));
credentials.setAccessKeySecret(context.stringValue("AssumeRoleResponse.Credentials.AccessKeySecret"));
credentials.setAccessKeyId(context.stringValue("AssumeRoleResponse.Credentials.AccessKeyId"));
credentials.setExpiration(context.stringValue("AssumeRoleResponse.Credentials.Expiration"));
assumeRoleResponse.setCredentials(credentials);
AssumedRoleUser assumedRoleUser = new AssumedRoleUser();
assumedRoleUser.setArn(context.stringValue("AssumeRoleResponse.AssumedRoleUser.Arn"));
assumedRoleUser.setAssumedRoleId(context.stringValue("AssumeRoleResponse.AssumedRoleUser.AssumedRoleId"));
assumeRoleResponse.setAssumedRoleUser(assumedRoleUser);
return assumeRoleResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/sts/GenerateSessionAccessKeyResponse.java
|
package com.aliyuncs.auth.sts;
import com.aliyuncs.AcsResponse;
import com.aliyuncs.transform.UnmarshallerContext;
import com.google.gson.annotations.SerializedName;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "GenerateSessionAccessKeyResponse")
public class GenerateSessionAccessKeyResponse extends AcsResponse {
@SerializedName("RequestId")
private String requestId;
@SerializedName("SessionAccessKey")
private SessionAccessKey sessionAccessKey;
public String getRequestId() {
return requestId;
}
@XmlElement(name = "RequestId")
public void setRequestId(String requestId) {
this.requestId = requestId;
}
@XmlElement(name = "SessionAccessKey")
public SessionAccessKey getSessionAccessKey() {
return sessionAccessKey;
}
public void setSessionAccessKey(SessionAccessKey sessionAccessKey) {
this.sessionAccessKey = sessionAccessKey;
}
@Override
public GenerateSessionAccessKeyResponse getInstance(UnmarshallerContext context) {
return GetSessionAccessKeyResponseUnmarshaller.unmarshall(this, context);
}
public static class SessionAccessKey {
@SerializedName("SessionAccessKeyId")
private String sessionAccessKeyId;
@SerializedName("SessionAccessKeySecret")
private String sessionAccessKeySecret;
@SerializedName("Expiration")
private String expiration;
public String getSessionAccessKeyId() {
return sessionAccessKeyId;
}
@XmlElement(name = "SessionAccessKeyId")
public void setSessionAccessKeyId(String sessionAccessKeyId) {
this.sessionAccessKeyId = sessionAccessKeyId;
}
public String getSessionAccessKeySecret() {
return sessionAccessKeySecret;
}
@XmlElement(name = "SessionAccessKeySecret")
public void setSessionAccessKeySecret(String sessionAccessKeySecret) {
this.sessionAccessKeySecret = sessionAccessKeySecret;
}
public String getExpiration() {
return expiration;
}
@XmlElement(name = "Expiration")
public void setExpiration(String expiration) {
this.expiration = expiration;
}
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/sts/GetSessionAccessKeyRequest.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.aliyuncs.auth.sts;
import com.aliyuncs.RpcAcsRequest;
public class GetSessionAccessKeyRequest extends RpcAcsRequest<GenerateSessionAccessKeyResponse> {
private static String version = "2015-04-01";
private static String product = "Sts";
private static String action = "GenerateSessionAccessKey";
private int durationSeconds = 3600;
private String publicKeyId;
public GetSessionAccessKeyRequest() {
super(product, version, action);
}
public int getDurationSeconds() {
return durationSeconds;
}
public void setDurationSeconds(int durationSeconds) {
this.durationSeconds = durationSeconds;
putQueryParameter("DurationSeconds", durationSeconds);
}
public String getPublicKeyId() {
return publicKeyId;
}
public void setPublicKeyId(String publicKeyId) {
this.publicKeyId = publicKeyId;
putQueryParameter("PublicKeyId", publicKeyId);
}
@Override
public Class<GenerateSessionAccessKeyResponse> getResponseClass() {
return GenerateSessionAccessKeyResponse.class;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/auth/sts/GetSessionAccessKeyResponseUnmarshaller.java
|
package com.aliyuncs.auth.sts;
import com.aliyuncs.auth.sts.GenerateSessionAccessKeyResponse.SessionAccessKey;
import com.aliyuncs.transform.UnmarshallerContext;
public class GetSessionAccessKeyResponseUnmarshaller {
public static GenerateSessionAccessKeyResponse unmarshall(GenerateSessionAccessKeyResponse getSessionAccessKeyResponse,
UnmarshallerContext context) {
getSessionAccessKeyResponse.setRequestId(context.stringValue("GenerateSessionAccessKeyResponse.RequestId"));
SessionAccessKey credentials = new SessionAccessKey();
credentials.setSessionAccessKeyId(context.stringValue("GenerateSessionAccessKeyResponse.SessionAccessKey.SessionAccessKeyId"));
credentials.setSessionAccessKeySecret(context.stringValue("GenerateSessionAccessKeyResponse.SessionAccessKey.SessionAccessKeySecret"));
credentials.setExpiration(context.stringValue("GenerateSessionAccessKeyResponse.SessionAccessKey.Expiration"));
getSessionAccessKeyResponse.setSessionAccessKey(credentials);
return getSessionAccessKeyResponse;
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/endpoint/ChainedEndpointResolver.java
|
package com.aliyuncs.endpoint;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ErrorCodeConstant;
import com.aliyuncs.exceptions.ErrorMessageConstant;
import java.util.List;
import java.util.Set;
@SuppressWarnings({"ALL", "AlibabaClassMustHaveAuthor"})
public class ChainedEndpointResolver implements EndpointResolver {
protected List<EndpointResolverBase> endpointResolvers;
public ChainedEndpointResolver(List<EndpointResolverBase> resolverChain) {
this.endpointResolvers = resolverChain;
}
private void checkProductCode(ResolveEndpointRequest request) throws ClientException {
boolean productCodeValid = false;
for (EndpointResolverBase resolver : endpointResolvers) {
if (resolver.isProductCodeValid(request)) {
productCodeValid = true;
}
}
if (!productCodeValid) {
String fmt = "No endpoint for product '%s'.\n" +
"Please check the product code, or set an endpoint for your request explicitly.\n" +
"See https://api.alibabacloud.com/product/%s\n";
throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_RESOLVING_ERROR,
String.format(fmt, request.productCode, request.productCode));
}
}
private void checkRegionId(ResolveEndpointRequest request) throws ClientException {
boolean regionIdValid = false;
for (EndpointResolverBase resolver : endpointResolvers) {
if (resolver.isRegionIdValid(request)) {
regionIdValid = true;
}
}
if (!regionIdValid) {
throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_RESOLVING_ERROR,
String.format(ErrorMessageConstant.INVALID_REGION_ID, request.regionId));
}
}
private String getAvailableRegionsHint(String productCode) {
Set<String> availabeRegions = null;
String availabeRegionsHint = "";
for (EndpointResolverBase resolver : endpointResolvers) {
availabeRegions = resolver.getValidRegionIdsByProduct(productCode);
if (availabeRegions != null) {
availabeRegionsHint = "\nOr you can use the other available regions:";
for (String availabeRegion : availabeRegions) {
availabeRegionsHint += " " + availabeRegion;
}
break;
}
}
return availabeRegionsHint;
}
@Override
public String resolve(ResolveEndpointRequest request) throws ClientException {
for (EndpointResolverBase resolver : endpointResolvers) {
String endpoint = resolver.resolve(request);
if (endpoint != null) {
return endpoint;
}
}
checkProductCode(request);
checkRegionId(request);
String fmt = "No endpoint in the region '%s' for product '%s'.\n" +
"You can set an endpoint for your request explicitly.%s\n" +
"See https://api.alibabacloud.com/product/%s";
String message = String.format(
fmt,
request.regionId,
request.productCode,
getAvailableRegionsHint(request.productCode),
request.productCode
);
throw new ClientException(ErrorCodeConstant.SDK_ENDPOINT_RESOLVING_ERROR, message);
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/endpoint/DefaultEndpointResolver.java
|
package com.aliyuncs.endpoint;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.aliyuncs.utils.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class DefaultEndpointResolver implements EndpointResolver {
public static UserCustomizedEndpointResolver predefinedEndpointResolver = new UserCustomizedEndpointResolver();
private UserCustomizedEndpointResolver userCustomizedEndpointResolver;
private EndpointResolver insideEndpointResolver;
public DefaultEndpointResolver(
IAcsClient client,
String userConfig,
IClientProfile profile) {
userCustomizedEndpointResolver = new UserCustomizedEndpointResolver();
EndpointResolverRules endpointResolverRules = new EndpointResolverRules();
List<EndpointResolverBase> resolverChain = new ArrayList<EndpointResolverBase>();
// The order is very IMPORTANT!
resolverChain.add(predefinedEndpointResolver);
resolverChain.add(userCustomizedEndpointResolver);
if (profile.isUsingVpcEndpoint()) {
resolverChain.add(new UserVpcEndpointResolver());
}
resolverChain.add(endpointResolverRules);
if (userConfig == null) {
resolverChain.add(new LocalConfigRegionalEndpointResolver());
resolverChain.add(new LocalConfigGlobalEndpointResolver());
} else {
resolverChain.add(new LocalConfigRegionalEndpointResolver(userConfig));
resolverChain.add(new LocalConfigGlobalEndpointResolver(userConfig));
}
String locationServiceEndpoint = profile.getLocationServiceEndpoint();
String locationServiceApiVersion = profile.getLocationServiceApiVersion();
if (!StringUtils.isEmpty(locationServiceEndpoint) && !StringUtils.isEmpty(locationServiceApiVersion)) {
resolverChain.add(new LocationServiceEndpointResolver(client,
locationServiceEndpoint,
locationServiceApiVersion));
} else if (profile.isUsingInternalLocationService()) {
resolverChain.add(new LocationServiceEndpointResolver(client,
"location-inner.aliyuncs.com",
"2015-12-25"));
} else {
resolverChain.add(new LocationServiceEndpointResolver(client));
}
insideEndpointResolver = new ChainedEndpointResolver(resolverChain);
}
public DefaultEndpointResolver(IAcsClient client) {
this(client, null, DefaultProfile.getProfile(null));
}
public DefaultEndpointResolver(IAcsClient client, IClientProfile profile) {
this(client, null, profile);
}
@Override
public String resolve(ResolveEndpointRequest request) throws ClientException {
return this.insideEndpointResolver.resolve(request);
}
public void putEndpointEntry(String regionId, String productCode, String endpoint) {
this.userCustomizedEndpointResolver.putEndpointEntry(regionId, productCode, endpoint);
}
}
|
0
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs
|
java-sources/com/aliyun/aliyun-java-sdk-core/4.7.6/com/aliyuncs/endpoint/EndpointResolver.java
|
package com.aliyuncs.endpoint;
import com.aliyuncs.exceptions.ClientException;
public interface EndpointResolver {
String resolve(ResolveEndpointRequest request) throws ClientException;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.