List of usage examples for com.amazonaws ClientConfiguration ClientConfiguration
public ClientConfiguration()
From source file:ch.cyberduck.core.cloudfront.CloudFrontDistributionConfiguration.java
License:Open Source License
public CloudFrontDistributionConfiguration(final S3Session session) { this.session = session; this.bookmark = session.getHost(); final int timeout = preferences.getInteger("connection.timeout.seconds") * 1000; configuration = new ClientConfiguration(); configuration.setConnectionTimeout(timeout); configuration.setSocketTimeout(timeout); final UseragentProvider ua = new PreferencesUseragentProvider(); configuration.setUserAgentPrefix(ua.get()); configuration.setMaxErrorRetry(0);//from w ww .j av a 2s .co m configuration.setMaxConnections(1); configuration.setUseGzip(preferences.getBoolean("http.compression.enable")); final Proxy proxy = ProxyFactory.get().find(bookmark); switch (proxy.getType()) { case HTTP: case HTTPS: configuration.setProxyHost(proxy.getHostname()); configuration.setProxyPort(proxy.getPort()); } locationFeature = session.getFeature(Location.class); }
From source file:ch.cyberduck.core.iam.AmazonIdentityConfiguration.java
License:Open Source License
public AmazonIdentityConfiguration(final Host host, final int timeout) { this.host = host; this.configuration = new ClientConfiguration(); this.configuration.setConnectionTimeout(timeout); this.configuration.setSocketTimeout(timeout); final UseragentProvider ua = new PreferencesUseragentProvider(); this.configuration.setUserAgent(ua.get()); this.configuration.setMaxErrorRetry(0); this.configuration.setMaxConnections(1); this.configuration.setUseGzip(PreferencesFactory.get().getBoolean("http.compression.enable")); final Proxy proxy = ProxyFactory.get().find(host); switch (proxy.getType()) { case HTTP://from w w w.j a va2 s . co m case HTTPS: this.configuration.setProxyHost(proxy.getHostname()); this.configuration.setProxyPort(proxy.getPort()); } }
From source file:ch.cyberduck.core.kms.KMSEncryptionFeature.java
License:Open Source License
public KMSEncryptionFeature(final S3Session session, final int timeout) { super(session); host = session.getHost();/*from w ww. j av a 2 s.c o m*/ this.session = session; configuration = new ClientConfiguration(); configuration.setConnectionTimeout(timeout); configuration.setSocketTimeout(timeout); final UseragentProvider ua = new PreferencesUseragentProvider(); configuration.setUserAgent(ua.get()); configuration.setMaxErrorRetry(0); configuration.setMaxConnections(1); configuration.setUseGzip(PreferencesFactory.get().getBoolean("http.compression.enable")); final Proxy proxy = ProxyFactory.get().find(host); switch (proxy.getType()) { case HTTP: case HTTPS: configuration.setProxyHost(proxy.getHostname()); configuration.setProxyPort(proxy.getPort()); } }
From source file:ch.hesso.master.sweetcity.utils.PictureUtils.java
License:Apache License
public static Key uploadPicture(Bitmap picture, GoogleAccountCredential googleCredential) { if (picture == null) return null; try {// w w w .j a va2 s .co m ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); AmazonS3 s3Connection = new AmazonS3Client(AWS_CREDENTIALS, clientConfig); s3Connection.setEndpoint(ConstantsAWS.S3_END_POINT); ObjectMetadata pictureMetadata = new ObjectMetadata(); String key = String.format(ConstantsAWS.S3_PICTURE_NAME_FORMAT, googleCredential.getSelectedAccountName(), Constants.DATE_FORMAT_IMAGE.format(new Date())); s3Connection.putObject(ConstantsAWS.S3_BUCKET_NAME, key, ImageUtils.bitmapToInputStream(picture), pictureMetadata); return new Key(key); } catch (Exception e) { Log.d(Constants.PROJECT_NAME, e.toString()); } return null; }
From source file:ch.hesso.master.sweetcity.utils.PictureUtils.java
License:Apache License
public static InputStream getPicture(Key key) { if (key == null) return null; try {//from ww w . ja v a 2s .co m ClientConfiguration clientConfig = new ClientConfiguration(); clientConfig.setProtocol(Protocol.HTTP); AmazonS3 s3Connection = new AmazonS3Client(AWS_CREDENTIALS, clientConfig); s3Connection.setEndpoint(ConstantsAWS.S3_END_POINT); S3Object obj = s3Connection.getObject(ConstantsAWS.S3_BUCKET_NAME, key.toString()); return obj.getObjectContent(); } catch (Exception e) { Log.d(Constants.PROJECT_NAME, e.toString()); } return null; }
From source file:clojusc.aws.examples.swf.javaapp.GreeterMain.java
License:Open Source License
public static void main() throws Exception { ClientConfiguration config = new ClientConfiguration().withSocketTimeout(GreeterConstants.clientTimeout); AWSCredentials creds = new BasicAWSCredentials(System.getenv(GreeterConstants.accessKey), System.getenv(GreeterConstants.secretKey)); AmazonSimpleWorkflow service = new AmazonSimpleWorkflowClient(creds, config); service.setEndpoint(GreeterConstants.endpoint); GreeterWorkflowClientExternalFactory factory = new GreeterWorkflowClientExternalFactoryImpl(service, GreeterConstants.domain);//from w ww . j a va 2 s. co m GreeterWorkflowClientExternal greeter = factory.getClient(GreeterConstants.clientId); greeter.greet(); }
From source file:clojusc.aws.examples.swf.javaapp.GreeterWorker.java
License:Open Source License
public static void main() throws Exception { ClientConfiguration config = new ClientConfiguration().withSocketTimeout(GreeterConstants.clientTimeout); AWSCredentials creds = new BasicAWSCredentials(System.getenv(GreeterConstants.accessKey), System.getenv(GreeterConstants.secretKey)); AmazonSimpleWorkflow service = new AmazonSimpleWorkflowClient(creds, config); service.setEndpoint(GreeterConstants.endpoint); ActivityWorker aw = new ActivityWorker(service, GreeterConstants.domain, GreeterConstants.taskListToPoll); aw.addActivitiesImplementation(new GreeterActivitiesImpl()); aw.start();/*from w w w .j av a 2 s. c om*/ WorkflowWorker wfw = new WorkflowWorker(service, GreeterConstants.domain, GreeterConstants.taskListToPoll); wfw.addWorkflowImplementationType(GreeterWorkflowImpl.class); wfw.start(); }
From source file:cloudExplorer.Acl.java
License:Open Source License
void setAccess(String id, int what, String access_key, String secret_key, String endpoint, String bucket) { try {// w ww.jav a 2 s .co m Collection<Grant> grantCollection = new ArrayList<Grant>(); AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); AccessControlList bucketAcl = s3Client.getBucketAcl(bucket); Grant grant = null; if (what == 0) { grant = new Grant(new CanonicalGrantee(id), Permission.Read); grantCollection.add(grant); } if (what == 1) { grant = new Grant(new CanonicalGrantee(id), Permission.FullControl); grantCollection.add(grant); } if (what == 3) { bucketAcl.getGrants().clear(); } bucketAcl.getGrants().addAll(grantCollection); s3Client.setBucketAcl(bucket, bucketAcl); } catch (AmazonServiceException ase) { NewJFrame.jTextArea1.append("\n\nError: " + ase.getErrorMessage()); } }
From source file:cloudExplorer.Acl.java
License:Open Source License
void setACLpublic(String object, String access_key, String secret_key, String endpoint, String bucket) { try {//from ww w . j a v a 2 s . com AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); s3Client.setObjectAcl(bucket, object, CannedAccessControlList.PublicRead); } catch (Exception setACLpublic) { mainFrame.jTextArea1.append("\nException occurred in ACL"); } }
From source file:cloudExplorer.Acl.java
License:Open Source License
void setACLprivate(String object, String access_key, String secret_key, String endpoint, String bucket) { try {//from w w w.j ava 2s . c o m AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); s3Client.setObjectAcl(bucket, object, CannedAccessControlList.Private); } catch (Exception setACLprivate) { mainFrame.jTextArea1.append("\nException occurred in setACLprivate"); } }