@Override protected void connectToRepository( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider) throws AuthenticationException { if (this.amazonS3 == null) { AWSCredentials awsCredentials; if (authenticationInfo == null) { awsCredentials = null; } else if (authenticationInfo.getPrivateKey() == null) { awsCredentials = createAWSCredentials(authenticationInfo); } else { awsCredentials = createAWSSessionCredentials(authenticationInfo); } ClientConfiguration clientConfiguration = S3Utils.getClientConfiguration(proxyInfoProvider); this.bucketName = S3Utils.getBucketName(repository); this.baseDirectory = S3Utils.getBaseDirectory(repository); this.amazonS3 = new AmazonS3Client(awsCredentials, clientConfiguration); Region region = Region.fromLocationConstraint(this.amazonS3.getBucketLocation(this.bucketName)); this.amazonS3.setEndpoint(region.getEndpoint()); } }