正在查看: Hopscotch v9.7.2 应用的 AmazonS3Client.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Hopscotch v9.7.2 应用的 AmazonS3Client.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.amazonaws.services.s3;
import android.support.v4.media.d;
import androidx.privacysandbox.ads.adservices.java.internal.a;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.AmazonWebServiceClient;
import com.amazonaws.AmazonWebServiceRequest;
import com.amazonaws.ClientConfiguration;
import com.amazonaws.DefaultRequest;
import com.amazonaws.Response;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSCredentialsProvider;
import com.amazonaws.auth.DefaultAWSCredentialsProviderChain;
import com.amazonaws.auth.Signer;
import com.amazonaws.auth.SignerFactory;
import com.amazonaws.event.ProgressEvent;
import com.amazonaws.event.ProgressListener;
import com.amazonaws.event.ProgressListenerCallbackExecutor;
import com.amazonaws.event.ProgressReportingInputStream;
import com.amazonaws.handlers.HandlerChainFactory;
import com.amazonaws.handlers.RequestHandler;
import com.amazonaws.handlers.RequestHandler2;
import com.amazonaws.http.ExecutionContext;
import com.amazonaws.http.HttpClient;
import com.amazonaws.http.HttpMethodName;
import com.amazonaws.http.HttpResponseHandler;
import com.amazonaws.http.UrlHttpClient;
import com.amazonaws.internal.StaticCredentialsProvider;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import com.amazonaws.metrics.AwsSdkMetrics;
import com.amazonaws.metrics.RequestMetricCollector;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.RegionUtils;
import com.amazonaws.retry.PredefinedRetryPolicies;
import com.amazonaws.retry.RetryPolicy;
import com.amazonaws.services.s3.internal.AWSS3V4Signer;
import com.amazonaws.services.s3.internal.BucketNameUtils;
import com.amazonaws.services.s3.internal.CompleteMultipartUploadRetryCondition;
import com.amazonaws.services.s3.internal.DigestValidationInputStream;
import com.amazonaws.services.s3.internal.InputSubstream;
import com.amazonaws.services.s3.internal.MD5DigestCalculatingInputStream;
import com.amazonaws.services.s3.internal.ObjectExpirationHeaderHandler;
import com.amazonaws.services.s3.internal.RepeatableFileInputStream;
import com.amazonaws.services.s3.internal.ResponseHeaderHandlerChain;
import com.amazonaws.services.s3.internal.S3ErrorResponseHandler;
import com.amazonaws.services.s3.internal.S3ExecutionContext;
import com.amazonaws.services.s3.internal.S3HttpUtils;
import com.amazonaws.services.s3.internal.S3MetadataResponseHandler;
import com.amazonaws.services.s3.internal.S3ObjectResponseHandler;
import com.amazonaws.services.s3.internal.S3RequesterChargedHeaderHandler;
import com.amazonaws.services.s3.internal.S3Signer;
import com.amazonaws.services.s3.internal.S3VersionHeaderHandler;
import com.amazonaws.services.s3.internal.S3XmlResponseHandler;
import com.amazonaws.services.s3.internal.ServerSideEncryptionHeaderHandler;
import com.amazonaws.services.s3.internal.ServiceUtils;
import com.amazonaws.services.s3.metrics.S3ServiceMetric;
import com.amazonaws.services.s3.model.AbortMultipartUploadRequest;
import com.amazonaws.services.s3.model.AccessControlList;
import com.amazonaws.services.s3.model.AmazonS3Exception;
import com.amazonaws.services.s3.model.CompleteMultipartUploadRequest;
import com.amazonaws.services.s3.model.CompleteMultipartUploadResult;
import com.amazonaws.services.s3.model.CreateBucketRequest;
import com.amazonaws.services.s3.model.GeneratePresignedUrlRequest;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.Grant;
import com.amazonaws.services.s3.model.Grantee;
import com.amazonaws.services.s3.model.HeadBucketRequest;
import com.amazonaws.services.s3.model.HeadBucketResult;
import com.amazonaws.services.s3.model.InitiateMultipartUploadRequest;
import com.amazonaws.services.s3.model.InitiateMultipartUploadResult;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.ObjectTagging;
import com.amazonaws.services.s3.model.Permission;
import com.amazonaws.services.s3.model.ResponseHeaderOverrides;
import com.amazonaws.services.s3.model.S3AccelerateUnsupported;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectInputStream;
import com.amazonaws.services.s3.model.SSEAlgorithm;
import com.amazonaws.services.s3.model.SSEAwsKeyManagementParams;
import com.amazonaws.services.s3.model.SSECustomerKey;
import com.amazonaws.services.s3.model.Tag;
import com.amazonaws.services.s3.model.UploadPartRequest;
import com.amazonaws.services.s3.model.UploadPartResult;
import com.amazonaws.services.s3.model.transform.BucketConfigurationXmlFactory;
import com.amazonaws.services.s3.model.transform.HeadBucketResultHandler;
import com.amazonaws.services.s3.model.transform.RequestPaymentConfigurationXmlFactory;
import com.amazonaws.services.s3.model.transform.RequestXmlFactory;
import com.amazonaws.services.s3.model.transform.XmlResponsesSaxParser;
import com.amazonaws.transform.Unmarshaller;
import com.amazonaws.util.AWSRequestMetrics;
import com.amazonaws.util.Base64;
import com.amazonaws.util.BinaryUtils;
import com.amazonaws.util.DateUtils;
import com.amazonaws.util.LengthCheckInputStream;
import com.amazonaws.util.RuntimeHttpUtils;
import com.amazonaws.util.ServiceClientHolderInputStream;
import com.amazonaws.util.ValidationUtils;
import com.facebook.common.util.ByteConstants;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.FilterInputStream;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
public class AmazonS3Client extends AmazonWebServiceClient implements AmazonS3 {
private static final int BUCKET_REGION_CACHE_SIZE = 300;
private static final String S3_SIGNER = "S3SignerType";
private static final String S3_V4_SIGNER = "AWSS3V4SignerType";
private static final BucketConfigurationXmlFactory bucketConfigurationXmlFactory;
private static final Map<String, String> bucketRegionCache;
private static Log log = LogFactory.b(AmazonS3Client.class);
private static final RequestPaymentConfigurationXmlFactory requestPaymentConfigurationXmlFactory;
private final AWSCredentialsProvider awsCredentialsProvider;
private final CompleteMultipartUploadRetryCondition completeMultipartUploadRetryCondition;
private final S3ErrorResponseHandler errorResponseHandler;
public final S3ClientOptions f;
public volatile String g;
private int notificationThreshold;
private final S3XmlResponseHandler<Void> voidResponseHandler;
static {
AwsSdkMetrics.addAll(Arrays.asList(S3ServiceMetric.a()));
SignerFactory.b(S3Signer.class, S3_SIGNER);
SignerFactory.b(AWSS3V4Signer.class, S3_V4_SIGNER);
bucketConfigurationXmlFactory = new BucketConfigurationXmlFactory();
requestPaymentConfigurationXmlFactory = new RequestPaymentConfigurationXmlFactory();
bucketRegionCache = Collections.synchronizedMap(new LinkedHashMap<String, String>(300, 1.1f, true) {
private static final long serialVersionUID = 23453;
@Override
public final boolean removeEldestEntry(Map.Entry<String, String> entry) {
return size() > 300;
}
});
}
@Deprecated
public AmazonS3Client() {
this(new DefaultAWSCredentialsProviderChain());
}
public static void D(DefaultRequest defaultRequest, ObjectMetadata objectMetadata) {
Map<String, Object> v = objectMetadata.v();
if (v.get("x-amz-server-side-encryption-aws-kms-key-id") != null && !ObjectMetadata.a.equals(v.get("x-amz-server-side-encryption"))) {
throw new IllegalArgumentException("If you specify a KMS key id for server side encryption, you must also set the SSEAlgorithm to ObjectMetadata.KMS_SERVER_SIDE_ENCRYPTION");
}
for (Map.Entry<String, Object> entry : v.entrySet()) {
defaultRequest.a(entry.getKey(), entry.getValue().toString());
}
Date t = objectMetadata.t();
if (t != null) {
defaultRequest.a("Expires", DateUtils.c("EEE, dd MMM yyyy HH:mm:ss z", t));
}
Map<String, String> C = objectMetadata.C();
if (C != null) {
for (Map.Entry<String, String> entry2 : C.entrySet()) {
String key = entry2.getKey();
String value = entry2.getValue();
if (key != null) {
key = key.trim();
}
if (value != null) {
value = value.trim();
}
if (!"x-amz-tagging".equals(key)) {
defaultRequest.a("x-amz-meta-" + key, value);
}
}
}
}
public static void E(DefaultRequest defaultRequest, boolean z) {
if (z) {
defaultRequest.a("x-amz-request-payer", "requester");
}
}
public static void F(DefaultRequest defaultRequest, SSECustomerKey sSECustomerKey) {
if (sSECustomerKey == null) {
return;
}
t(defaultRequest, "x-amz-server-side-encryption-customer-algorithm", sSECustomerKey.a());
t(defaultRequest, "x-amz-server-side-encryption-customer-key", sSECustomerKey.b());
t(defaultRequest, "x-amz-server-side-encryption-customer-key-MD5", sSECustomerKey.c());
if (sSECustomerKey.b() == null || sSECustomerKey.c() != null) {
return;
}
try {
defaultRequest.a("x-amz-server-side-encryption-customer-key-MD5", Base64.encodeAsString(MessageDigest.getInstance("MD5").digest(Base64.decode(sSECustomerKey.b()))));
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
public static String H(ObjectTagging objectTagging) {
if (objectTagging == null || objectTagging.a() == null) {
return null;
}
StringBuilder sb = new StringBuilder();
Iterator<Tag> it = objectTagging.a().iterator();
while (it.hasNext()) {
Tag next = it.next();
sb.append(S3HttpUtils.a(next.a()));
sb.append('=');
sb.append(S3HttpUtils.a(next.b()));
if (it.hasNext()) {
sb.append("&");
}
}
return sb.toString();
}
public static void s(DefaultRequest defaultRequest, AccessControlList accessControlList) {
Set<Grant> a = accessControlList.a();
HashMap hashMap = new HashMap();
for (Grant grant : a) {
if (!hashMap.containsKey(grant.b())) {
hashMap.put(grant.b(), new LinkedList());
}
((Collection) hashMap.get(grant.b())).add(grant.a());
}
for (Permission permission : Permission.values()) {
if (hashMap.containsKey(permission)) {
Collection<Grantee> collection = (Collection) hashMap.get(permission);
StringBuilder sb = new StringBuilder();
boolean z = false;
for (Grantee grantee : collection) {
if (z) {
sb.append(", ");
} else {
z = true;
}
sb.append(grantee.getTypeIdentifier());
sb.append("=\"");
sb.append(grantee.getIdentifier());
sb.append("\"");
}
defaultRequest.a(permission.getHeaderName(), sb.toString());
}
}
}
public static void t(DefaultRequest defaultRequest, String str, String str2) {
if (str2 != null) {
defaultRequest.a(str, str2);
}
}
public static void u(DefaultRequest defaultRequest, String str, List list) {
if (list == null || list.isEmpty()) {
return;
}
int i = ServiceUtils.a;
Iterator it = list.iterator();
String str2 = "";
boolean z = true;
while (it.hasNext()) {
String str3 = (String) it.next();
if (!z) {
str2 = a.g(str2, ", ");
}
str2 = a.g(str2, str3);
z = false;
}
defaultRequest.a(str, str2);
}
@Deprecated
public static S3Signer w(DefaultRequest defaultRequest, String str, String str2) {
StringBuilder sb = new StringBuilder("/");
sb.append(str != null ? str.concat("/") : "");
if (str2 == null) {
str2 = "";
}
sb.append(str2);
return new S3Signer(defaultRequest.f().toString(), sb.toString());
}
public static void z(ProgressListenerCallbackExecutor progressListenerCallbackExecutor, int i) {
if (progressListenerCallbackExecutor == null) {
return;
}
ProgressEvent progressEvent = new ProgressEvent(0L);
progressEvent.b = i;
progressListenerCallbackExecutor.b(progressEvent);
}
@Deprecated
public final void A() {
super.p("s3.amazonaws.com");
this.e = "s3";
HandlerChainFactory handlerChainFactory = new HandlerChainFactory();
this.d.addAll(handlerChainFactory.a(RequestHandler.class, "/com/amazonaws/services/s3/request.handlers"));
this.d.addAll(handlerChainFactory.a(RequestHandler2.class, "/com/amazonaws/services/s3/request.handler2s"));
}
public final Object B(DefaultRequest defaultRequest, HttpResponseHandler httpResponseHandler, String str, String str2) {
AmazonWebServiceRequest g = defaultRequest.g();
ExecutionContext i = i(g);
AWSRequestMetrics a = i.a();
defaultRequest.m(a);
a.f(AWSRequestMetrics.Field.ClientExecuteTime);
Response response = null;
try {
try {
defaultRequest.u();
if (!defaultRequest.e().containsKey("Content-Type")) {
defaultRequest.a("Content-Type", "application/octet-stream");
}
if (str != null && !(defaultRequest.g() instanceof CreateBucketRequest) && C(defaultRequest)) {
y(str);
}
AWSCredentials a2 = this.awsCredentialsProvider.a();
if (g.e() != null) {
a2 = g.e();
}
i.g(x(defaultRequest, str, str2));
i.f(a2);
response = this.c.b(defaultRequest, httpResponseHandler, this.errorResponseHandler, i);
Object a3 = response.a();
j(a, defaultRequest, response, false);
return a3;
} catch (AmazonS3Exception e) {
if (e.d() == 301 && e.k() != null) {
String str3 = e.k().get("x-amz-bucket-region");
bucketRegionCache.put(str, str3);
e.f("The bucket is in this region: " + str3 + ". Please use this region to retry the request");
}
throw e;
}
} catch (Throwable th) {
j(a, defaultRequest, response, false);
throw th;
}
}
public final boolean C(DefaultRequest defaultRequest) {
if (defaultRequest.d().getHost().endsWith("s3.amazonaws.com")) {
String n = n();
if (n == null) {
n = this.g;
}
if (n == null) {
return true;
}
}
return false;
}
public final void G(DefaultRequest defaultRequest, String str, String str2, URI uri) {
int i;
if (uri == null) {
uri = this.a;
}
if (!this.f.d() && BucketNameUtils.isDNSBucketName(str)) {
String host = uri.getHost();
if (host != null) {
String[] split = host.split("\\.");
if (split.length == 4) {
int length = split.length;
while (i < length) {
try {
int parseInt = Integer.parseInt(split[i]);
i = (parseInt >= 0 && parseInt <= 255) ? i + 1 : 0;
} catch (NumberFormatException unused) {
}
}
}
}
log.d("Using virtual style addressing. Endpoint = " + uri);
try {
defaultRequest.o(new URI(uri.getScheme() + "://" + str + "." + uri.getAuthority()));
defaultRequest.s((str2 == null || !str2.startsWith("/")) ? str2 : "/".concat(str2));
log.d("Key: " + str2 + "; Request: " + defaultRequest);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(a.o("Invalid bucket name: ", str), e);
}
}
log.d("Using path style addressing. Endpoint = " + uri);
defaultRequest.o(uri);
if (str != null) {
StringBuilder j = d.j(str, "/");
j.append(str2 != null ? str2 : "");
defaultRequest.s(j.toString());
}
log.d("Key: " + str2 + "; Request: " + defaultRequest);
}
@Override
public final CompleteMultipartUploadResult a(CompleteMultipartUploadRequest completeMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
String h = completeMultipartUploadRequest.h();
String i = completeMultipartUploadRequest.i();
String k = completeMultipartUploadRequest.k();
ValidationUtils.a(h, "The bucket name parameter must be specified when completing a multipart upload");
ValidationUtils.a(i, "The key parameter must be specified when completing a multipart upload");
ValidationUtils.a(k, "The upload ID parameter must be specified when completing a multipart upload");
ValidationUtils.a(completeMultipartUploadRequest.j(), "The part ETags parameter must be specified when completing a multipart upload");
int i2 = 0;
while (true) {
DefaultRequest v = v(h, i, completeMultipartUploadRequest, HttpMethodName.POST, null);
v.b("uploadId", k);
E(v, completeMultipartUploadRequest.l());
byte[] a = RequestXmlFactory.a(completeMultipartUploadRequest.j());
v.a("Content-Type", "application/xml");
v.a("Content-Length", String.valueOf(a.length));
v.n(new ByteArrayInputStream(a));
XmlResponsesSaxParser.CompleteMultipartUploadHandler completeMultipartUploadHandler = (XmlResponsesSaxParser.CompleteMultipartUploadHandler) B(v, new ResponseHeaderHandlerChain(new Unmarshaller<XmlResponsesSaxParser.CompleteMultipartUploadHandler, InputStream>() {
@Override
public final XmlResponsesSaxParser.CompleteMultipartUploadHandler a(InputStream inputStream) throws Exception {
XmlResponsesSaxParser xmlResponsesSaxParser = new XmlResponsesSaxParser();
XmlResponsesSaxParser.CompleteMultipartUploadHandler completeMultipartUploadHandler2 = new XmlResponsesSaxParser.CompleteMultipartUploadHandler();
xmlResponsesSaxParser.f(completeMultipartUploadHandler2, inputStream);
return completeMultipartUploadHandler2;
}
}, new ServerSideEncryptionHeaderHandler(), new ObjectExpirationHeaderHandler(), new S3VersionHeaderHandler(), new S3RequesterChargedHeaderHandler()), h, i);
if (completeMultipartUploadHandler.o() != null) {
return completeMultipartUploadHandler.o();
}
AmazonS3Exception n = completeMultipartUploadHandler.n();
int i3 = i2 + 1;
RetryPolicy d = this.b.d();
if (!((d == null || d.c() == null || d == PredefinedRetryPolicies.a) ? false : this.completeMultipartUploadRetryCondition.a(n, i2))) {
throw completeMultipartUploadHandler.n();
}
i2 = i3;
}
}
@Override
public final InitiateMultipartUploadResult b(InitiateMultipartUploadRequest initiateMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
ValidationUtils.a(initiateMultipartUploadRequest.i(), "The bucket name parameter must be specified when initiating a multipart upload");
ValidationUtils.a(initiateMultipartUploadRequest.k(), "The key parameter must be specified when initiating a multipart upload");
DefaultRequest v = v(initiateMultipartUploadRequest.i(), initiateMultipartUploadRequest.k(), initiateMultipartUploadRequest, HttpMethodName.POST, null);
v.b("uploads", null);
if (initiateMultipartUploadRequest.o() != null) {
v.a("x-amz-storage-class", initiateMultipartUploadRequest.o().toString());
}
if (initiateMultipartUploadRequest.l() != null) {
v.a("x-amz-website-redirect-location", initiateMultipartUploadRequest.l());
}
if (initiateMultipartUploadRequest.h() != null) {
s(v, initiateMultipartUploadRequest.h());
} else if (initiateMultipartUploadRequest.j() != null) {
v.a("x-amz-acl", initiateMultipartUploadRequest.j().toString());
}
ObjectMetadata objectMetadata = initiateMultipartUploadRequest.a;
if (objectMetadata != null) {
D(v, objectMetadata);
}
t(v, "x-amz-tagging", H(initiateMultipartUploadRequest.p()));
E(v, initiateMultipartUploadRequest.q());
F(v, initiateMultipartUploadRequest.n());
SSEAwsKeyManagementParams m = initiateMultipartUploadRequest.m();
if (m != null) {
t(v, "x-amz-server-side-encryption", SSEAlgorithm.KMS.getAlgorithm());
t(v, "x-amz-server-side-encryption-aws-kms-key-id", m.a());
}
v.a("Content-Length", String.valueOf(0));
v.n(new ByteArrayInputStream(new byte[0]));
return (InitiateMultipartUploadResult) B(v, new ResponseHeaderHandlerChain(new Unmarshaller<InitiateMultipartUploadResult, InputStream>() {
@Override
public final InitiateMultipartUploadResult a(InputStream inputStream) throws Exception {
XmlResponsesSaxParser xmlResponsesSaxParser = new XmlResponsesSaxParser();
XmlResponsesSaxParser.InitiateMultipartUploadHandler initiateMultipartUploadHandler = new XmlResponsesSaxParser.InitiateMultipartUploadHandler();
xmlResponsesSaxParser.f(initiateMultipartUploadHandler, inputStream);
return initiateMultipartUploadHandler.m();
}
}, new ServerSideEncryptionHeaderHandler()), initiateMultipartUploadRequest.i(), initiateMultipartUploadRequest.k());
}
@Override
public final S3Object c(GetObjectRequest getObjectRequest) throws AmazonClientException, AmazonServiceException {
ProgressListenerCallbackExecutor progressListenerCallbackExecutor;
S3ClientOptions s3ClientOptions = this.f;
ValidationUtils.a(getObjectRequest.h(), "The bucket name parameter must be specified when requesting an object");
ValidationUtils.a(getObjectRequest.i(), "The key parameter must be specified when requesting an object");
DefaultRequest v = v(getObjectRequest.h(), getObjectRequest.i(), getObjectRequest, HttpMethodName.GET, null);
if (getObjectRequest.q() != null) {
v.b("versionId", getObjectRequest.q());
}
long[] m = getObjectRequest.m();
if (m != null) {
String str = "bytes=" + Long.toString(m[0]) + "-";
if (m[1] >= 0) {
StringBuilder i = d.i(str);
i.append(Long.toString(m[1]));
str = i.toString();
}
v.a("Range", str);
}
E(v, getObjectRequest.r());
ResponseHeaderOverrides n = getObjectRequest.n();
if (n != null) {
if (n.h() != null) {
v.b("response-cache-control", n.h());
}
if (n.i() != null) {
v.b("response-content-disposition", n.i());
}
if (n.j() != null) {
v.b("response-content-encoding", n.j());
}
if (n.k() != null) {
v.b("response-content-language", n.k());
}
if (n.l() != null) {
v.b("response-content-type", n.l());
}
if (n.m() != null) {
v.b("response-expires", n.m());
}
}
Date k = getObjectRequest.k();
if (k != null) {
int i2 = ServiceUtils.a;
v.a("If-Modified-Since", DateUtils.c("EEE, dd MMM yyyy HH:mm:ss z", k));
}
Date p = getObjectRequest.p();
if (p != null) {
int i3 = ServiceUtils.a;
v.a("If-Unmodified-Since", DateUtils.c("EEE, dd MMM yyyy HH:mm:ss z", p));
}
u(v, "If-Match", getObjectRequest.j());
u(v, "If-None-Match", getObjectRequest.l());
F(v, getObjectRequest.o());
ProgressListener c = getObjectRequest.c();
if (c == null) {
ExecutorService executorService = ProgressListenerCallbackExecutor.a;
progressListenerCallbackExecutor = null;
} else {
progressListenerCallbackExecutor = new ProgressListenerCallbackExecutor(c);
}
try {
S3Object s3Object = (S3Object) B(v, new S3ObjectResponseHandler(), getObjectRequest.h(), getObjectRequest.i());
s3Object.f(getObjectRequest.h());
s3Object.g(getObjectRequest.i());
FilterInputStream serviceClientHolderInputStream = new ServiceClientHolderInputStream(s3Object.a(), this);
if (progressListenerCallbackExecutor != null) {
ProgressReportingInputStream progressReportingInputStream = new ProgressReportingInputStream(serviceClientHolderInputStream, progressListenerCallbackExecutor);
progressReportingInputStream.f();
progressReportingInputStream.g(this.notificationThreshold);
z(progressListenerCallbackExecutor, 2);
serviceClientHolderInputStream = progressReportingInputStream;
}
if (ServiceUtils.b(getObjectRequest, s3ClientOptions) || ServiceUtils.c(s3Object.b(), s3ClientOptions)) {
serviceClientHolderInputStream = new LengthCheckInputStream(serviceClientHolderInputStream, s3Object.b().n(), true);
} else {
String q = s3Object.b().q();
if (q != null && !q.contains("-")) {
try {
serviceClientHolderInputStream = new DigestValidationInputStream(serviceClientHolderInputStream, MessageDigest.getInstance("MD5"), BinaryUtils.a(s3Object.b().q()));
} catch (NoSuchAlgorithmException e) {
log.k("No MD5 digest algorithm available. Unable to calculate checksum and verify data integrity.", e);
}
}
}
s3Object.h(new S3ObjectInputStream(serviceClientHolderInputStream));
return s3Object;
} catch (AmazonS3Exception e2) {
if (e2.d() == 412 || e2.d() == 304) {
z(progressListenerCallbackExecutor, 16);
return null;
}
z(progressListenerCallbackExecutor, 8);
throw e2;
}
}
@Override
public final UploadPartResult d(UploadPartRequest uploadPartRequest) throws AmazonClientException, AmazonServiceException {
InputStream inputSubstream;
MD5DigestCalculatingInputStream mD5DigestCalculatingInputStream;
ValidationUtils.a(uploadPartRequest, "The request parameter must be specified when uploading a part");
String h = uploadPartRequest.h();
String m = uploadPartRequest.m();
String s = uploadPartRequest.s();
int p = uploadPartRequest.p();
long q = uploadPartRequest.q();
ValidationUtils.a(h, "The bucket name parameter must be specified when uploading a part");
ValidationUtils.a(m, "The key parameter must be specified when uploading a part");
ValidationUtils.a(s, "The upload ID parameter must be specified when uploading a part");
DefaultRequest v = v(h, m, uploadPartRequest, HttpMethodName.PUT, null);
v.b("uploadId", s);
v.b("partNumber", Integer.toString(p));
ObjectMetadata o = uploadPartRequest.o();
if (o != null) {
D(v, o);
}
t(v, "Content-MD5", uploadPartRequest.n());
v.a("Content-Length", Long.toString(q));
E(v, uploadPartRequest.t());
F(v, uploadPartRequest.r());
if (uploadPartRequest.l() != null) {
inputSubstream = uploadPartRequest.l();
} else {
if (uploadPartRequest.i() == null) {
throw new IllegalArgumentException("A File or InputStream must be specified when uploading part");
}
try {
inputSubstream = new InputSubstream(new RepeatableFileInputStream(uploadPartRequest.i()), uploadPartRequest.j(), q, true);
} catch (FileNotFoundException e) {
throw new IllegalArgumentException("The specified file doesn't exist", e);
}
}
String n = uploadPartRequest.n();
S3ClientOptions s3ClientOptions = this.f;
ProgressListenerCallbackExecutor progressListenerCallbackExecutor = null;
if (n != null || ServiceUtils.b(uploadPartRequest, s3ClientOptions)) {
mD5DigestCalculatingInputStream = null;
} else {
mD5DigestCalculatingInputStream = new MD5DigestCalculatingInputStream(inputSubstream);
inputSubstream = mD5DigestCalculatingInputStream;
}
ProgressListener c = uploadPartRequest.c();
if (c == null) {
ExecutorService executorService = ProgressListenerCallbackExecutor.a;
} else {
progressListenerCallbackExecutor = new ProgressListenerCallbackExecutor(c);
}
if (progressListenerCallbackExecutor != null) {
ProgressReportingInputStream progressReportingInputStream = new ProgressReportingInputStream(inputSubstream, progressListenerCallbackExecutor);
progressReportingInputStream.g(this.notificationThreshold);
z(progressListenerCallbackExecutor, ByteConstants.KB);
inputSubstream = progressReportingInputStream;
}
try {
try {
v.n(inputSubstream);
ObjectMetadata objectMetadata = (ObjectMetadata) B(v, new S3MetadataResponseHandler(), h, m);
if (objectMetadata != null && mD5DigestCalculatingInputStream != null && !ServiceUtils.c(objectMetadata, s3ClientOptions) && !Arrays.equals(mD5DigestCalculatingInputStream.f(), BinaryUtils.a(objectMetadata.q()))) {
throw new AmazonClientException("Unable to verify integrity of data upload. Client calculated content hash didn't match hash calculated by Amazon S3. You may need to delete the data stored in Amazon S3.");
}
z(progressListenerCallbackExecutor, 2048);
UploadPartResult uploadPartResult = new UploadPartResult();
uploadPartResult.i(objectMetadata.q());
uploadPartResult.j(p);
uploadPartResult.f(objectMetadata.x());
uploadPartResult.b(objectMetadata.z());
uploadPartResult.g(objectMetadata.A());
uploadPartResult.d(objectMetadata.E());
if (inputSubstream != null) {
try {
inputSubstream.close();
} catch (Exception unused) {
}
}
return uploadPartResult;
} catch (Throwable th) {
if (inputSubstream != null) {
try {
inputSubstream.close();
} catch (Exception unused2) {
}
}
throw th;
}
} catch (AmazonClientException e2) {
z(progressListenerCallbackExecutor, 4096);
throw e2;
}
}
@Override
public final void e(AbortMultipartUploadRequest abortMultipartUploadRequest) throws AmazonClientException, AmazonServiceException {
ValidationUtils.a(abortMultipartUploadRequest.h(), "The bucket name parameter must be specified when aborting a multipart upload");
ValidationUtils.a(abortMultipartUploadRequest.i(), "The key parameter must be specified when aborting a multipart upload");
ValidationUtils.a(abortMultipartUploadRequest.j(), "The upload ID parameter must be specified when aborting a multipart upload");
String h = abortMultipartUploadRequest.h();
String i = abortMultipartUploadRequest.i();
DefaultRequest v = v(h, i, abortMultipartUploadRequest, HttpMethodName.DELETE, null);
v.b("uploadId", abortMultipartUploadRequest.j());
E(v, abortMultipartUploadRequest.k());
B(v, this.voidResponseHandler, h, i);
}
@Override
public final com.amazonaws.services.s3.model.PutObjectResult f(com.amazonaws.services.s3.model.PutObjectRequest r19) throws com.amazonaws.AmazonClientException, com.amazonaws.AmazonServiceException {
throw new UnsupportedOperationException("Method not decompiled: com.amazonaws.services.s3.AmazonS3Client.f(com.amazonaws.services.s3.model.PutObjectRequest):com.amazonaws.services.s3.model.PutObjectResult");
}
@Override
public final ExecutionContext i(AmazonWebServiceRequest amazonWebServiceRequest) {
return new S3ExecutionContext(this.d, o(amazonWebServiceRequest) || System.getProperty("com.amazonaws.sdk.enableRuntimeProfiling") != null, this);
}
@Override
public final void p(String str) {
super.p("s3.amazonaws.com");
}
@Override
public final void q(Region region) {
super.q(region);
this.g = region.d();
}
public final DefaultRequest v(String str, String str2, AmazonWebServiceRequest amazonWebServiceRequest, HttpMethodName httpMethodName, URI uri) {
DefaultRequest defaultRequest = new DefaultRequest(amazonWebServiceRequest, "Amazon S3");
S3ClientOptions s3ClientOptions = this.f;
if (s3ClientOptions.a() && !(defaultRequest.g() instanceof S3AccelerateUnsupported)) {
uri = s3ClientOptions.c() ? RuntimeHttpUtils.a("s3-accelerate.dualstack.amazonaws.com", this.b) : RuntimeHttpUtils.a("s3-accelerate.amazonaws.com", this.b);
}
defaultRequest.q(httpMethodName);
G(defaultRequest, str, str2, uri);
return defaultRequest;
}
public final Signer x(DefaultRequest defaultRequest, String str, String str2) {
Signer m = m(this.f.a() ? this.a : defaultRequest.d());
ClientConfiguration clientConfiguration = this.b;
if (clientConfiguration == null || clientConfiguration.e() == null) {
if ((m instanceof AWSS3V4Signer) && C(defaultRequest)) {
String str3 = this.g == null ? bucketRegionCache.get(str) : this.g;
if (str3 != null) {
G(defaultRequest, str, str2, RuntimeHttpUtils.a(RegionUtils.a(str3).e("s3"), this.b));
AWSS3V4Signer aWSS3V4Signer = (AWSS3V4Signer) m;
aWSS3V4Signer.a = l();
aWSS3V4Signer.b = str3;
return aWSS3V4Signer;
}
if (defaultRequest.g() instanceof GeneratePresignedUrlRequest) {
return w(defaultRequest, str, str2);
}
}
String n = n() == null ? this.g == null ? bucketRegionCache.get(str) : this.g : n();
if (n != null) {
AWSS3V4Signer aWSS3V4Signer2 = new AWSS3V4Signer();
aWSS3V4Signer2.a = l();
aWSS3V4Signer2.b = n;
return aWSS3V4Signer2;
}
}
return m instanceof S3Signer ? w(defaultRequest, str, str2) : m;
}
public final void y(String str) {
String str2 = bucketRegionCache.get(str);
if (str2 == null) {
if (log.e()) {
log.d("Bucket region cache doesn't have an entry for " + str + ". Trying to get bucket region from Amazon S3.");
}
str2 = null;
try {
str2 = ((HeadBucketResult) B(v(str, null, new HeadBucketRequest(str), HttpMethodName.HEAD, new URI("https://s3-us-west-1.amazonaws.com")), new HeadBucketResultHandler(), str, null)).a();
} catch (AmazonS3Exception e) {
if (e.k() != null) {
str2 = e.k().get("x-amz-bucket-region");
}
} catch (URISyntaxException unused) {
log.b("Error while creating URI");
}
if (str2 == null && log.e()) {
log.d("Not able to derive region of the " + str + " from the HEAD Bucket requests.");
}
if (str2 != null) {
bucketRegionCache.put(str, str2);
}
}
if (log.e()) {
log.d("Region for " + str + " is " + str2);
}
}
@Deprecated
public AmazonS3Client(AWSCredentials aWSCredentials) {
this(aWSCredentials, new ClientConfiguration());
}
@Deprecated
public AmazonS3Client(AWSCredentials aWSCredentials, ClientConfiguration clientConfiguration) {
this(new StaticCredentialsProvider(aWSCredentials), clientConfiguration);
}
@Deprecated
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider) {
this(aWSCredentialsProvider, new ClientConfiguration());
}
@Deprecated
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider, ClientConfiguration clientConfiguration) {
this(aWSCredentialsProvider, clientConfiguration, new UrlHttpClient(clientConfiguration));
}
@Deprecated
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider, ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector) {
super(clientConfiguration, new UrlHttpClient(clientConfiguration), requestMetricCollector);
this.errorResponseHandler = new S3ErrorResponseHandler();
this.voidResponseHandler = new S3XmlResponseHandler<>(null);
this.f = new S3ClientOptions();
this.notificationThreshold = ByteConstants.KB;
this.completeMultipartUploadRetryCondition = new CompleteMultipartUploadRetryCondition();
this.awsCredentialsProvider = aWSCredentialsProvider;
A();
}
@Deprecated
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider, ClientConfiguration clientConfiguration, HttpClient httpClient) {
super(clientConfiguration, httpClient);
this.errorResponseHandler = new S3ErrorResponseHandler();
this.voidResponseHandler = new S3XmlResponseHandler<>(null);
this.f = new S3ClientOptions();
this.notificationThreshold = ByteConstants.KB;
this.completeMultipartUploadRetryCondition = new CompleteMultipartUploadRetryCondition();
this.awsCredentialsProvider = aWSCredentialsProvider;
A();
}
@Deprecated
public AmazonS3Client(ClientConfiguration clientConfiguration) {
this(new DefaultAWSCredentialsProviderChain(), clientConfiguration);
}
public AmazonS3Client(AWSCredentials aWSCredentials, Region region) {
this(aWSCredentials, region, new ClientConfiguration());
}
public AmazonS3Client(AWSCredentials aWSCredentials, Region region, ClientConfiguration clientConfiguration) {
this(aWSCredentials, region, clientConfiguration, new UrlHttpClient(clientConfiguration));
}
public AmazonS3Client(AWSCredentials aWSCredentials, Region region, ClientConfiguration clientConfiguration, HttpClient httpClient) {
this(new StaticCredentialsProvider(aWSCredentials), region, clientConfiguration, httpClient);
}
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider, Region region) {
this(aWSCredentialsProvider, region, new ClientConfiguration());
}
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider, Region region, ClientConfiguration clientConfiguration) {
this(aWSCredentialsProvider, region, clientConfiguration, new UrlHttpClient(clientConfiguration));
}
public AmazonS3Client(AWSCredentialsProvider aWSCredentialsProvider, Region region, ClientConfiguration clientConfiguration, HttpClient httpClient) {
super(clientConfiguration, httpClient);
this.errorResponseHandler = new S3ErrorResponseHandler();
this.voidResponseHandler = new S3XmlResponseHandler<>(null);
this.f = new S3ClientOptions();
this.notificationThreshold = ByteConstants.KB;
this.completeMultipartUploadRetryCondition = new CompleteMultipartUploadRetryCondition();
this.awsCredentialsProvider = aWSCredentialsProvider;
if (aWSCredentialsProvider == null) {
throw new IllegalArgumentException("Credentials cannot be null. Credentials is required to sign the request");
}
if (region != null) {
this.b = clientConfiguration;
this.e = "s3";
super.p("s3.amazonaws.com");
q(region);
HandlerChainFactory handlerChainFactory = new HandlerChainFactory();
this.d.addAll(handlerChainFactory.a(RequestHandler.class, "/com/amazonaws/services/s3/request.handlers"));
this.d.addAll(handlerChainFactory.a(RequestHandler2.class, "/com/amazonaws/services/s3/request.handler2s"));
log.d("initialized with endpoint = " + this.a);
return;
}
throw new IllegalArgumentException("Region cannot be null. Region is required to sign the request");
}
public AmazonS3Client(ClientConfiguration clientConfiguration, Region region) {
this(new DefaultAWSCredentialsProviderChain(), region, clientConfiguration);
}
}