aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/sms/SnsSmsClient.java
diff options
context:
space:
mode:
authorSubodh Ranadive <subodh.ranadive@ekzero.com>2021-03-04 14:53:05 +0530
committerSubodh Ranadive <subodh.ranadive@ekzero.com>2021-03-24 15:30:31 +0530
commit49b8cdc68d4ea2ab2e93e6d9d1622f3e828a7776 (patch)
treea593bb4a5c5ed662488c6f4692cdea296673facd /src/main/java/org/traccar/sms/SnsSmsClient.java
parentd2dc1f983a9b5fc579b24c406587260e726dc35d (diff)
downloadtrackermap-server-49b8cdc68d4ea2ab2e93e6d9d1622f3e828a7776.tar.gz
trackermap-server-49b8cdc68d4ea2ab2e93e6d9d1622f3e828a7776.tar.bz2
trackermap-server-49b8cdc68d4ea2ab2e93e6d9d1622f3e828a7776.zip
feature : added support of AWS SNS messaging
Diffstat (limited to 'src/main/java/org/traccar/sms/SnsSmsClient.java')
-rw-r--r--src/main/java/org/traccar/sms/SnsSmsClient.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/sms/SnsSmsClient.java b/src/main/java/org/traccar/sms/SnsSmsClient.java
index 81114e5f5..0c2be0bd2 100644
--- a/src/main/java/org/traccar/sms/SnsSmsClient.java
+++ b/src/main/java/org/traccar/sms/SnsSmsClient.java
@@ -21,6 +21,7 @@ import com.amazonaws.services.sns.AmazonSNS;
import com.amazonaws.services.sns.AmazonSNSClientBuilder;
import com.amazonaws.services.sns.model.MessageAttributeValue;
import com.amazonaws.services.sns.model.PublishRequest;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
@@ -30,25 +31,25 @@ import org.traccar.notification.MessageException;
import java.util.HashMap;
import java.util.Map;
-
public class SnsSmsClient implements SmsManager {
private static final Logger LOGGER = LoggerFactory.getLogger(SnsSmsClient.class);
private final AmazonSNS snsClient;
public SnsSmsClient() {
- if (Context.getConfig().getString(Keys.AWS_REGION) == null
- || Context.getConfig().getString(Keys.AWS_ACCESS_KEY) == null
- || Context.getConfig().getString(Keys.AWS_SECRET_KEY) == null) {
+ if (Context.getConfig().hasKey(Keys.SMS_AWS_REGION)
+ && Context.getConfig().hasKey(Keys.SMS_AWS_ACCESS)
+ && Context.getConfig().hasKey(Keys.SMS_AWS_SECRET)) {
+ snsClient = awsSNSClient();
+ } else {
throw new RuntimeException("SNS Not Configured Properly. Please provide valid config.");
}
- snsClient = awsSNSClient();
}
public AmazonSNS awsSNSClient() {
- BasicAWSCredentials awsCredentials = new BasicAWSCredentials(Context.getConfig().getString(Keys.AWS_ACCESS_KEY),
- Context.getConfig().getString(Keys.AWS_SECRET_KEY));
- return AmazonSNSClientBuilder.standard().withRegion(Context.getConfig().getString(Keys.AWS_REGION))
+ BasicAWSCredentials awsCredentials = new BasicAWSCredentials(Context.getConfig().getString(Keys.SMS_AWS_ACCESS),
+ Context.getConfig().getString(Keys.SMS_AWS_SECRET));
+ return AmazonSNSClientBuilder.standard().withRegion(Context.getConfig().getString(Keys.SMS_AWS_REGION))
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build();
}