com.xerox.amazonws.common
Class AWSConnection

java.lang.Object
  extended by com.xerox.amazonws.common.AWSConnection
Direct Known Subclasses:
AWSAuthConnection, AWSQueryConnection

public abstract class AWSConnection
extends Object

This class provides common code to the query and rest connection classes

Author:
D. Kavanagh, developer@dotech.com

Field Summary
protected  Map<String,List<String>> headers
           
 
Constructor Summary
AWSConnection(String awsAccessId, String awsSecretKey, boolean isSecure, String server, int port)
          Initializes the queue service with your AWS login information.
 
Method Summary
protected  String encode(String awsSecretKey, String canonicalString, boolean urlencode)
          Calculate the HMAC/SHA1 on a string.
protected  String encode(String awsSecretKey, String canonicalString, boolean urlencode, String algorithm)
           
protected  String getAlgorithm()
           
 String getAwsAccessKeyId()
           
 int getPort()
           
 String getResourcePrefix()
           
 String getSecretAccessKey()
           
 String getServer()
           
 int getSignatureVersion()
          This method returns the signature version
 URL getUrl()
          This method provides the URL for the queue service based on initialization.
 boolean isSecure()
           
protected  URL makeURL(String resource)
          Create a new URL object for a given resource.
 void setResourcePrefix(String prefix)
           
 void setServer(String server)
           
 void setSignatureVersion(int version)
          This method sets the signature version used to sign requests (0, 1 or 2).
protected  String urlencode(String unencoded)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

headers

protected Map<String,List<String>> headers
Constructor Detail

AWSConnection

public AWSConnection(String awsAccessId,
                     String awsSecretKey,
                     boolean isSecure,
                     String server,
                     int port)
Initializes the queue service with your AWS login information.

Parameters:
awsAccessId - The your user key into AWS
awsSecretKey - The secret string used to generate signatures for authentication.
isSecure - True if the data should be encrypted on the wire on the way to or from SQS.
server - Which host to connect to.
port - Which port to use.
Method Detail

getUrl

public URL getUrl()
This method provides the URL for the queue service based on initialization.

Returns:
generated queue service url

getAwsAccessKeyId

public String getAwsAccessKeyId()

getSecretAccessKey

public String getSecretAccessKey()

isSecure

public boolean isSecure()

getServer

public String getServer()

setServer

public void setServer(String server)

getPort

public int getPort()

getResourcePrefix

public String getResourcePrefix()

setResourcePrefix

public void setResourcePrefix(String prefix)

getSignatureVersion

public int getSignatureVersion()
This method returns the signature version

Returns:
the version

setSignatureVersion

public void setSignatureVersion(int version)
This method sets the signature version used to sign requests (0, 1 or 2). NOTE: This value defaults to 2, so passing 1 is the most likely use case.

Parameters:
version - signature version

makeURL

protected URL makeURL(String resource)
               throws MalformedURLException
Create a new URL object for a given resource.

Parameters:
resource - The resource name (bucketName + "/" + key).
Throws:
MalformedURLException

encode

protected String encode(String awsSecretKey,
                        String canonicalString,
                        boolean urlencode)
Calculate the HMAC/SHA1 on a string.

Parameters:
awsSecretKey - passcode to sign it with
canonicalString - data to sign
Returns:
signature
Throws:
NoSuchAlgorithmException - If the algorithm does not exist. Unlikely
InvalidKeyException - If the key is invalid.

encode

protected String encode(String awsSecretKey,
                        String canonicalString,
                        boolean urlencode,
                        String algorithm)

getAlgorithm

protected String getAlgorithm()

urlencode

protected String urlencode(String unencoded)