Unsolved
This post is more than 5 years old
8 Posts
0
1048
June 6th, 2020 02:00
How to delete bucket policy using Java SDK ecs-object-client-java
Hello,
I am creating Bucket policies in my application using following java code snippet:
(I am using EMC Java SDK ecs-object-client-java)
>>>
List < BucketPolicyStatement > stmts = new ArrayList <>();
stmts . add ( new BucketPolicyStatement ()
. withSid ( "Grant permission to " + userId + " for objects" )
. withEffect ( Effect . Allow )
. withPrincipal ( userId )
. withResource ( bucketName + "/*" )
. withActions ( BucketPolicyAction . GetObject ,
BucketPolicyAction . GetObjectVersion ,
BucketPolicyAction . GetObjectAcl ,
BucketPolicyAction . GetObjectVersionAcl
)
);
stmts . add ( new BucketPolicyStatement ()
. withSid ( "Grant permission to " + userId + " for bucket" )
. withEffect ( Effect . Allow )
. withPrincipal ( userId )
. withResource ( bucketName )
. withActions ( BucketPolicyAction . ListBucket ,
BucketPolicyAction . ListBucketVersions ,
BucketPolicyAction . GetLifecycleConfiguration ,
BucketPolicyAction . GetBucketAcl ,
BucketPolicyAction . GetBucketVersioning ,
BucketPolicyAction . GetBucketPolicy
)
);
BucketPolicy bucketPolicy = new BucketPolicy ()
. withVersion ( "2012-10-17" )
. withId ( "new-policy-1" )
. withStatements ( stmts );
s3Client . setBucketPolicy ( bucketName , bucketPolicy );
<<<
Everything is working fine. But my question is how do I DELETE (remove) the Bucket policy programatically once it is set as above.
Any help / pointer would be highly appreciated.
Thanks
No Events found!


DELL-Sam L
Moderator
•
7.9K Posts
•
135 Points
0
June 8th, 2020 11:00
Hello UdayBidikar,
Here is a link to a KB that maybe of assistance. You will need to login with your EMC account. https://dell.to/3f0I57h
Please let us know if you have any other questions.
UdayBidikar
8 Posts
0
June 12th, 2020 01:00
Hello Dell-Sam L,
Thank you for the quick response, but my question was about deleting the Bucket policy using S3 object client interface. Anyway mean while I figured out how to do it. I extended the ""S3JerseyClient" object in ecs-object-client-java SDK as follows. It works just fine now: