Package org.jets3t.service.acl

Examples of org.jets3t.service.acl.AccessControlList


    /**
     * Updates the ACL settings for the currently selected bucket.
     */
    private void updateBucketAccessControlList() {
        try {
            AccessControlList bucketACL = s3ServiceMulti.getS3Service().getBucketAcl(currentSelectedBucket);
           
            AccessControlList updatedBucketACL = AccessControlDialog.showDialog(
                ownerFrame, new S3Bucket[] {currentSelectedBucket}, bucketACL, this);
            if (updatedBucketACL != null) {
                currentSelectedBucket.setAcl(updatedBucketACL);
                s3ServiceMulti.getS3Service().putBucketAcl(currentSelectedBucket);
            }
View Full Code Here


                final AccessControlList[] updatedObjectACL = new AccessControlList[] {null};
                               
                runInDispatcherThreadImmediately(new Runnable() {
                    public void run() {
                        // Build merged ACL containing ALL relevant permissions
                        AccessControlList mergedACL = new AccessControlList();
                        for (int i = 0; i < selectedObjects.length; i++) {
                            AccessControlList objectACL = selectedObjects[i].getAcl();
                            mergedACL.grantAllPermissions(objectACL.getGrants());
                           
                            // BEWARE! Here we assume that all the objects have the same owner...
                            if (mergedACL.getOwner() == null) {
                                mergedACL.setOwner(objectACL.getOwner());
                            }
                        }
                       
                        // Show ACL dialog box for user to change ACL settings for all objects.
                        updatedObjectACL[0] = AccessControlDialog.showDialog(
View Full Code Here

        }

        public void run() {
            try {
                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

     * Updates the ACL settings for the currently selected bucket.
     */
    private void updateBucketAccessControlList() {
        try {
            S3Bucket currentBucket = getCurrentSelectedBucket();
            AccessControlList bucketACL = s3ServiceMulti.getS3Service().getBucketAcl(currentBucket);
           
            AccessControlList updatedBucketACL = AccessControlDialog.showDialog(
                ownerFrame, new S3Bucket[] {currentBucket}, bucketACL, this);
            if (updatedBucketACL != null) {
                currentBucket.setAcl(updatedBucketACL);
                s3ServiceMulti.getS3Service().putBucketAcl(currentBucket);
            }
View Full Code Here

                final AccessControlList[] updatedObjectACL = new AccessControlList[] {null};
                               
                runInDispatcherThreadImmediately(new Runnable() {
                    public void run() {
                        // Build merged ACL containing ALL relevant permissions
                        AccessControlList mergedACL = new AccessControlList();
                        for (int i = 0; i < selectedObjects.length; i++) {
                            AccessControlList objectACL = selectedObjects[i].getAcl();
                            mergedACL.grantAllPermissions(objectACL.getGrants());
                           
                            // BEWARE! Here we assume that all the objects have the same owner...
                            if (mergedACL.getOwner() == null) {
                                mergedACL.setOwner(objectACL.getOwner());
                            }
                        }
                       
                        // Show ACL dialog box for user to change ACL settings for all objects.
                        updatedObjectACL[0] = AccessControlDialog.showDialog(
View Full Code Here

                    dialog.setVisible(true);
                   
                    // Update ACL setting.
                    S3Object minimalObject = new S3Object(object.getKey());
   
                    AccessControlList newAcl = (dialog.isPublicAclSet()
                        ? AccessControlList.REST_CANNED_PUBLIC_READ
                        : AccessControlList.REST_CANNED_PRIVATE);
                   
                    if (newAcl != null) {
                        if (AccessControlList.REST_CANNED_PRIVATE.equals(newAcl)) {                                   
View Full Code Here

        S3Bucket publicBucket = new S3Bucket(awsCredentials.getAccessKey() + ".publicBucket");
        s3Service.createBucket(publicBucket);
       
        // Retrieve the bucket's ACL and modify it to grant public access,
        // ie READ access to the ALL_USERS group.
        AccessControlList bucketAcl = s3Service.getBucketAcl(publicBucket);
        bucketAcl.grantPermission(GroupGrantee.ALL_USERS, Permission.PERMISSION_READ);
       
        // Update the bucket's ACL. Now anyone can view the list of objects in this bucket.
        publicBucket.setAcl(bucketAcl);
        s3Service.putBucketAcl(publicBucket);
        System.out.println("View bucket's object listing here: http://s3.amazonaws.com/"
            + publicBucket.getName());
       
        // Now let's create an object that is public from scratch. Note that we will use the bucket's
        // public ACL object created above, this works fine. Although it is possible to create an
        // AccessControlList object from scratch, this is more involved as you need to set the
        // ACL's Owner information which is only readily available from an existing ACL.
       
        // Create a public object in S3. Anyone can download this object.
        S3Object publicObject = new S3Object(
            publicBucket, "publicObject.txt", "This object is public");
        publicObject.setAcl(bucketAcl);
        s3Service.putObject(publicBucket, publicObject);       
        System.out.println("View public object contents here: http://s3.amazonaws.com/"
            + publicBucket.getName() + "/" + publicObject.getKey());

        // The ALL_USERS Group is particularly useful, but there are also other grantee types
        // that can be used with AccessControlList. Please see Amazon's S3 technical documentation
        // for a fuller discussion of these settings.
       
        AccessControlList acl = new AccessControlList();
       
        // Grant access by email address. Note that this only works email address of AWS S3 members.
        acl.grantPermission(new EmailAddressGrantee("someone@somewhere.com"),
            Permission.PERMISSION_FULL_CONTROL);
       
        // Grant control of ACL settings to a known AWS S3 member.
        acl.grantPermission(new CanonicalGrantee("AWS member's ID"),
            Permission.PERMISSION_READ_ACP);
        acl.grantPermission(new CanonicalGrantee("AWS member's ID"),
            Permission.PERMISSION_WRITE_ACP);
       
    
        /*
         * Temporarily make an Object available to anyone
View Full Code Here

          }
            boolean isSetLoggingGroupWrite = false;
            boolean isSetLoggingGroupReadACP = false;
            String groupIdentifier = GroupGrantee.LOG_DELIVERY.getIdentifier();
           
            AccessControlList logBucketACL = getBucketAcl(status.getTargetBucketName());
           
            Iterator grantIter = logBucketACL.getGrants().iterator();
            while (grantIter.hasNext()) {
                GrantAndPermission gap = (GrantAndPermission) grantIter.next();
               
                if (groupIdentifier.equals(gap.getGrantee().getIdentifier())) {
                    // Found a Group Grantee.                   
                    if (gap.getPermission().equals(Permission.PERMISSION_WRITE)) {
                        isSetLoggingGroupWrite = true;
                        if (log.isDebugEnabled()) {
                          log.debug("Target bucket '" + status.getTargetBucketName() + "' has ACL "
                              + "permission " + Permission.PERMISSION_WRITE + " for group " +
                              groupIdentifier);
                        }
                    } else if (gap.getPermission().equals(Permission.PERMISSION_READ_ACP)) {
                        isSetLoggingGroupReadACP = true;
                        if (log.isDebugEnabled()) {
                          log.debug("Target bucket '" + status.getTargetBucketName() + "' has ACL "
                              + "permission " + Permission.PERMISSION_READ_ACP + " for group " +
                              groupIdentifier);
                        }
                    }
                }
            }
           
            // Update target bucket's ACL if necessary.
            if (!isSetLoggingGroupWrite || !isSetLoggingGroupReadACP) {
              if (log.isWarnEnabled()) {
                  log.warn("Target logging bucket '" + status.getTargetBucketName()
                      + "' does not have the necessary ACL settings, updating ACL now");
              }
             
                logBucketACL.grantPermission(GroupGrantee.LOG_DELIVERY, Permission.PERMISSION_WRITE);
                logBucketACL.grantPermission(GroupGrantee.LOG_DELIVERY, Permission.PERMISSION_READ_ACP);
                putBucketAcl(status.getTargetBucketName(), logBucketACL);
            } else {
              if (log.isDebugEnabled()) {
                  log.debug("Target logging bucket '" + status.getTargetBucketName()
                      + "' has the necessary ACL settings");
View Full Code Here

                    dialog.setVisible(true);
                   
                    // Update ACL setting.
                    S3Object minimalObject = new S3Object(object.getKey());
   
                    AccessControlList newAcl = (dialog.isPublicAclSet()
                        ? AccessControlList.REST_CANNED_PUBLIC_READ
                        : AccessControlList.REST_CANNED_PRIVATE);
                   
                    if (newAcl != null) {
                        if (AccessControlList.REST_CANNED_PRIVATE.equals(newAcl)) {                                   
View Full Code Here

     * @throws S3ServiceException
     */
    private AccessControlList convertAccessControlTypes(AccessControlPolicy policy)
        throws S3ServiceException
    {
        AccessControlList acl = new AccessControlList();
        acl.setOwner(convertOwner(policy.getOwner()));
       
        Grant[] grants = policy.getAccessControlList();
        for (int i = 0; i < grants.length; i++) {
            Grant grant = (Grant) grants[i];
            org.jets3t.service.acl.Permission permission =
                org.jets3t.service.acl.Permission.parsePermission(grant.getPermission().toString());           
           
            Grantee grantee = grant.getGrantee();
            if (grantee instanceof Group) {
                GroupGrantee jets3tGrantee = new GroupGrantee();
                jets3tGrantee.setIdentifier(((Group)grantee).getURI());               
                acl.grantPermission(jets3tGrantee, permission);               
            } else if (grantee instanceof CanonicalUser) {
                CanonicalUser canonicalUser = (CanonicalUser) grantee;
                CanonicalGrantee jets3tGrantee = new CanonicalGrantee();
                jets3tGrantee.setIdentifier(canonicalUser.getID());
                jets3tGrantee.setDisplayName(canonicalUser.getDisplayName());
                acl.grantPermission(jets3tGrantee, permission);               
            } else if (grantee instanceof AmazonCustomerByEmail) {
                AmazonCustomerByEmail customerByEmail = (AmazonCustomerByEmail) grantee;
                EmailAddressGrantee jets3tGrantee = new EmailAddressGrantee();
                jets3tGrantee.setIdentifier(customerByEmail.getEmailAddress());
                acl.grantPermission(jets3tGrantee, permission);               
            } else {
                throw new S3ServiceException("Unrecognised grantee type: " + grantee.getClass());
            }
        }
        return acl;
View Full Code Here

TOP

Related Classes of org.jets3t.service.acl.AccessControlList

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.