UPDATE!
After trying to run the code based on this blog, it suddenly just doesn’t work!
Recommend you look at JetS3t which provides a nice wrapper around the S3 SOAP stuff.
The main reason not to the S3 SOAP directly is because signing requests is a complete pain in the ass.
Woe is me!
After looking a lot of tools, I decided I need to write a one-off for my application to update ACL’s. All the tools I found wanted to pull back every ACL and update it! I want all my keys in this part of my bucket to have the same ACL.
I tried to use the wsimport’d library, but….
javax.xml.ws.soap.SOAPFaultException: The SOAP 1.1 request is missing a security element at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:171) at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:102) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:240) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:210) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:103) at $Proxy33.getObjectAccessControlPolicy(Unknown Source) at us.versus.them.jarczar.publisher.AppTest.testApp(AppTest.java:44)
OSS to the Rescue
I cursed and cried and then found the Amazon S3 Library for SOAP in Java. The only bit I really wanted was com.amazon.s3.AWSAuthConnection which takes care of the blasted authentication nonsense.
Compiling s3-example-libraries
Compiling it was fun:
% javac -d out $( find com -name "*.java" ) -classpath ${HOME}/.m2/repository/org/codehaus/castor/castor/1.2/castor-1.2.jar:${HOME}/.m2/repository/org/apache/axis/axis/1.4/axis-1.4.jar:${HOME}/.m2/repository/com/sun/javaee/javaee/5.0/javaee-5.0.jar % jar cf s3-example-libraries.jar -C out . % addToRepo.sh com.amazon.s3 1.0.0 s3-example-libraries.jar ${HOME}/.m2/repository/com/amazon/s3/s3-example-libraries/1.0.0
Using it
Using it was trivial:
import com.amazon.s3.AWSAuthConnection; import com.amazonaws.s3.doc._2006_03_01.*; //.... AWSAuthConnection aws = new AWSAuthConnection( awsAccessKeyId, awsSecretAccessKey ); AccessControlPolicy acl = aws.getACL( bucket, key );Maven Dependencies
It did pull in a few deps....<dependency> <groupId>org.codehaus.castor</groupId> <artifactId>castor</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.apache.axis</groupId> <artifactId>axis</artifactId> <version>1.4</version> </dependency> <dependency> <groupId>com.amazon.s3</groupId> <artifactId>s3-example-libraries</artifactId> <version>1.0.0</version> </dependency> <dependency> <groupId>com.sun.javaee</groupId> <artifactId>javaee</artifactId> <version>5.0</version> </dependency> <dependency> <groupId>commons-discovery</groupId> <artifactId>commons-discovery</artifactId> <version>0.4</version> </dependency> <dependency> <groupId>axis</groupId> <artifactId>axis-wsdl4j</artifactId> <version>1.5.1</version> </dependency>bloc
Advertisements