Package org.jets3t.service.utils.signedurl

Examples of org.jets3t.service.utils.signedurl.SignedUrlHandler


                if (signedAclUrl == null) {
                    AccessControlList acl = s3Service.getObjectAcl(bucket, object.getKey());
                    object.setAcl(acl);
                    result = object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    AccessControlList acl = handler.getObjectAclWithSignedUrl(signedAclUrl);
                    URL url = new URL(signedAclUrl);
                    object = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                    object.setAcl(acl);
                    result = object;
                }
View Full Code Here


            try {
                if (signedDeleteUrl == null) {
                    s3Service.deleteObject(bucket, object.getKey());                   
                    result = object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    handler.deleteObjectWithSignedUrl(signedDeleteUrl);
                    URL url = new URL(signedDeleteUrl);
                    result = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                }
            } catch (RuntimeException e) {
                result = e;
View Full Code Here

            try {
                if (headOnly) {
                    if (signedGetOrHeadUrl == null) {
                        result = s3Service.getObjectDetails(bucket, objectKey);
                    } else {
                        SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                        result = handler.getObjectDetailsWithSignedUrl(signedGetOrHeadUrl);
                    }
                } else {
                    if (signedGetOrHeadUrl == null) {
                        result = s3Service.getObject(bucket, objectKey);
                    } else {
                        SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                        result = handler.getObjectWithSignedUrl(signedGetOrHeadUrl);
                    }
                }
            } catch (S3ServiceException e) {
                result = e;
            }           
View Full Code Here

            try {
              if (!downloadPackage.isSignedDownload()) {
                object = s3Service.getObject(bucket, objectKey);
              } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    object = handler.getObjectWithSignedUrl(downloadPackage.getSignedUrl());
              }

                // Setup monitoring of stream bytes tranferred.
                interruptableInputStream = new InterruptableInputStream(object.getDataInputStream());
                bufferedInputStream = new BufferedInputStream(
View Full Code Here

                        signedUrlAndObject.getObject().getDataInputStream());
                    ProgressMonitoredInputStream pmInputStream = new ProgressMonitoredInputStream(
                        interruptableInputStream, progressMonitor);
                    signedUrlAndObject.getObject().setDataInputStream(pmInputStream);
                }
                SignedUrlHandler signedPutUploader = (SignedUrlHandler) s3Service;
                result = signedPutUploader.putObjectWithSignedUrl(
                    signedUrlAndObject.getSignedUrl(), signedUrlAndObject.getObject());
            } catch (S3ServiceException e) {
                result = e;
            } finally {
                try {
View Full Code Here

    public static void main(String[] args) throws Exception {
        // Initialise a SignedUrlHandler, which is an interface implemented by classes able to
        // perform operations in S3 using signed URLs (no AWS Credentials required).
        // The RestS3Service provides an implementation of this interface in JetS3t.
        SignedUrlHandler signedUrlHandler = new RestS3Service(null);

        // Create a bucket to test reading and writing to       
        S3Bucket bucket = new S3Bucket(myBucketName);
       
        // Create an object to use for testing.
        S3Object object = new S3Object(bucket, "urlSigningTestObject.txt", "Hello World!");
       
        // Determine what the time will be in 5 minutes - our signed URLs will be valid for 5 minutes only.
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.MINUTE, 5);
        Date expiryDate = cal.getTime();

        /*
         * Generate the signed URL strings for PUT, GET, HEAD and DELETE operations, using the
         * AWS Credentials in the samples.properties file.
         */
        AWSCredentials awsCredentials = SamplesUtils.loadAWSCredentials();
       
        // Create a signed HTTP PUT URL valid for 5 minutes.       
        String putUrl = S3Service.createSignedPutUrl(bucket.getName(), object.getKey(),
            object.getMetadataMap(), awsCredentials, expiryDate, false);
       
        // Create a signed HTTP GET URL valid for 5 minutes.
        String getUrl = S3Service.createSignedGetUrl(bucket.getName(), object.getKey()
            awsCredentials, expiryDate, false);

        // Create a signed HTTP HEAD URL valid for 5 minutes.
        String headUrl = S3Service.createSignedHeadUrl(bucket.getName(), object.getKey(),
            awsCredentials, expiryDate, false);

        // Create a signed HTTP DELETE URL valid for 5 minutes.
        String deleteUrl = S3Service.createSignedDeleteUrl(bucket.getName(), object.getKey(),
            awsCredentials, expiryDate, false);
       
        System.out.println("Signed PUT URL: " + putUrl);
        System.out.println("Signed GET URL: " + getUrl);
        System.out.println("Signed HEAD URL: " + headUrl);
        System.out.println("Signed DELETE URL: " + deleteUrl);

        System.out.println("Performing PUT with signed URL");
        S3Object putObject = signedUrlHandler.putObjectWithSignedUrl(putUrl, object);
        System.out.println("  Object has been uploaded to S3: " + putObject.getKey());

        System.out.println("Performing HEAD with signed URL");       
        S3Object headObject = signedUrlHandler.getObjectDetailsWithSignedUrl(headUrl);
        System.out.println("  Size of object in S3: " + headObject.getContentLength());

        System.out.println("Performing GET with signed URL");
        S3Object getObject = signedUrlHandler.getObjectWithSignedUrl(getUrl);
        String contentData = (new BufferedReader(
            new InputStreamReader(getObject.getDataInputStream()))).readLine();
        System.out.println("  Content of object in S3: " + contentData);
       
        System.out.println("Performing DELETE with signed URL");
        signedUrlHandler.deleteObjectWithSignedUrl(deleteUrl);
        System.out.println("  Object deleted - the example is finished");
    }
View Full Code Here

                    } else {
                        s3Service.putObjectAcl(bucket, s3Object);                                       
                    }               
                    result = s3Object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    handler.putObjectAclWithSignedUrl(signedUrl, signedUrlAcl);
                    URL url = new URL(signedUrl);
                    S3Object object = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                    object.setAcl(signedUrlAcl);
                    result = object;                   
                }
View Full Code Here

                    } else {
                        s3Service.putObjectAcl(bucket, s3Object);                                       
                    }               
                    result = s3Object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    handler.putObjectAclWithSignedUrl(signedUrl, signedUrlAcl);
                    URL url = new URL(signedUrl);
                    S3Object object = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                    object.setAcl(signedUrlAcl);
                    result = object;                   
                }
View Full Code Here

                if (signedAclUrl == null) {
                    AccessControlList acl = s3Service.getObjectAcl(bucket, object.getKey());
                    object.setAcl(acl);
                    result = object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    AccessControlList acl = handler.getObjectAclWithSignedUrl(signedAclUrl);
                    URL url = new URL(signedAclUrl);
                    object = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                    object.setAcl(acl);
                    result = object;
                }
View Full Code Here

            try {
                if (signedDeleteUrl == null) {
                    s3Service.deleteObject(bucket, object.getKey());                   
                    result = object;
                } else {
                    SignedUrlHandler handler = (SignedUrlHandler) s3Service;
                    handler.deleteObjectWithSignedUrl(signedDeleteUrl);
                    URL url = new URL(signedDeleteUrl);
                    result = ServiceUtils.buildObjectFromUrl(url.getHost(), url.getPath());
                }
            } catch (RuntimeException e) {
                result = e;
View Full Code Here

TOP

Related Classes of org.jets3t.service.utils.signedurl.SignedUrlHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.