Package org.jets3t.service.acl

Examples of org.jets3t.service.acl.AccessControlList


            AWSCredentials credentials = new AWSCredentials(s3AccessKey, s3SecretKey);
            S3Service s3 = new RestS3Service(credentials);
            S3Bucket bucket = s3.getBucket("xubu");
            File file = flv.getFile();
            S3Object object = new S3Object(bucket, file);
            AccessControlList acl = s3.getBucketAcl(bucket);
            object.setAcl(acl);
            object.setKey("streams/" + stream_id + ".flv");
            object = s3.putObject(bucket, object);
            log.info("http://s3.amazonaws.com/" + bucket.getName() + "/" + object.getKey());
            file.delete();
View Full Code Here


    /**
     * Populates the local {@link #updatedAccessControlList} variable with ACL
     * details set by the user in the GUI elements.
     */
  private void updateAccessControlList() {
    updatedAccessControlList = new AccessControlList();
    updatedAccessControlList.setOwner(originalAccessControlList.getOwner());
   
    for (int i = 0; i < canonicalGranteeTable.getRowCount(); i++) {
      GranteeInterface grantee = canonicalGranteeTableModel.getGrantee(i);
      Permission permission = canonicalGranteeTableModel.getPermission(i);
View Full Code Here

     * @param args
     * @throws Exception
   */
  public static void main(String args[]) throws Exception {
    // TEST DATA
    AccessControlList acl = new AccessControlList();
    S3Owner owner = new S3Owner("1234567890", "Some Name");
    acl.setOwner(owner);
   
    GranteeInterface grantee = new CanonicalGrantee();
    grantee.setIdentifier("zzz");
    acl.grantPermission(grantee, Permission.PERMISSION_WRITE);

    grantee = new CanonicalGrantee();
    grantee.setIdentifier("abc");
        ((CanonicalGrantee)grantee).setDisplayName("jamesmurty");
    acl.grantPermission(grantee, Permission.PERMISSION_FULL_CONTROL);
    grantee = new CanonicalGrantee();
    grantee.setIdentifier("aaa");
    acl.grantPermission(grantee, Permission.PERMISSION_READ);
    grantee = GroupGrantee.ALL_USERS;
    acl.grantPermission(grantee, Permission.PERMISSION_READ);
    grantee = GroupGrantee.AUTHENTICATED_USERS;
    acl.grantPermission(grantee, Permission.PERMISSION_WRITE);
    grantee = new EmailAddressGrantee();
    grantee.setIdentifier("james@test.com");
    acl.grantPermission(grantee, Permission.PERMISSION_READ);
    grantee = new EmailAddressGrantee();
    grantee.setIdentifier("james@test2.com");
    acl.grantPermission(grantee, Permission.PERMISSION_FULL_CONTROL);

    JFrame f = new JFrame("Cockpit");
    S3Bucket bucket = new S3Bucket();
    bucket.setName("SomeReallyLongAndWackyBucketNamePath.HereItIs");
   
    AccessControlList updatedACL = acl;
    while ((updatedACL = AccessControlDialog.showDialog(f, new S3Bucket[] {bucket}, updatedACL, null)) != null) {
      System.out.println(updatedACL.toXml());
    }   
   
    f.dispose();   
  }
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 HyperlinkActivatedListener hyperlinkListener = this;
           
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    // Build merged ACL containing ALL relevant permissions
                    AccessControlList mergedACL = new AccessControlList();
                    for (int i = 0; i < objectsWithACL.length; i++) {
                        AccessControlList objectACL = objectsWithACL[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.
                    AccessControlList updatedObjectACL = AccessControlDialog.showDialog(
                        ownerFrame, objectsWithACL, mergedACL, hyperlinkListener);
                    if (updatedObjectACL != null) {
                        // Update ACLs for each object.
                        for (int i = 0; i < objectsWithACL.length; i++) {
                            objectsWithACL[i].setAcl(updatedObjectACL);
View Full Code Here

            // Display grants table.
            grantsTable.setVisible(true);
            while (grantsTableModel.getRowCount() > 0) {
                grantsTableModel.removeRow(0);
            }
            AccessControlList acl = bucket.getAcl();
            Iterator iter = acl.getGrants().iterator();
            while (iter.hasNext()) {
                GrantAndPermission gap = (GrantAndPermission) iter.next();
                grantsTableModel.addRow(new Object[] {
                    gap.getGrantee().getIdentifier(), gap.getPermission().toString()});
            }
View Full Code Here

                status.getTargetBucketName() + "' has the appropriate ACL settings");
            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;
                        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;
                        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) {
                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 {
                log.debug("Target logging bucket '" + status.getTargetBucketName()
                    + "' has the necessary ACL settings");               
            }
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

        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

     * @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.