summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2009-10-03 15:43:34 -0700
committerShawn O. Pearce <spearce@spearce.org>2009-10-05 12:17:11 -0700
commit8d5510d51c27d9fccbeb9cfd82f218a5c3ebf530 (patch)
treea5e21c712b8014e72eb2a0b4b857e613ac690b34 /org.eclipse.jgit
parent3ce8c91e759ee1a9fca1d7b3cb2646b76388de6c (diff)
downloadjgit-8d5510d51c27d9fccbeb9cfd82f218a5c3ebf530.tar.gz
jgit-8d5510d51c27d9fccbeb9cfd82f218a5c3ebf530.zip
Move AmazonS3 command line utility to jgit-pgm
This removes one of the few remaining dependencies on AWTAuthenticator from the core library. For the most part the interface is identical to the prior main method. The jgit-pgm Main class already sets up the HTTP proxy and authenticator for us, so we don't need to do that in our new run method. Change-Id: Ia2cce34d34c97b88214a8bd8f2cc542845e19032 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java66
1 files changed, 0 insertions, 66 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
index 9343f4aba4..46ebf82552 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
@@ -44,7 +44,6 @@
package org.eclipse.jgit.transport;
import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -79,7 +78,6 @@ import java.util.TreeMap;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-import org.eclipse.jgit.awtui.AwtAuthenticator;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ProgressMonitor;
@@ -623,70 +621,6 @@ public class AmazonS3 {
c.setRequestProperty("Authorization", "AWS " + publicKey + ":" + sec);
}
- /**
- * Simple command line interface to {@link AmazonS3}.
- *
- * @param argv
- * command line arguments. See usage for details.
- * @throws IOException
- * an error occurred.
- */
- public static void main(final String[] argv) throws IOException {
- if (argv.length != 4) {
- commandLineUsage();
- return;
- }
-
- AwtAuthenticator.install();
- HttpSupport.configureHttpProxy();
-
- final AmazonS3 s3 = new AmazonS3(properties(new File(argv[0])));
- final String op = argv[1];
- final String bucket = argv[2];
- final String key = argv[3];
- if ("get".equals(op)) {
- final URLConnection c = s3.get(bucket, key);
- int len = c.getContentLength();
- final InputStream in = c.getInputStream();
- try {
- final byte[] tmp = new byte[2048];
- while (len > 0) {
- final int n = in.read(tmp);
- if (n < 0)
- throw new EOFException("Expected " + len + " bytes.");
- System.out.write(tmp, 0, n);
- len -= n;
- }
- } finally {
- in.close();
- }
- } else if ("ls".equals(op) || "list".equals(op)) {
- for (final String k : s3.list(bucket, key))
- System.out.println(k);
- } else if ("rm".equals(op) || "delete".equals(op)) {
- s3.delete(bucket, key);
- } else if ("put".equals(op)) {
- final OutputStream os = s3.beginPut(bucket, key, null, null);
- final byte[] tmp = new byte[2048];
- int n;
- while ((n = System.in.read(tmp)) > 0)
- os.write(tmp, 0, n);
- os.close();
- } else {
- commandLineUsage();
- }
- }
-
- private static void commandLineUsage() {
- System.err.println("usage: conn.prop op bucket key");
- System.err.println();
- System.err.println(" where conn.prop is a jets3t properties file.");
- System.err.println(" op is one of: get ls rm put");
- System.err.println(" bucket is the name of the S3 bucket");
- System.err.println(" key is the name of the object.");
- System.exit(1);
- }
-
static Properties properties(final File authFile)
throws FileNotFoundException, IOException {
final Properties p = new Properties();