Package com.cloud.bridge.service.core.s3

Examples of com.cloud.bridge.service.core.s3.S3AccessControlList


 
  private S3AccessControlList toEngineAccessControlList(AccessControlList acl)
  {
    if (acl == null) return null;
   
    S3AccessControlList engineAcl = new S3AccessControlList();
   
    Grant[] grants = acl.getGrant();
    if (grants != null)
    {
      for (Grant grant: grants)
      {
        S3Grant engineGrant = new S3Grant();

        Grantee grantee = grant.getGrantee();
        if (grantee instanceof CanonicalUser)
        {
          engineGrant.setGrantee(SAcl.GRANTEE_USER);
          engineGrant.setCanonicalUserID(((CanonicalUser)grantee).getID());
        }
        else if (grantee instanceof Group)
        {
           Group temp = (Group)grantee;
           String uri = temp.getURI();
           if ( uri.equalsIgnoreCase( "http://acs.amazonaws.com/groups/global/AllUsers" )) {
              // -> this allows all public unauthenticated access based on permission given
              engineGrant.setGrantee(SAcl.GRANTEE_ALLUSERS);
              engineGrant.setCanonicalUserID( "*" );
           }
           else if (uri.equalsIgnoreCase( "http://acs.amazonaws.com/groups/global/Authenticated" )) {
              // -> this allows any authenticated user access based on permission given
              engineGrant.setGrantee(SAcl.GRANTEE_AUTHENTICATED);
              engineGrant.setCanonicalUserID( "A" );
           }
           else throw new UnsupportedOperationException("Unsupported grantee group URI: " + uri );

        }
        else throw new UnsupportedOperationException("Unsupported grantee type: " + grantee.getClass().getCanonicalName());
       
        Permission permission = grant.getPermission();
        String permissionValue = permission.getValue();
        if(permissionValue.equalsIgnoreCase("READ")) {
          engineGrant.setPermission(SAcl.PERMISSION_READ);
        } else if(permissionValue.equalsIgnoreCase("WRITE")) {
          engineGrant.setPermission(SAcl.PERMISSION_WRITE);
        } else if(permissionValue.equalsIgnoreCase("READ_ACP")) {
          engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
        } else if(permissionValue.equalsIgnoreCase("WRITE_ACP")) {
          engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
        } else if(permissionValue.equalsIgnoreCase("FULL_CONTROL")) {
          engineGrant.setPermission(SAcl.PERMISSION_FULL);
        } else {
          throw new UnsupportedOperationException("Unsupported permission: " + permissionValue);
        }
        engineAcl.addGrant(engineGrant);
      }
    }
    return engineAcl;
  }
View Full Code Here


        // [B] Obtain the grant request which applies to the acl request string.  This latter is supplied as the value of the x-amz-acl header.

        S3SetObjectAccessControlPolicyRequest engineRequest = new S3SetObjectAccessControlPolicyRequest();
        S3Grant grantRequest = new S3Grant();
        S3AccessControlList aclRequest = new S3AccessControlList();

        String aclRequestString = request.getHeader("x-amz-acl");
        OrderedPair <Integer,Integer> accessControlsForObjectOwner = SAclVO.getCannedAccessControls(aclRequestString,"SObject");
        grantRequest.setPermission(accessControlsForObjectOwner.getFirst());
        grantRequest.setGrantee(accessControlsForObjectOwner.getSecond());
        grantRequest.setCanonicalUserID(owner);
        aclRequest.addGrant(grantRequest);
        engineRequest.setAcl(aclRequest);
        engineRequest.setBucketName(bucketName);
        engineRequest.setKey(key);

View Full Code Here

        String signature = (String) request.getAttribute(S3Constants.PLAIN_POST_SIGNATURE);
        S3Grant grant = new S3Grant();
        grant.setCanonicalUserID(accessKey);
        grant.setGrantee(SAcl.GRANTEE_USER);
        grant.setPermission(SAcl.PERMISSION_FULL);
        S3AccessControlList acl = new S3AccessControlList();
        acl.addGrant(grant);
        S3PutObjectInlineRequest engineRequest = new S3PutObjectInlineRequest();
        engineRequest.setBucketName(bucket);
        engineRequest.setKey(key);
        engineRequest.setAcl(acl);
        engineRequest.setContentLength(contentLength);
View Full Code Here

        // [B] Obtain the grant request which applies to the acl request string.
        // This latter is supplied as the value of the x-amz-acl header.

        S3SetBucketAccessControlPolicyRequest engineRequest = new S3SetBucketAccessControlPolicyRequest();
        S3Grant grantRequest = new S3Grant();
        S3AccessControlList aclRequest = new S3AccessControlList();

        String aclRequestString = request.getHeader("x-amz-acl");
        OrderedPair<Integer, Integer> accessControlsForBucketOwner = SAclVO.getCannedAccessControls(aclRequestString, "SBucket");
        grantRequest.setPermission(accessControlsForBucketOwner.getFirst());
        grantRequest.setGrantee(accessControlsForBucketOwner.getSecond());
        grantRequest.setCanonicalUserID(owner);
        aclRequest.addGrant(grantRequest);
        engineRequest.setAcl(aclRequest);
        engineRequest.setBucketName(bucketName);

        // [C] Allow an S3Engine to handle the
        // S3SetBucketAccessControlPolicyRequest
View Full Code Here

        // [C] Get a list of all Grant elements in an AccessControlList
        part = getElement( doc, "http://s3.amazonaws.com/doc/2006-03-01/", "Grant" );
        if (null != part)
        {
            S3AccessControlList engineAcl = new S3AccessControlList();

            count = part.getLength();
            for( int i=0; i < count; i++ )
            {
                parent = part.item(i);
                S3Grant engineGrant = new S3Grant();

                // -> get a list of all the children elements of the 'Grant' parent element
                if (null != (children = parent.getChildNodes()))
                {
                    int numChildren = children.getLength();
                    for( int j=0; j < numChildren; j++ )
                    {
                        contents = children.item( j );
                        element  = contents.getNodeName().trim();
                        if ( element.endsWith( "Grantee" ))
                        {
                            NamedNodeMap attbs = contents.getAttributes();
                            if (null != attbs)
                            {
                                Node type = attbs.getNamedItemNS( "http://www.w3.org/2001/XMLSchema-instance", "type" );
                                if ( null != type )
                                    temp = type.getFirstChild().getNodeValue().trim();
                                else temp = null;

                                if ( null != temp && temp.equalsIgnoreCase( "CanonicalUser" ))
                                {
                                    engineGrant.setGrantee(SAcl.GRANTEE_USER);
                                    engineGrant.setCanonicalUserID( getChildNodeValue( contents, "ID" ));
                                }
                                else throw new UnsupportedOperationException( "Missing http://www.w3.org/2001/XMLSchema-instance:type value" );
                            }
                        }
                        else if (element.endsWith( "Permission" ))
                        {
                            temp = contents.getFirstChild().getNodeValue().trim();
                            if (temp.equalsIgnoreCase("READ"        )) engineGrant.setPermission(SAcl.PERMISSION_READ);
                            else if (temp.equalsIgnoreCase("WRITE"       )) engineGrant.setPermission(SAcl.PERMISSION_WRITE);
                            else if (temp.equalsIgnoreCase("READ_ACP"    )) engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
                            else if (temp.equalsIgnoreCase("WRITE_ACP"   )) engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
                            else if (temp.equalsIgnoreCase("FULL_CONTROL")) engineGrant.setPermission(SAcl.PERMISSION_FULL);
                            else throw new UnsupportedOperationException( "Unsupported permission: " + temp );
                        }
                    }
                    engineAcl.addGrant( engineGrant );
                }
            }
            request.setAcl( engineAcl );
        }
        return request;
View Full Code Here

        // [B] Obtain the grant request which applies to the acl request string.
        // This latter is supplied as the value of the x-amz-acl header.

        S3SetBucketAccessControlPolicyRequest engineRequest = new S3SetBucketAccessControlPolicyRequest();
        S3Grant grantRequest = new S3Grant();
        S3AccessControlList aclRequest = new S3AccessControlList();

        String aclRequestString = request.getHeader("x-amz-acl");
        OrderedPair<Integer, Integer> accessControlsForBucketOwner = SAclVO.getCannedAccessControls(aclRequestString, "SBucket");
        grantRequest.setPermission(accessControlsForBucketOwner.getFirst());
        grantRequest.setGrantee(accessControlsForBucketOwner.getSecond());
        grantRequest.setCanonicalUserID(owner);
        aclRequest.addGrant(grantRequest);
        engineRequest.setAcl(aclRequest);
        engineRequest.setBucketName(bucketName);

        // [C] Allow an S3Engine to handle the
        // S3SetBucketAccessControlPolicyRequest
View Full Code Here

    private S3AccessControlList toEngineAccessControlList(AccessControlList acl) {
        if (acl == null)
            return null;

        S3AccessControlList engineAcl = new S3AccessControlList();

        Grant[] grants = acl.getGrant();
        if (grants != null) {
            for (Grant grant : grants) {
                S3Grant engineGrant = new S3Grant();

                Grantee grantee = grant.getGrantee();
                if (grantee instanceof CanonicalUser) {
                    engineGrant.setGrantee(SAcl.GRANTEE_USER);
                    engineGrant.setCanonicalUserID(((CanonicalUser)grantee).getID());
                } else if (grantee instanceof Group) {
                    Group temp = (Group)grantee;
                    String uri = temp.getURI();
                    if (uri.equalsIgnoreCase("http://acs.amazonaws.com/groups/global/AllUsers")) {
                        // -> this allows all public unauthenticated access based on permission given
                        engineGrant.setGrantee(SAcl.GRANTEE_ALLUSERS);
                        engineGrant.setCanonicalUserID("*");
                    } else if (uri.equalsIgnoreCase("http://acs.amazonaws.com/groups/global/Authenticated")) {
                        // -> this allows any authenticated user access based on permission given
                        engineGrant.setGrantee(SAcl.GRANTEE_AUTHENTICATED);
                        engineGrant.setCanonicalUserID("A");
                    } else
                        throw new UnsupportedOperationException("Unsupported grantee group URI: " + uri);

                } else
                    throw new UnsupportedOperationException("Unsupported grantee type: " + grantee.getClass().getCanonicalName());

                Permission permission = grant.getPermission();
                String permissionValue = permission.getValue();
                if (permissionValue.equalsIgnoreCase("READ")) {
                    engineGrant.setPermission(SAcl.PERMISSION_READ);
                } else if (permissionValue.equalsIgnoreCase("WRITE")) {
                    engineGrant.setPermission(SAcl.PERMISSION_WRITE);
                } else if (permissionValue.equalsIgnoreCase("READ_ACP")) {
                    engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
                } else if (permissionValue.equalsIgnoreCase("WRITE_ACP")) {
                    engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
                } else if (permissionValue.equalsIgnoreCase("FULL_CONTROL")) {
                    engineGrant.setPermission(SAcl.PERMISSION_FULL);
                } else {
                    throw new UnsupportedOperationException("Unsupported permission: " + permissionValue);
                }
                engineAcl.addGrant(engineGrant);
            }
        }
        return engineAcl;
    }
View Full Code Here

        // [B] Obtain the grant request which applies to the acl request string.  This latter is supplied as the value of the x-amz-acl header.

        S3SetObjectAccessControlPolicyRequest engineRequest = new S3SetObjectAccessControlPolicyRequest();
        S3Grant grantRequest = new S3Grant();
        S3AccessControlList aclRequest = new S3AccessControlList();

        String aclRequestString = request.getHeader("x-amz-acl");
        OrderedPair<Integer, Integer> accessControlsForObjectOwner = SAclVO.getCannedAccessControls(aclRequestString, "SObject");
        grantRequest.setPermission(accessControlsForObjectOwner.getFirst());
        grantRequest.setGrantee(accessControlsForObjectOwner.getSecond());
        grantRequest.setCanonicalUserID(owner);
        aclRequest.addGrant(grantRequest);
        engineRequest.setAcl(aclRequest);
        engineRequest.setBucketName(bucketName);
        engineRequest.setKey(key);

        // [C] Allow an S3Engine to handle the S3SetObjectAccessControlPolicyRequest
View Full Code Here

        String signature = (String)request.getAttribute(S3Constants.PLAIN_POST_SIGNATURE);
        S3Grant grant = new S3Grant();
        grant.setCanonicalUserID(accessKey);
        grant.setGrantee(SAcl.GRANTEE_USER);
        grant.setPermission(SAcl.PERMISSION_FULL);
        S3AccessControlList acl = new S3AccessControlList();
        acl.addGrant(grant);
        S3PutObjectInlineRequest engineRequest = new S3PutObjectInlineRequest();
        engineRequest.setBucketName(bucket);
        engineRequest.setKey(key);
        engineRequest.setAcl(acl);
        engineRequest.setContentLength(contentLength);
View Full Code Here

 
  private S3AccessControlList toEngineAccessControlList(AccessControlList acl)
  {
    if (acl == null) return null;
   
    S3AccessControlList engineAcl = new S3AccessControlList();
   
    Grant[] grants = acl.getGrant();
    if (grants != null)
    {
      for (Grant grant: grants)
      {
        S3Grant engineGrant = new S3Grant();

        Grantee grantee = grant.getGrantee();
        if (grantee instanceof CanonicalUser)
        {
          engineGrant.setGrantee(SAcl.GRANTEE_USER);
          engineGrant.setCanonicalUserID(((CanonicalUser)grantee).getID());
        }
        else if (grantee instanceof Group)
        {
           Group temp = (Group)grantee;
           String uri = temp.getURI();
           if ( uri.equalsIgnoreCase( "http://acs.amazonaws.com/groups/global/AllUsers" )) {
              // -> this allows all public unauthenticated access based on permission given
              engineGrant.setGrantee(SAcl.GRANTEE_ALLUSERS);
              engineGrant.setCanonicalUserID( "*" );
           }
           else if (uri.equalsIgnoreCase( "http://acs.amazonaws.com/groups/global/Authenticated" )) {
              // -> this allows any authenticated user access based on permission given
              engineGrant.setGrantee(SAcl.GRANTEE_AUTHENTICATED);
              engineGrant.setCanonicalUserID( "A" );
           }
           else throw new UnsupportedOperationException("Unsupported grantee group URI: " + uri );

        }
        else throw new UnsupportedOperationException("Unsupported grantee type: " + grantee.getClass().getCanonicalName());
       
        Permission permission = grant.getPermission();
        String permissionValue = permission.getValue();
        if(permissionValue.equalsIgnoreCase("READ")) {
          engineGrant.setPermission(SAcl.PERMISSION_READ);
        } else if(permissionValue.equalsIgnoreCase("WRITE")) {
          engineGrant.setPermission(SAcl.PERMISSION_WRITE);
        } else if(permissionValue.equalsIgnoreCase("READ_ACP")) {
          engineGrant.setPermission(SAcl.PERMISSION_READ_ACL);
        } else if(permissionValue.equalsIgnoreCase("WRITE_ACP")) {
          engineGrant.setPermission(SAcl.PERMISSION_WRITE_ACL);
        } else if(permissionValue.equalsIgnoreCase("FULL_CONTROL")) {
          engineGrant.setPermission(SAcl.PERMISSION_FULL);
        } else {
          throw new UnsupportedOperationException("Unsupported permission: " + permissionValue);
        }
        engineAcl.addGrant(engineGrant);
      }
    }
    return engineAcl;
  }
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.core.s3.S3AccessControlList

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.