|
15 | 15 | */
|
16 | 16 | package org.modeshape.jcr.value.binary;
|
17 | 17 |
|
18 |
| -import java.io.IOException; |
19 |
| -import java.io.InputStream; |
20 |
| -import java.util.Collections; |
21 |
| -import java.util.Date; |
22 |
| -import java.util.Iterator; |
23 |
| -import java.util.Map; |
24 |
| -import java.util.concurrent.TimeUnit; |
25 |
| - |
26 |
| -import javax.jcr.RepositoryException; |
27 |
| - |
28 | 18 | import com.amazonaws.AmazonClientException;
|
| 19 | +import com.amazonaws.auth.AWSCredentialsProvider; |
29 | 20 | import com.amazonaws.auth.BasicAWSCredentials;
|
| 21 | +import com.amazonaws.auth.profile.ProfileCredentialsProvider; |
| 22 | +import com.amazonaws.internal.StaticCredentialsProvider; |
30 | 23 | import com.amazonaws.services.s3.AmazonS3Client;
|
31 | 24 | import com.amazonaws.services.s3.iterable.S3Objects;
|
32 | 25 | import com.amazonaws.services.s3.model.CopyObjectRequest;
|
|
38 | 31 | import org.modeshape.jcr.value.BinaryKey;
|
39 | 32 | import org.modeshape.jcr.value.BinaryValue;
|
40 | 33 |
|
| 34 | +import javax.jcr.RepositoryException; |
| 35 | +import java.io.IOException; |
| 36 | +import java.io.InputStream; |
| 37 | +import java.util.Collections; |
| 38 | +import java.util.Date; |
| 39 | +import java.util.Iterator; |
| 40 | +import java.util.Map; |
| 41 | +import java.util.concurrent.TimeUnit; |
| 42 | + |
41 | 43 | /**
|
42 | 44 | * Binary storage option which manages the storage of files to Amazon S3
|
43 | 45 | *
|
@@ -93,7 +95,14 @@ public S3BinaryStore(String accessKey, String secretKey, String bucketName) thro
|
93 | 95 | */
|
94 | 96 | public S3BinaryStore(String accessKey, String secretKey, String bucketName, String endPoint) throws BinaryStoreException {
|
95 | 97 | this.bucketName = bucketName;
|
96 |
| - this.s3Client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); |
| 98 | + |
| 99 | + AWSCredentialsProvider credentialsProvider; |
| 100 | + if (accessKey == null && secretKey == null) { |
| 101 | + credentialsProvider = new ProfileCredentialsProvider(); |
| 102 | + } else { |
| 103 | + credentialsProvider = new StaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretKey)); |
| 104 | + } |
| 105 | + this.s3Client = new AmazonS3Client(credentialsProvider); |
97 | 106 |
|
98 | 107 | // Support for compatible S3 storage systems
|
99 | 108 | if(endPoint != null)
|
|
0 commit comments