wms-amazonutil

16:53:58.421 INFO  jd.cli.Main - Decompiling wms-amazonutil.jar
package com.amazon.s3;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;

public class AWSAuthConnection
{
  public static final String LOCATION_DEFAULT = null;
  public static final String LOCATION_EU = "EU";
  private String awsAccessKeyId;
  private String awsSecretAccessKey;
  private boolean isSecure;
  private String server;
  private int port;
  private CallingFormat callingFormat;
  
  public AWSAuthConnection(String paramString1, String paramString2)
  {
    this(paramString1, paramString2, true);
  }
  
  public AWSAuthConnection(String paramString1, String paramString2, boolean paramBoolean)
  {
    this(paramString1, paramString2, paramBoolean, "s3.amazonaws.com");
  }
  
  public AWSAuthConnection(String paramString1, String paramString2, boolean paramBoolean, String paramString3)
  {
    this(paramString1, paramString2, paramBoolean, paramString3, paramBoolean ? 443 : 80);
  }
  
  public AWSAuthConnection(String paramString1, String paramString2, boolean paramBoolean, String paramString3, int paramInt)
  {
    this(paramString1, paramString2, paramBoolean, paramString3, paramInt, CallingFormat.getSubdomainCallingFormat());
  }
  
  public AWSAuthConnection(String paramString1, String paramString2, boolean paramBoolean, String paramString3, CallingFormat paramCallingFormat)
  {
    this(paramString1, paramString2, paramBoolean, paramString3, paramBoolean ? 443 : 80, paramCallingFormat);
  }
  
  public AWSAuthConnection(String paramString1, String paramString2, boolean paramBoolean, String paramString3, int paramInt, CallingFormat paramCallingFormat)
  {
    awsAccessKeyId = paramString1;
    awsSecretAccessKey = paramString2;
    isSecure = paramBoolean;
    server = paramString3;
    port = paramInt;
    callingFormat = paramCallingFormat;
  }
  
  /**
   * @deprecated
   */
  public Response createBucket(String paramString, Map paramMap)
    throws MalformedURLException, IOException
  {
    return createBucket(paramString, null, paramMap);
  }
  
  public Response createBucket(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    String str;
    if (paramString2 == null)
    {
      str = null;
    }
    else if ("EU".equals(paramString2))
    {
      if (!callingFormat.supportsLocatedBuckets()) {
        throw new IllegalArgumentException("Creating location-constrained bucket with unsupported calling-format");
      }
      str = "<CreateBucketConstraint><LocationConstraint>" + paramString2 + "</LocationConstraint></CreateBucketConstraint>";
    }
    else
    {
      throw new IllegalArgumentException("Invalid Location: " + paramString2);
    }
    if (!Utils.validateBucketName(paramString1, callingFormat, paramString2 != null)) {
      throw new IllegalArgumentException("Invalid Bucket Name: " + paramString1);
    }
    HttpURLConnection localHttpURLConnection = makeRequest("PUT", paramString1, "", null, paramMap);
    if (str != null)
    {
      localHttpURLConnection.setDoOutput(true);
      localHttpURLConnection.getOutputStream().write(str.getBytes("UTF-8"));
    }
    return new Response(localHttpURLConnection);
  }
  
  public boolean checkBucketExists(String paramString)
    throws MalformedURLException, IOException
  {
    HttpURLConnection localHttpURLConnection = makeRequest("HEAD", paramString, "", null, null);
    int i = localHttpURLConnection.getResponseCode();
    return (i >= 200) && (i < 300);
  }
  
  public ListBucketResponse listBucket(String paramString1, String paramString2, String paramString3, Integer paramInteger, Map paramMap)
    throws MalformedURLException, IOException
  {
    return listBucket(paramString1, paramString2, paramString3, paramInteger, null, paramMap);
  }
  
  public ListBucketResponse listBucket(String paramString1, String paramString2, String paramString3, Integer paramInteger, String paramString4, Map paramMap)
    throws MalformedURLException, IOException
  {
    Map localMap = Utils.paramsForListOptions(paramString2, paramString3, paramInteger, paramString4);
    return new ListBucketResponse(makeRequest("GET", paramString1, "", localMap, paramMap));
  }
  
  public Response deleteBucket(String paramString, Map paramMap)
    throws MalformedURLException, IOException
  {
    return new Response(makeRequest("DELETE", paramString, "", null, paramMap));
  }
  
  public Response put(String paramString1, String paramString2, S3Object paramS3Object, Map paramMap)
    throws MalformedURLException, IOException
  {
    HttpURLConnection localHttpURLConnection = makeRequest("PUT", paramString1, Utils.urlencode(paramString2), null, paramMap, paramS3Object);
    
    localHttpURLConnection.setDoOutput(true);
    localHttpURLConnection.getOutputStream().write(data == null ? new byte[0] : data);
    
    return new Response(localHttpURLConnection);
  }
  
  public Response copy(String paramString1, String paramString2, String paramString3, String paramString4, Map paramMap)
    throws MalformedURLException, IOException
  {
    S3Object localS3Object = new S3Object(new byte[0], new HashMap());
    paramMap = paramMap == null ? new HashMap() : new HashMap(paramMap);
    paramMap.put("x-amz-copy-source", Arrays.asList(new String[] { paramString1 + "/" + paramString2 }));
    paramMap.put("x-amz-metadata-directive", Arrays.asList(new String[] { "COPY" }));
    return verifyCopy(put(paramString3, paramString4, localS3Object, paramMap));
  }
  
  public Response copy(String paramString1, String paramString2, String paramString3, String paramString4, Map paramMap1, Map paramMap2)
    throws MalformedURLException, IOException
  {
    S3Object localS3Object = new S3Object(new byte[0], paramMap1);
    paramMap2 = paramMap2 == null ? new HashMap() : new HashMap(paramMap2);
    paramMap2.put("x-amz-copy-source", Arrays.asList(new String[] { paramString1 + "/" + paramString2 }));
    paramMap2.put("x-amz-metadata-directive", Arrays.asList(new String[] { "REPLACE" }));
    return verifyCopy(put(paramString3, paramString4, localS3Object, paramMap2));
  }
  
  private Response verifyCopy(Response paramResponse)
    throws IOException
  {
    if (connection.getResponseCode() < 400)
    {
      byte[] arrayOfByte = GetResponse.slurpInputStream(connection.getInputStream());
      String str = new String(arrayOfByte);
      if (str.indexOf("<Error") != -1) {
        throw new IOException(str.substring(str.indexOf("<Error")));
      }
      if (str.indexOf("</CopyObjectResult>") == -1) {
        throw new IOException("Unexpected response: " + str);
      }
    }
    return paramResponse;
  }
  
  public GetResponse get(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    return new GetResponse(makeRequest("GET", paramString1, Utils.urlencode(paramString2), null, paramMap));
  }
  
  public Response delete(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    return new Response(makeRequest("DELETE", paramString1, Utils.urlencode(paramString2), null, paramMap));
  }
  
  public GetResponse getBucketRequestPayment(String paramString, Map paramMap)
    throws MalformedURLException, IOException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("requestPayment", null);
    return new GetResponse(makeRequest("GET", paramString, "", localHashMap, paramMap));
  }
  
  public Response putBucketRequestPayment(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("requestPayment", null);
    S3Object localS3Object = new S3Object(paramString2.getBytes(), null);
    HttpURLConnection localHttpURLConnection = makeRequest("PUT", paramString1, "", localHashMap, paramMap, localS3Object);
    
    localHttpURLConnection.setDoOutput(true);
    localHttpURLConnection.getOutputStream().write(data == null ? new byte[0] : data);
    
    return new Response(localHttpURLConnection);
  }
  
  public GetResponse getBucketLogging(String paramString, Map paramMap)
    throws MalformedURLException, IOException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("logging", null);
    return new GetResponse(makeRequest("GET", paramString, "", localHashMap, paramMap));
  }
  
  public Response putBucketLogging(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("logging", null);
    S3Object localS3Object = new S3Object(paramString2.getBytes(), null);
    HttpURLConnection localHttpURLConnection = makeRequest("PUT", paramString1, "", localHashMap, paramMap, localS3Object);
    
    localHttpURLConnection.setDoOutput(true);
    localHttpURLConnection.getOutputStream().write(data == null ? new byte[0] : data);
    
    return new Response(localHttpURLConnection);
  }
  
  public GetResponse getBucketACL(String paramString, Map paramMap)
    throws MalformedURLException, IOException
  {
    return getACL(paramString, "", paramMap);
  }
  
  public GetResponse getACL(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    if (paramString2 == null) {
      paramString2 = "";
    }
    HashMap localHashMap = new HashMap();
    localHashMap.put("acl", null);
    
    return new GetResponse(makeRequest("GET", paramString1, Utils.urlencode(paramString2), localHashMap, paramMap));
  }
  
  public Response putBucketACL(String paramString1, String paramString2, Map paramMap)
    throws MalformedURLException, IOException
  {
    return putACL(paramString1, "", paramString2, paramMap);
  }
  
  public Response putACL(String paramString1, String paramString2, String paramString3, Map paramMap)
    throws MalformedURLException, IOException
  {
    S3Object localS3Object = new S3Object(paramString3.getBytes(), null);
    
    HashMap localHashMap = new HashMap();
    localHashMap.put("acl", null);
    
    HttpURLConnection localHttpURLConnection = makeRequest("PUT", paramString1, Utils.urlencode(paramString2), localHashMap, paramMap, localS3Object);
    
    localHttpURLConnection.setDoOutput(true);
    localHttpURLConnection.getOutputStream().write(data == null ? new byte[0] : data);
    
    return new Response(localHttpURLConnection);
  }
  
  public LocationResponse getBucketLocation(String paramString)
    throws MalformedURLException, IOException
  {
    HashMap localHashMap = new HashMap();
    localHashMap.put("location", null);
    return new LocationResponse(makeRequest("GET", paramString, "", localHashMap, null));
  }
  
  public ListAllMyBucketsResponse listAllMyBuckets(Map paramMap)
    throws MalformedURLException, IOException
  {
    return new ListAllMyBucketsResponse(makeRequest("GET", "", "", null, paramMap));
  }
  
  private HttpURLConnection makeRequest(String paramString1, String paramString2, String paramString3, Map paramMap1, Map paramMap2)
    throws MalformedURLException, IOException
  {
    return makeRequest(paramString1, paramString2, paramString3, paramMap1, paramMap2, null);
  }
  
  private HttpURLConnection makeRequest(String paramString1, String paramString2, String paramString3, Map paramMap1, Map paramMap2, S3Object paramS3Object)
    throws MalformedURLException, IOException
  {
    CallingFormat localCallingFormat = Utils.getCallingFormatForBucket(callingFormat, paramString2);
    if ((isSecure) && (localCallingFormat != CallingFormat.getPathCallingFormat()) && (paramString2.indexOf(".") != -1)) {
      System.err.println("You are making an SSL connection, however, the bucket contains periods and the wildcard certificate will not match by default.  Please consider using HTTP.");
    }
    URL localURL = localCallingFormat.getURL(isSecure, server, port, paramString2, paramString3, paramMap1);
    
    HttpURLConnection localHttpURLConnection = (HttpURLConnection)localURL.openConnection();
    localHttpURLConnection.setRequestMethod(paramString1);
    if ((!localHttpURLConnection.getInstanceFollowRedirects()) && (localCallingFormat.supportsLocatedBuckets())) {
      throw new RuntimeException("HTTP redirect support required.");
    }
    addHeaders(localHttpURLConnection, paramMap2);
    if (paramS3Object != null) {
      addMetadataHeaders(localHttpURLConnection, metadata);
    }
    addAuthHeader(localHttpURLConnection, paramString1, paramString2, paramString3, paramMap1);
    
    return localHttpURLConnection;
  }
  
  private void addHeaders(HttpURLConnection paramHttpURLConnection, Map paramMap)
  {
    addHeaders(paramHttpURLConnection, paramMap, "");
  }
  
  private void addMetadataHeaders(HttpURLConnection paramHttpURLConnection, Map paramMap)
  {
    addHeaders(paramHttpURLConnection, paramMap, "x-amz-meta-");
  }
  
  private void addHeaders(HttpURLConnection paramHttpURLConnection, Map paramMap, String paramString)
  {
    Iterator localIterator1;
    if (paramMap != null) {
      for (localIterator1 = paramMap.keySet().iterator(); localIterator1.hasNext();)
      {
        str1 = (String)localIterator1.next();
        for (localIterator2 = ((List)paramMap.get(str1)).iterator(); localIterator2.hasNext();)
        {
          String str2 = (String)localIterator2.next();
          paramHttpURLConnection.addRequestProperty(paramString + str1, str2);
        }
      }
    }
    String str1;
    Iterator localIterator2;
  }
  
  private void addAuthHeader(HttpURLConnection paramHttpURLConnection, String paramString1, String paramString2, String paramString3, Map paramMap)
  {
    if (paramHttpURLConnection.getRequestProperty("Date") == null) {
      paramHttpURLConnection.setRequestProperty("Date", httpDate());
    }
    if (paramHttpURLConnection.getRequestProperty("Content-Type") == null) {
      paramHttpURLConnection.setRequestProperty("Content-Type", "");
    }
    String str1 = Utils.makeCanonicalString(paramString1, paramString2, paramString3, paramMap, paramHttpURLConnection.getRequestProperties());
    
    String str2 = Utils.encode(awsSecretAccessKey, str1, false);
    paramHttpURLConnection.setRequestProperty("Authorization", "AWS " + awsAccessKeyId + ":" + str2);
  }
  
  public static String httpDate()
  {
    SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss ", Locale.US);
    localSimpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    return localSimpleDateFormat.format(new Date()) + "GMT";
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.AWSAuthConnection
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.util.Date;

public class Bucket
{
  public String name;
  public Date creationDate;
  
  public Bucket()
  {
    name = null;
    creationDate = null;
  }
  
  public Bucket(String paramString, Date paramDate)
  {
    name = paramString;
    creationDate = paramDate;
  }
  
  public String toString()
  {
    return name;
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.Bucket
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

class CallingFormat$1 {}

/* Location:
 * Qualified Name:     com.amazon.s3.CallingFormat.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

class CallingFormat$PathCallingFormat
  extends CallingFormat
{
  public boolean supportsLocatedBuckets()
  {
    return false;
  }
  
  public String getPathBase(String paramString1, String paramString2)
  {
    return isBucketSpecified(paramString1) ? "/" + paramString1 + "/" + paramString2 : "/";
  }
  
  public String getEndpoint(String paramString1, int paramInt, String paramString2)
  {
    return paramString1 + ":" + paramInt;
  }
  
  public URL getURL(boolean paramBoolean, String paramString1, int paramInt, String paramString2, String paramString3, Map paramMap)
    throws MalformedURLException
  {
    String str1 = isBucketSpecified(paramString2) ? "/" + paramString2 + "/" + paramString3 : "/";
    String str2 = Utils.convertPathArgsHashToString(paramMap);
    return new URL(paramBoolean ? "https" : "http", paramString1, paramInt, str1 + str2);
  }
  
  private boolean isBucketSpecified(String paramString)
  {
    if (paramString == null) {
      return false;
    }
    if (paramString.length() == 0) {
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.CallingFormat.PathCallingFormat
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

class CallingFormat$SubdomainCallingFormat
  extends CallingFormat
{
  public boolean supportsLocatedBuckets()
  {
    return true;
  }
  
  public String getServer(String paramString1, String paramString2)
  {
    return paramString2 + "." + paramString1;
  }
  
  public String getEndpoint(String paramString1, int paramInt, String paramString2)
  {
    return getServer(paramString1, paramString2) + ":" + paramInt;
  }
  
  public String getPathBase(String paramString1, String paramString2)
  {
    return "/" + paramString2;
  }
  
  public URL getURL(boolean paramBoolean, String paramString1, int paramInt, String paramString2, String paramString3, Map paramMap)
    throws MalformedURLException
  {
    if ((paramString2 == null) || (paramString2.length() == 0))
    {
      str1 = Utils.convertPathArgsHashToString(paramMap);
      return new URL(paramBoolean ? "https" : "http", paramString1, paramInt, "/" + str1);
    }
    String str1 = getServer(paramString1, paramString2);
    String str2 = getPathBase(paramString2, paramString3);
    String str3 = Utils.convertPathArgsHashToString(paramMap);
    return new URL(paramBoolean ? "https" : "http", str1, paramInt, str2 + str3);
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.CallingFormat.SubdomainCallingFormat
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

class CallingFormat$VanityCallingFormat
  extends CallingFormat.SubdomainCallingFormat
{
  private CallingFormat$VanityCallingFormat()
  {
    super(null);
  }
  
  public String getServer(String paramString1, String paramString2)
  {
    return paramString2;
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.CallingFormat.VanityCallingFormat
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;

public abstract class CallingFormat
{
  protected static CallingFormat pathCallingFormat = new PathCallingFormat(null);
  protected static CallingFormat subdomainCallingFormat = new SubdomainCallingFormat(null);
  protected static CallingFormat vanityCallingFormat = new VanityCallingFormat(null);
  
  public abstract boolean supportsLocatedBuckets();
  
  public abstract String getEndpoint(String paramString1, int paramInt, String paramString2);
  
  public abstract String getPathBase(String paramString1, String paramString2);
  
  public abstract URL getURL(boolean paramBoolean, String paramString1, int paramInt, String paramString2, String paramString3, Map paramMap)
    throws MalformedURLException;
  
  public static CallingFormat getPathCallingFormat()
  {
    return pathCallingFormat;
  }
  
  public static CallingFormat getSubdomainCallingFormat()
  {
    return subdomainCallingFormat;
  }
  
  public static CallingFormat getVanityCallingFormat()
  {
    return vanityCallingFormat;
  }
  
  private static class PathCallingFormat
    extends CallingFormat
  {
    public boolean supportsLocatedBuckets()
    {
      return false;
    }
    
    public String getPathBase(String paramString1, String paramString2)
    {
      return isBucketSpecified(paramString1) ? "/" + paramString1 + "/" + paramString2 : "/";
    }
    
    public String getEndpoint(String paramString1, int paramInt, String paramString2)
    {
      return paramString1 + ":" + paramInt;
    }
    
    public URL getURL(boolean paramBoolean, String paramString1, int paramInt, String paramString2, String paramString3, Map paramMap)
      throws MalformedURLException
    {
      String str1 = isBucketSpecified(paramString2) ? "/" + paramString2 + "/" + paramString3 : "/";
      String str2 = Utils.convertPathArgsHashToString(paramMap);
      return new URL(paramBoolean ? "https" : "http", paramString1, paramInt, str1 + str2);
    }
    
    private boolean isBucketSpecified(String paramString)
    {
      if (paramString == null) {
        return false;
      }
      if (paramString.length() == 0) {
        return false;
      }
      return true;
    }
  }
  
  private static class SubdomainCallingFormat
    extends CallingFormat
  {
    public boolean supportsLocatedBuckets()
    {
      return true;
    }
    
    public String getServer(String paramString1, String paramString2)
    {
      return paramString2 + "." + paramString1;
    }
    
    public String getEndpoint(String paramString1, int paramInt, String paramString2)
    {
      return getServer(paramString1, paramString2) + ":" + paramInt;
    }
    
    public String getPathBase(String paramString1, String paramString2)
    {
      return "/" + paramString2;
    }
    
    public URL getURL(boolean paramBoolean, String paramString1, int paramInt, String paramString2, String paramString3, Map paramMap)
      throws MalformedURLException
    {
      if ((paramString2 == null) || (paramString2.length() == 0))
      {
        str1 = Utils.convertPathArgsHashToString(paramMap);
        return new URL(paramBoolean ? "https" : "http", paramString1, paramInt, "/" + str1);
      }
      String str1 = getServer(paramString1, paramString2);
      String str2 = getPathBase(paramString2, paramString3);
      String str3 = Utils.convertPathArgsHashToString(paramMap);
      return new URL(paramBoolean ? "https" : "http", str1, paramInt, str2 + str3);
    }
  }
  
  private static class VanityCallingFormat
    extends CallingFormat.SubdomainCallingFormat
  {
    private VanityCallingFormat()
    {
      super();
    }
    
    public String getServer(String paramString1, String paramString2)
    {
      return paramString2;
    }
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.CallingFormat
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

public class CommonPrefixEntry
{
  public String prefix;
}

/* Location:
 * Qualified Name:     com.amazon.s3.CommonPrefixEntry
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class GetResponse
  extends Response
{
  public S3Object object;
  
  public GetResponse(HttpURLConnection paramHttpURLConnection)
    throws IOException
  {
    super(paramHttpURLConnection);
    if (paramHttpURLConnection.getResponseCode() < 400)
    {
      Map localMap = extractMetadata(paramHttpURLConnection);
      byte[] arrayOfByte = slurpInputStream(paramHttpURLConnection.getInputStream());
      object = new S3Object(arrayOfByte, localMap);
    }
  }
  
  private Map extractMetadata(HttpURLConnection paramHttpURLConnection)
  {
    TreeMap localTreeMap = new TreeMap();
    Map localMap = paramHttpURLConnection.getHeaderFields();
    for (Iterator localIterator = localMap.keySet().iterator(); localIterator.hasNext();)
    {
      String str = (String)localIterator.next();
      if (str != null) {
        if (str.startsWith("x-amz-meta-")) {
          localTreeMap.put(str.substring("x-amz-meta-".length()), localMap.get(str));
        }
      }
    }
    return localTreeMap;
  }
  
  static byte[] slurpInputStream(InputStream paramInputStream)
    throws IOException
  {
    byte[] arrayOfByte = new byte['?'];
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream(2048);
    int i;
    while ((i = paramInputStream.read(arrayOfByte)) != -1) {
      localByteArrayOutputStream.write(arrayOfByte, 0, i);
    }
    return localByteArrayOutputStream.toByteArray();
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.GetResponse
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.SimpleTimeZone;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

class ListAllMyBucketsResponse$ListAllMyBucketsHandler
  extends DefaultHandler
{
  private List entries = null;
  private Bucket currBucket = null;
  private StringBuffer currText = null;
  private SimpleDateFormat iso8601Parser = null;
  
  public ListAllMyBucketsResponse$ListAllMyBucketsHandler()
  {
    entries = new ArrayList();
    iso8601Parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    iso8601Parser.setTimeZone(new SimpleTimeZone(0, "GMT"));
    currText = new StringBuffer();
  }
  
  public void startDocument() {}
  
  public void endDocument() {}
  
  public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes)
  {
    if (paramString2.equals("Bucket")) {
      currBucket = new Bucket();
    }
  }
  
  public void endElement(String paramString1, String paramString2, String paramString3)
  {
    if (paramString2.equals("Bucket")) {
      entries.add(currBucket);
    } else if (paramString2.equals("Name")) {
      currBucket.name = currText.toString();
    } else if (paramString2.equals("CreationDate")) {
      try
      {
        currBucket.creationDate = iso8601Parser.parse(currText.toString());
      }
      catch (ParseException localParseException)
      {
        throw new RuntimeException("Unexpected date format in list bucket output", localParseException);
      }
    }
    currText = new StringBuffer();
  }
  
  public void characters(char[] paramArrayOfChar, int paramInt1, int paramInt2)
  {
    currText.append(paramArrayOfChar, paramInt1, paramInt2);
  }
  
  public List getEntries()
  {
    return entries;
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.ListAllMyBucketsResponse.ListAllMyBucketsHandler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.SimpleTimeZone;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

public class ListAllMyBucketsResponse
  extends Response
{
  public List entries;
  
  public ListAllMyBucketsResponse(HttpURLConnection paramHttpURLConnection)
    throws IOException
  {
    super(paramHttpURLConnection);
    if (paramHttpURLConnection.getResponseCode() < 400) {
      try
      {
        XMLReader localXMLReader = Utils.createXMLReader();
        ListAllMyBucketsHandler localListAllMyBucketsHandler = new ListAllMyBucketsHandler();
        localXMLReader.setContentHandler(localListAllMyBucketsHandler);
        localXMLReader.setErrorHandler(localListAllMyBucketsHandler);
        
        localXMLReader.parse(new InputSource(paramHttpURLConnection.getInputStream()));
        entries = localListAllMyBucketsHandler.getEntries();
      }
      catch (SAXException localSAXException)
      {
        throw new RuntimeException("Unexpected error parsing ListAllMyBuckets xml", localSAXException);
      }
    }
  }
  
  static class ListAllMyBucketsHandler
    extends DefaultHandler
  {
    private List entries = null;
    private Bucket currBucket = null;
    private StringBuffer currText = null;
    private SimpleDateFormat iso8601Parser = null;
    
    public ListAllMyBucketsHandler()
    {
      entries = new ArrayList();
      iso8601Parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
      iso8601Parser.setTimeZone(new SimpleTimeZone(0, "GMT"));
      currText = new StringBuffer();
    }
    
    public void startDocument() {}
    
    public void endDocument() {}
    
    public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes)
    {
      if (paramString2.equals("Bucket")) {
        currBucket = new Bucket();
      }
    }
    
    public void endElement(String paramString1, String paramString2, String paramString3)
    {
      if (paramString2.equals("Bucket")) {
        entries.add(currBucket);
      } else if (paramString2.equals("Name")) {
        currBucket.name = currText.toString();
      } else if (paramString2.equals("CreationDate")) {
        try
        {
          currBucket.creationDate = iso8601Parser.parse(currText.toString());
        }
        catch (ParseException localParseException)
        {
          throw new RuntimeException("Unexpected date format in list bucket output", localParseException);
        }
      }
      currText = new StringBuffer();
    }
    
    public void characters(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    {
      currText.append(paramArrayOfChar, paramInt1, paramInt2);
    }
    
    public List getEntries()
    {
      return entries;
    }
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.ListAllMyBucketsResponse
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.SimpleTimeZone;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

class ListBucketResponse$ListBucketHandler
  extends DefaultHandler
{
  private String name = null;
  private String prefix = null;
  private String marker = null;
  private String delimiter = null;
  private int maxKeys = 0;
  private boolean isTruncated = false;
  private String nextMarker = null;
  private boolean isEchoedPrefix = false;
  private List keyEntries = null;
  private ListEntry keyEntry = null;
  private List commonPrefixEntries = null;
  private CommonPrefixEntry commonPrefixEntry = null;
  private StringBuffer currText = null;
  private SimpleDateFormat iso8601Parser = null;
  
  public ListBucketResponse$ListBucketHandler(ListBucketResponse paramListBucketResponse)
  {
    keyEntries = new ArrayList();
    commonPrefixEntries = new ArrayList();
    iso8601Parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
    iso8601Parser.setTimeZone(new SimpleTimeZone(0, "GMT"));
    currText = new StringBuffer();
  }
  
  public void startDocument()
  {
    isEchoedPrefix = true;
  }
  
  public void endDocument() {}
  
  public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes)
  {
    if (paramString2.equals("Contents")) {
      keyEntry = new ListEntry();
    } else if (paramString2.equals("Owner")) {
      keyEntry.owner = new Owner();
    } else if (paramString2.equals("CommonPrefixes")) {
      commonPrefixEntry = new CommonPrefixEntry();
    }
  }
  
  public void endElement(String paramString1, String paramString2, String paramString3)
  {
    if (paramString2.equals("Name"))
    {
      name = currText.toString();
    }
    else if ((paramString2.equals("Prefix")) && (isEchoedPrefix))
    {
      prefix = currText.toString();
      isEchoedPrefix = false;
    }
    else if (paramString2.equals("Marker"))
    {
      marker = currText.toString();
    }
    else if (paramString2.equals("MaxKeys"))
    {
      maxKeys = Integer.parseInt(currText.toString());
    }
    else if (paramString2.equals("Delimiter"))
    {
      delimiter = currText.toString();
    }
    else if (paramString2.equals("IsTruncated"))
    {
      isTruncated = Boolean.valueOf(currText.toString()).booleanValue();
    }
    else if (paramString2.equals("NextMarker"))
    {
      nextMarker = currText.toString();
    }
    else if (paramString2.equals("Contents"))
    {
      keyEntries.add(keyEntry);
    }
    else if (paramString2.equals("Key"))
    {
      keyEntry.key = currText.toString();
    }
    else if (paramString2.equals("LastModified"))
    {
      try
      {
        keyEntry.lastModified = iso8601Parser.parse(currText.toString());
      }
      catch (ParseException localParseException)
      {
        throw new RuntimeException("Unexpected date format in list bucket output", localParseException);
      }
    }
    else if (paramString2.equals("ETag"))
    {
      keyEntry.eTag = currText.toString();
    }
    else if (paramString2.equals("Size"))
    {
      keyEntry.size = Long.parseLong(currText.toString());
    }
    else if (paramString2.equals("StorageClass"))
    {
      keyEntry.storageClass = currText.toString();
    }
    else if (paramString2.equals("ID"))
    {
      keyEntry.owner.id = currText.toString();
    }
    else if (paramString2.equals("DisplayName"))
    {
      keyEntry.owner.displayName = currText.toString();
    }
    else if (paramString2.equals("CommonPrefixes"))
    {
      commonPrefixEntries.add(commonPrefixEntry);
    }
    else if (paramString2.equals("Prefix"))
    {
      commonPrefixEntry.prefix = currText.toString();
    }
    if (currText.length() != 0) {
      currText = new StringBuffer();
    }
  }
  
  public void characters(char[] paramArrayOfChar, int paramInt1, int paramInt2)
  {
    currText.append(paramArrayOfChar, paramInt1, paramInt2);
  }
  
  public String getName()
  {
    return name;
  }
  
  public String getPrefix()
  {
    return prefix;
  }
  
  public String getMarker()
  {
    return marker;
  }
  
  public String getDelimiter()
  {
    return delimiter;
  }
  
  public int getMaxKeys()
  {
    return maxKeys;
  }
  
  public boolean getIsTruncated()
  {
    return isTruncated;
  }
  
  public String getNextMarker()
  {
    return nextMarker;
  }
  
  public List getKeyEntries()
  {
    return keyEntries;
  }
  
  public List getCommonPrefixEntries()
  {
    return commonPrefixEntries;
  }
}

/* Location:
 * Qualified Name:     com.amazon.s3.ListBucketResponse.ListBucketHandler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package com.amazon.s3;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.SimpleTimeZone;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

public class ListBucketResponse
  extends Response
{
  public String name = null;
  public String prefix = null;
  public String marker = null;
  public String delimiter = null;
  public int maxKeys = 0;
  public boolean isTruncated = false;
  public String nextMarker = null;
  public List entries = null;
  public List commonPrefixEntries = null;
  
  public ListBucketResponse(HttpURLConnection paramHttpURLConnection)
    throws IOException
  {
    super(paramHttpURLConnection);
    if (paramHttpURLConnection.getResponseCode() < 400) {
      try
      {
        XMLReader localXMLReader = Utils.createXMLReader();
        ListBucketHandler localListBucketHandler = new ListBucketHandler();
        localXMLReader.setContentHandler(localListBucketHandler);
        localXMLReader.setErrorHandler(localListBucketHandler);
        
        localXMLReader.parse(new InputSource(paramHttpURLConnection.getInputStream()));
        
        name = localListBucketHandler.getName();
        prefix = localListBucketHandler.getPrefix();
        marker = localListBucketHandler.getMarker();
        delimiter = localListBucketHandler.getDelimiter();
        maxKeys = localListBucketHandler.getMaxKeys();
        isTruncated = localListBucketHandler.getIsTruncated();
        nextMarker = localListBucketHandler.getNextMarker();
        entries = localListBucketHandler.getKeyEntries();
        commonPrefixEntries = localListBucketHandler.getCommonPrefixEntries();
      }
      catch (SAXException localSAXException)
      {
        throw new RuntimeException("Unexpected error parsing ListBucket xml", localSAXException);
      }
    }
  }
  
  class ListBucketHandler
    extends DefaultHandler
  {
    private String name = null;
    private String prefix = null;
    private String marker = null;
    private String delimiter = null;
    private int maxKeys = 0;
    private boolean isTruncated = false;
    private String nextMarker = null;
    private boolean isEchoedPrefix = false;
    private List keyEntries = null;
    private ListEntry keyEntry = null;
    private List commonPrefixEntries = null;
    private CommonPrefixEntry commonPrefixEntry = null;
    private StringBuffer currText = null;
    private SimpleDateFormat iso8601Parser = null;
    
    public ListBucketHandler()
    {
      keyEntries = new ArrayList();
      commonPrefixEntries = new ArrayList();
      iso8601Parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
      iso8601Parser.setTimeZone(new SimpleTimeZone(0, "GMT"));
      currText = new StringBuffer();
    }
    
    public void startDocument()
    {
      isEchoedPrefix = true;
    }
    
    public void endDocument() {}
    
    public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes)
    {
      if (paramString2.equals("Contents")) {
        keyEntry = new ListEntry();
      } else if (paramString2.equals("Owner")) {
        keyEntry.owner = new Owner();
      } else if (paramString2.equals("CommonPrefixes")) {
        commonPrefixEntry = new CommonPrefixEntry();
      }
    }
    
    public void endElement(String paramString1, String paramString2, String paramString3)
    {
      if (paramString2.equals("Name"))
      {
        name = currText.toString();
      }
      else if ((paramString2.equals("Prefix")) && (isEchoedPrefix))
      {
        prefix = currText.toString();
        isEchoedPrefix = false;
      }
      else if (paramString2.equals("Marker"))
      {
        marker = currText.toString();
      }
      else if (paramString2.equals("MaxKeys"))
      {
        maxKeys = Integer.parseInt(currText.toString());
      }
      else if (paramString2.equals("Delimiter"))
      {
        delimiter = currText.toString();
      }
      else if (paramString2.equals("IsTruncated"))
      {
        isTruncated = Boolean.valueOf(currText.toString()).booleanValue();
      }
      else if (paramString2.equals("NextMarker"))
      {
        nextMarker = currText.toString();
      }
      else if (paramString2.equals("Contents"))
      {
        keyEntries.add(keyEntry);
      }
      else if (paramString2.equals("Key"))
      {
        keyEntry.key = currText.toString();
      }
      else if (paramString2.equals("LastModified"))
      {
        try
        {
          keyEntry.lastModified = iso8601Parser.parse(currText.toString());
        }
        catch (ParseException localParseException)
        {
          throw new RuntimeException("Unexpected date format in list bucket 
1 2 3

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd