Ejemplo n.º 1
0
        /**
         * Returns new bucket statements for given policy type.
         */
        private List <Statement> newBucketStatement(PolicyType policy, String prefix)
        {
            List <Statement> statements = new List <Statement>();

            if (policy.Equals(PolicyType.NONE) || bucketName == null || bucketName.Length == 0)
            {
                return(statements);
            }

            Resources resources = new Resources(PolicyConstants.AWS_RESOURCE_PREFIX + bucketName);

            Statement statement = new Statement();

            statement.actions   = PolicyConstants.COMMON_BUCKET_ACTIONS;
            statement.effect    = "Allow";
            statement.principal = new Principal("*");
            statement.resources = resources;
            statement.sid       = "";

            statements.Add(statement);

            if (policy.Equals(PolicyType.READ_ONLY) || policy.Equals(PolicyType.READ_WRITE))
            {
                statement           = new Statement();
                statement.actions   = PolicyConstants.READ_ONLY_BUCKET_ACTIONS;
                statement.effect    = "Allow";
                statement.principal = new Principal("*");
                statement.resources = resources;
                statement.sid       = "";

                if (prefix != null && prefix.Length != 0)
                {
                    ConditionKeyMap map = new ConditionKeyMap();
                    map.Put("s3:prefix", prefix);
                    statement.conditions = new ConditionMap("StringEquals", map);
                }

                statements.Add(statement);
            }

            if (policy.Equals(PolicyType.WRITE_ONLY) || policy.Equals(PolicyType.READ_WRITE))
            {
                statement           = new Statement();
                statement.actions   = PolicyConstants.WRITE_ONLY_BUCKET_ACTIONS;
                statement.effect    = "Allow";
                statement.principal = new Principal("*");
                statement.resources = resources;
                statement.sid       = "";

                statements.Add(statement);
            }

            return(statements);
        }
Ejemplo n.º 2
0
 public ConditionKeyMap(ConditionKeyMap map = null) : base(map)
 {
 }