Skip to content

Commit 1f9cec1

Browse files
committed
v2
1 parent 7c0478c commit 1f9cec1

26 files changed

+338
-334
lines changed

.github/workflows/CI.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Java Build
22

33
on: [push, pull_request]
44

5+
env:
6+
AWS_DEFAULT_REGION: us-west-2
7+
58
jobs:
69
build:
710
runs-on: ubuntu-latest
@@ -16,4 +19,4 @@ jobs:
1619
- name: Build with Maven
1720
run: mvn --batch-mode --update-snapshots package
1821
- name: Codecov
19-
uses: codecov/codecov-action@v3.1.0
22+
uses: codecov/codecov-action@v3.1.4

.github/workflows/codeql-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ name: "CodeQL"
1313

1414
on:
1515
push:
16-
branches: [ "master" ]
16+
branches: ["master", "v2"]
1717
pull_request:
18-
branches: [ "master" ]
18+
branches: ["master", "v2"]
1919
schedule:
2020
- cron: '38 2 * * 1'
2121

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jacoco.exec
1717
# Eclipse m2e generated files
1818
# Eclipse Core
1919
.project
20+
.settings
2021
# JDT-specific (Eclipse Java Development Tools)
2122
.classpath
2223

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AWS Secrets Manager JDBC Library
22

33
[![Java Build](https://github.com/aws/aws-secretsmanager-jdbc/actions/workflows/CI.yml/badge.svg?event=push)](https://github.com/aws/aws-secretsmanager-jdbc/actions/workflows/CI.yml)
4-
[![Coverage](https://codecov.io/gh/aws/aws-secretsmanager-jdbc/branch/master/graph/badge.svg?token=hCl7eBaSwn)](https://codecov.io/gh/aws/aws-secretsmanager-jdbc)
4+
[![Coverage](https://codecov.io/gh/aws/aws-secretsmanager-jdbc/branch/v2/graph/badge.svg?token=hCl7eBaSwn)](https://codecov.io/gh/aws/aws-secretsmanager-jdbc)
55

66
The **AWS Secrets Manager JDBC Library** enables Java developers to easily connect to SQL databases using secrets stored in AWS Secrets Manager.
77

@@ -25,7 +25,7 @@ The recommended way to use the SQL Connection Library is to consume it from Mave
2525
<dependency>
2626
<groupId>com.amazonaws.secretsmanager</groupId>
2727
<artifactId>aws-secretsmanager-jdbc</artifactId>
28-
<version>1.0.12</version>
28+
<version>2.0.0</version>
2929
</dependency>
3030
```
3131

pom.xml

+38-68
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,13 @@
1616
<artifactId>aws-secretsmanager-jdbc</artifactId>
1717
<packaging>jar</packaging>
1818
<name>AWS Secrets Manager SQL Connection Library</name>
19-
<version>1.0.12</version>
19+
<version>2.0.0</version>
2020
<description>The AWS Secrets Manager SQL Connection Library for Java enables Java developers to easily
2121
connect to SQL databases using secrets stored in AWS Secrets Manager.
2222
</description>
2323
<url>https://aws.amazon.com/secrets-manager</url>
2424

2525
<properties>
26-
<aws-java-sdk.version>1.12.252</aws-java-sdk.version>
27-
<aws-secretsmanager-cache.version>1.0.2</aws-secretsmanager-cache.version>
28-
<lombok.version>1.18.24</lombok.version>
29-
<jackson.version>2.14.1</jackson.version>
30-
<junit.version>4.13.2</junit.version>
31-
<mockito.version>1.10.19</mockito.version>
32-
<powermock.version>1.7.0</powermock.version>
33-
<compiler.plugin.version>3.10.1</compiler.plugin.version>
34-
<javadoc.plugin.version>3.4.0</javadoc.plugin.version>
35-
<source.plugin.version>3.2.1</source.plugin.version>
36-
<checkstyle.plugin.version>3.1.2</checkstyle.plugin.version>
37-
<spotbugs.plugin.version>4.7.3.5</spotbugs.plugin.version>
3826
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3927
</properties>
4028

@@ -76,61 +64,67 @@
7664
<dependency>
7765
<groupId>com.amazonaws.secretsmanager</groupId>
7866
<artifactId>aws-secretsmanager-caching-java</artifactId>
79-
<version>${aws-secretsmanager-cache.version}</version>
67+
<version>2.0.0</version>
8068
</dependency>
8169

8270
<dependency>
83-
<groupId>com.amazonaws</groupId>
84-
<artifactId>aws-java-sdk-secretsmanager</artifactId>
85-
<version>${aws-java-sdk.version}</version>
71+
<groupId>software.amazon.awssdk</groupId>
72+
<artifactId>secretsmanager</artifactId>
73+
<version>2.20.93</version>
8674
</dependency>
8775

8876
<dependency>
8977
<groupId>org.projectlombok</groupId>
9078
<artifactId>lombok</artifactId>
91-
<version>${lombok.version}</version>
79+
<version>1.18.28</version>
9280
<scope>provided</scope>
9381
</dependency>
9482

9583
<dependency>
9684
<groupId>com.fasterxml.jackson.core</groupId>
9785
<artifactId>jackson-databind</artifactId>
98-
<version>${jackson.version}</version>
86+
<version>2.15.2</version>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>com.github.spotbugs</groupId>
91+
<artifactId>spotbugs-annotations</artifactId>
92+
<version>4.7.3</version>
9993
</dependency>
10094

10195
<dependency>
10296
<groupId>junit</groupId>
10397
<artifactId>junit</artifactId>
104-
<version>${junit.version}</version>
98+
<version>4.13.2</version>
10599
<scope>test</scope>
106100
</dependency>
107101

108102
<dependency>
109-
<groupId>org.mockito</groupId>
110-
<artifactId>mockito-all</artifactId>
111-
<version>${mockito.version}</version>
103+
<groupId>com.github.stefanbirkner</groupId>
104+
<artifactId>system-rules</artifactId>
105+
<version>1.19.0</version>
112106
<scope>test</scope>
113107
</dependency>
114108

115109
<dependency>
116-
<groupId>org.powermock</groupId>
117-
<artifactId>powermock-module-junit4</artifactId>
118-
<version>${powermock.version}</version>
110+
<groupId>org.mockito</groupId>
111+
<artifactId>mockito-inline</artifactId>
112+
<version>3.12.4</version>
119113
<scope>test</scope>
120114
</dependency>
121115

122116
<dependency>
123117
<groupId>org.powermock</groupId>
124-
<artifactId>powermock-api-mockito</artifactId>
125-
<version>${powermock.version}</version>
118+
<artifactId>powermock-module-junit4</artifactId>
119+
<version>2.0.9</version>
126120
<scope>test</scope>
127121
</dependency>
128122

129123
<dependency>
130-
<groupId>org.jacoco</groupId>
131-
<artifactId>org.jacoco.agent</artifactId>
132-
<classifier>runtime</classifier>
133-
<version>0.8.8</version>
124+
<groupId>org.powermock</groupId>
125+
<artifactId>powermock-api-mockito2</artifactId>
126+
<version>2.0.9</version>
127+
<scope>test</scope>
134128
</dependency>
135129
</dependencies>
136130

@@ -139,17 +133,17 @@
139133
<plugin>
140134
<groupId>org.apache.maven.plugins</groupId>
141135
<artifactId>maven-compiler-plugin</artifactId>
142-
<version>${compiler.plugin.version}</version>
136+
<version>3.11.0</version>
143137
<configuration>
144-
<source>1.8</source>
145-
<target>1.8</target>
138+
<source>11</source>
139+
<target>11</target>
146140
<encoding>UTF-8</encoding>
147141
</configuration>
148142
</plugin>
149143
<plugin>
150144
<groupId>org.apache.maven.plugins</groupId>
151145
<artifactId>maven-source-plugin</artifactId>
152-
<version>${source.plugin.version}</version>
146+
<version>3.3.0</version>
153147
<executions>
154148
<execution>
155149
<id>attach-sources</id>
@@ -162,7 +156,7 @@
162156
<plugin>
163157
<groupId>org.apache.maven.plugins</groupId>
164158
<artifactId>maven-javadoc-plugin</artifactId>
165-
<version>${javadoc.plugin.version}</version>
159+
<version>3.5.0</version>
166160
<executions>
167161
<execution>
168162
<id>attach-javadocs</id>
@@ -175,10 +169,9 @@
175169
<plugin>
176170
<groupId>org.apache.maven.plugins</groupId>
177171
<artifactId>maven-checkstyle-plugin</artifactId>
178-
<version>${checkstyle.plugin.version}</version>
172+
<version>3.3.0</version>
179173
<configuration>
180174
<configLocation>${basedir}/config/checkstyle/checkstyle.xml</configLocation>
181-
<encoding>UTF-8</encoding>
182175
<consoleOutput>true</consoleOutput>
183176
<failsOnError>true</failsOnError>
184177
<linkXRef>false</linkXRef>
@@ -197,7 +190,7 @@
197190
<plugin>
198191
<groupId>com.github.spotbugs</groupId>
199192
<artifactId>spotbugs-maven-plugin</artifactId>
200-
<version>${spotbugs.plugin.version}</version>
193+
<version>4.7.3.5</version>
201194
<configuration>
202195
<effort>Max</effort>
203196
<threshold>Low</threshold>
@@ -216,45 +209,22 @@
216209
<plugin>
217210
<groupId>org.jacoco</groupId>
218211
<artifactId>jacoco-maven-plugin</artifactId>
219-
<version>0.8.8</version>
212+
<version>0.8.10</version>
220213
<executions>
221214
<execution>
222-
<id>default-instrument</id>
223215
<goals>
224-
<goal>instrument</goal>
225-
</goals>
226-
</execution>
227-
<execution>
228-
<id>default-restore-instrumented-classes</id>
229-
<goals>
230-
<goal>restore-instrumented-classes</goal>
216+
<goal>prepare-agent</goal>
231217
</goals>
232218
</execution>
233219
<execution>
234220
<id>report</id>
235-
<phase>prepare-package</phase>
221+
<phase>test</phase>
236222
<goals>
237223
<goal>report</goal>
238224
</goals>
239225
</execution>
240-
<execution>
241-
<id>default-check</id>
242-
<goals>
243-
<goal>check</goal>
244-
</goals>
245-
</execution>
246226
</executions>
247227
</plugin>
248-
<plugin>
249-
<groupId>org.apache.maven.plugins</groupId>
250-
<artifactId>maven-surefire-plugin</artifactId>
251-
<version>2.22.2</version>
252-
<configuration>
253-
<systemPropertyVariables>
254-
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
255-
</systemPropertyVariables>
256-
</configuration>
257-
</plugin>
258228
</plugins>
259229
</build>
260230

@@ -266,7 +236,7 @@
266236
<plugin>
267237
<groupId>org.apache.maven.plugins</groupId>
268238
<artifactId>maven-gpg-plugin</artifactId>
269-
<version>3.0.1</version>
239+
<version>3.1.0</version>
270240
<executions>
271241
<execution>
272242
<id>sign-artifacts</id>
@@ -292,4 +262,4 @@
292262
</build>
293263
</profile>
294264
</profiles>
295-
</project>
265+
</project>

src/main/java/com/amazonaws/secretsmanager/sql/AWSSecretsManagerDriver.java

+17-14
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@
1212
*/
1313
package com.amazonaws.secretsmanager.sql;
1414

15-
import com.amazonaws.secretsmanager.util.Config;
16-
import com.amazonaws.secretsmanager.caching.SecretCache;
17-
import com.amazonaws.secretsmanager.caching.SecretCacheConfiguration;
18-
import com.amazonaws.secretsmanager.util.JDBCSecretCacheBuilderProvider;
19-
import com.amazonaws.services.secretsmanager.AWSSecretsManager;
20-
import com.amazonaws.services.secretsmanager.AWSSecretsManagerClientBuilder;
21-
import com.amazonaws.util.StringUtils;
22-
import com.fasterxml.jackson.databind.JsonNode;
23-
import com.fasterxml.jackson.databind.ObjectMapper;
24-
2515
import java.io.IOException;
2616
import java.sql.Connection;
2717
import java.sql.Driver;
@@ -33,6 +23,19 @@
3323
import java.util.Properties;
3424
import java.util.logging.Logger;
3525

26+
import com.amazonaws.secretsmanager.caching.SecretCache;
27+
import com.amazonaws.secretsmanager.caching.SecretCacheConfiguration;
28+
import com.amazonaws.secretsmanager.util.Config;
29+
import com.amazonaws.secretsmanager.util.JDBCSecretCacheBuilderProvider;
30+
import com.fasterxml.jackson.databind.JsonNode;
31+
import com.fasterxml.jackson.databind.ObjectMapper;
32+
33+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34+
35+
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClient;
36+
import software.amazon.awssdk.services.secretsmanager.SecretsManagerClientBuilder;
37+
import software.amazon.awssdk.utils.StringUtils;
38+
3639
/**
3740
* <p>
3841
* Provides support for accessing SQL databases using credentials stored within AWS Secrets Manager. If this
@@ -130,6 +133,7 @@ protected AWSSecretsManagerDriver() {
130133
*
131134
* @param cache Secret cache to use to retrieve secrets
132135
*/
136+
@SuppressFBWarnings("MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR")
133137
protected AWSSecretsManagerDriver(SecretCache cache) {
134138
this.secretCache = cache;
135139

@@ -143,7 +147,7 @@ protected AWSSecretsManagerDriver(SecretCache cache) {
143147
*
144148
* @param builder Builder used to instantiate cache
145149
*/
146-
protected AWSSecretsManagerDriver(AWSSecretsManagerClientBuilder builder) {
150+
protected AWSSecretsManagerDriver(SecretsManagerClientBuilder builder) {
147151
this(new SecretCache(builder));
148152
}
149153

@@ -153,7 +157,7 @@ protected AWSSecretsManagerDriver(AWSSecretsManagerClientBuilder builder) {
153157
*
154158
* @param client AWS Secrets Manager client to instantiate cache
155159
*/
156-
protected AWSSecretsManagerDriver(AWSSecretsManager client) {
160+
protected AWSSecretsManagerDriver(SecretsManagerClient client) {
157161
this(new SecretCache(client));
158162
}
159163

@@ -380,7 +384,7 @@ public Connection connect(String url, Properties info) throws SQLException {
380384
} else { // Else, assume this is a secret ID and try to retrieve it
381385
try {
382386
String secretString = secretCache.getSecretString(url);
383-
if (StringUtils.isNullOrEmpty(secretString)) {
387+
if (StringUtils.isBlank(secretString)) {
384388
throw new IllegalArgumentException("URL " + url + " is not a valid URL starting with scheme " +
385389
SCHEME + " or a valid retrievable secret ID ");
386390
}
@@ -437,4 +441,3 @@ public boolean jdbcCompliant() {
437441
return getWrappedDriver().jdbcCompliant();
438442
}
439443
}
440-

0 commit comments

Comments
 (0)