skyscreamer / nevado

A JMS driver for Amazon SQS.

Home Page:http://nevado.skyscreamer.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding support for BasicSessionCredentials

xbranko opened this issue · comments

Would it be possible to add support for BasicSessionCredentials too? In my company we use BasicSessionCredentials and not BasicAWSCredentials.

Looking at the code, it seems that this would require a minimal and rather local change to the constructor for the AmazonAwsSQSConnector, to allow it to get the sessionToken in addition to the current parameters:

 public AmazonAwsSQSConnector(String awsAccessKey, String awsSecretKey, String awsSessionToken, boolean isSecure, long receiveCheckIntervalMs) {
    this(awsAccessKey, awsSecretKey, awsSessionToken, isSecure, receiveCheckIntervalMs, false);
}

 public AmazonAwsSQSConnector(String awsAccessKey, String awsSecretKey, String awsSessionToken, boolean isSecure, long receiveCheckIntervalMs, boolean isAsync) {
    super(receiveCheckIntervalMs, isAsync);
    AWSCredentials awsCredentials = (awsSessionToken == null)? new BasicAWSCredentials(awsAccessKey, awsSecretKey) : new BasicSessionCredentials(awsAccessKey, awsSecretKey, awsSessionToken); 
// ... everything else stays the same

Other required change is in the AmazonAwsSQSConnectorFactory where the AmazonAwsSQSConnector is used:

 public AmazonAwsSQSConnector getInstance(String awsAccessKey, String awsSecretKey, String awsSessionToken, String awsSQSEndpoint, String awsSNSEndpoint) {
    AmazonAwsSQSConnector amazonAwsSQSConnector = new AmazonAwsSQSConnector(awsAccessKey, awsSecretKey, awsSessionToken, _isSecure,
            _receiveCheckIntervalMs, _useAsyncSend); 
// ... everything else stays the same

This way people who use BasicAWSCredentials will still be able to with minimal effort.

Many thanks in advance!