Examples of BucketPolicyDao


Examples of com.cloud.bridge.persist.dao.BucketPolicyDao

       }
        
       // -> delete all the policy state associated with the bucket
       try {
                ServiceProvider.getInstance().deleteBucketPolicy( bucketName );
             BucketPolicyDao policyDao = new BucketPolicyDao();
             policyDao.deletePolicy( bucketName );
       }
       catch( Exception e ) {
                logger.error("When deleting a bucket we must try to delete its policy: ", e);
       }
      
View Full Code Here

Examples of com.cloud.bridge.persist.dao.BucketPolicyDao

    if ( null == policy )
    {
       // -> do we have to load it from the database (any other value means there is no policy)?
       if (-1 == result.getSecond().intValue())
       {
          BucketPolicyDao policyDao = new BucketPolicyDao();
          String policyInJson = policyDao.getPolicy( context.getBucketName());
          // -> place in cache that no policy exists in the database
          if (null == policyInJson) {
                ServiceProvider.getInstance().setBucketPolicy(context.getBucketName(), null);
            return null;
          }
View Full Code Here

Examples of com.cloud.bridge.persist.dao.BucketPolicyDao

  {
    String bucketName = (String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY);
    String policy = streamToString( request.getInputStream());
           
    // [A] Is there an owner of an existing policy or bucket?
        BucketPolicyDao policyDao = new BucketPolicyDao();
    SBucketDao bucketDao = new SBucketDao();
    SBucket bucket = bucketDao.getByName( bucketName );
        String owner = null;
       
        if ( null != bucket )
        {
           owner = bucket.getOwnerCanonicalId();
        }
        else
        {    try {
               owner = policyDao.getPolicyOwner( bucketName );
             }
             catch( Exception e ) {}
        }

       
    // [B] "The bucket owner by default has permissions to attach bucket policies to their buckets using PUT Bucket policy."
    //  -> the bucket owner may want to restrict the IP address from where this can be executed
      String client = UserContext.current().getCanonicalUserId();
    S3PolicyContext context = new S3PolicyContext( PolicyActions.PutBucketPolicy, bucketName );
      switch( S3Engine.verifyPolicy( context )) {
      case ALLOW:
             break;
            
    case DEFAULT_DENY:
         if (null != owner && !client.equals( owner )) {
           response.setStatus(405);
           return;
         }
         break;
          
    case DENY:
             response.setStatus(403);
             return;
    }
     
     
      // [B] Place the policy into the database over writting an existing policy
      try {
        // -> first make sure that the policy is valid by parsing it
           PolicyParser parser = new PolicyParser();
        S3BucketPolicy sbp = parser.parse( policy, bucketName );

          policyDao.deletePolicy( bucketName );
          if (null != policy && !policy.isEmpty()) policyDao.addPolicy( bucketName, client, policy );
                 
        if (null != sbp) ServiceProvider.getInstance().setBucketPolicy( bucketName, sbp );
        response.setStatus(200);     
      }
      catch( PermissionDeniedException e ) {
View Full Code Here

Examples of com.cloud.bridge.persist.dao.BucketPolicyDao

  private void executeGetBucketPolicy(HttpServletRequest request, HttpServletResponse response)
  {
    String bucketName = (String)request.getAttribute(S3Constants.BUCKET_ATTR_KEY);

    // [A] Is there an owner of an existing policy or bucket?
        BucketPolicyDao policyDao = new BucketPolicyDao();
    SBucketDao bucketDao = new SBucketDao();
    SBucket bucket = bucketDao.getByName( bucketName );
        String owner = null;
       
        if ( null != bucket )
        {
           owner = bucket.getOwnerCanonicalId();
        }
        else
        {    try {
               owner = policyDao.getPolicyOwner( bucketName );
             }
             catch( Exception e ) {}
        }

       
    // [B] "The bucket owner by default has permissions to retrieve bucket policies using GET Bucket policy."
    //  -> the bucket owner may want to restrict the IP address from where this can be executed
    String client = UserContext.current().getCanonicalUserId();
    S3PolicyContext context = new S3PolicyContext( PolicyActions.GetBucketPolicy, bucketName );
    switch( S3Engine.verifyPolicy( context )) {
    case ALLOW:
             break;
            
    case DEFAULT_DENY:
         if (null != owner && !client.equals( owner )) {
            response.setStatus(405);
            return;
          }
          break;
          
    case DENY:
             response.setStatus(403);
             return;
    }

     
      // [B] Pull the policy from the database if one exists
      try {
          String policy = policyDao.getPolicy( bucketName );
          if ( null == policy ) {
           response.setStatus(404);
          }
          else {
             response.setStatus(200);
View Full Code Here

Examples of com.cloud.bridge.persist.dao.BucketPolicyDao

            return;
        }
    }

      try {
          BucketPolicyDao policyDao = new BucketPolicyDao();
          String policy = policyDao.getPolicy( bucketName );
          if ( null == policy ) {
           response.setStatus(204);
          }
          else {
                ServiceProvider.getInstance().deleteBucketPolicy( bucketName );
               policyDao.deletePolicy( bucketName );
             response.setStatus(200);
          }
      }
    catch( Exception e ) {
      logger.error("Delete Bucket Policy failed due to " + e.getMessage(), e)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.