Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Dependency upgrade and more logging (#18)
Browse files Browse the repository at this point in the history
* Adding more logging
* Updating dependencies
* Increasing version to 2.2.0
  • Loading branch information
tlisonbee authored May 2, 2017
1 parent aef2b03 commit 4d1361b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#

version=2.1.0
version=2.2.0
groupId=com.nike
artifactId=cerberus-client
6 changes: 4 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ repositories {
jcenter()
}

def AWS_SDK_VERSION = '1.11.75'
def AWS_SDK_VERSION = '1.11.123'
def VAULT_CLIENT_COORDINATES = "com.nike:vault-client:1.3.0"

//noinspection GroovyAssignabilityCheck
dependencies {

Expand All @@ -38,12 +39,13 @@ dependencies {
compile VAULT_CLIENT_COORDINATES
shadow "joda-time:joda-time:2.8.1"
shadow "org.apache.commons:commons-lang3:3.4"
shadow "org.slf4j:slf4j-api:1.7.14"
shadow "org.slf4j:slf4j-api:1.7.25"

compile "com.amazonaws:aws-java-sdk-core:${AWS_SDK_VERSION}"
compile "com.amazonaws:aws-java-sdk-kms:${AWS_SDK_VERSION}"
compile "com.amazonaws:aws-java-sdk-lambda:${AWS_SDK_VERSION}"

testRuntime 'org.slf4j:slf4j-simple:1.7.25'
testCompile "junit:junit:4.12"
testCompile ("org.mockito:mockito-core:1.10.19") {
exclude group: 'org.hamcrest'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public abstract class BaseAwsCredentialsProvider implements VaultCredentialsProv
public BaseAwsCredentialsProvider(UrlResolver urlResolver) {
super();
this.urlResolver = urlResolver;

cerberusJavaClientHeaderValue = ClientVersion.getClientHeaderValue();
LOGGER.info("Cerberus URL={}", urlResolver.resolve());
}

/**
Expand All @@ -117,7 +117,17 @@ public BaseAwsCredentialsProvider(UrlResolver urlResolver) {
public VaultCredentials getCredentials() {
readLock.lock();
try {
if (credentials == null || expireDateTime.isBeforeNow()) {
boolean needsToAuthenticate = false;
if (credentials == null) {
// initial state: no credentials
needsToAuthenticate = true;
}
else if (expireDateTime.isBeforeNow()) {
// credentials have expired
needsToAuthenticate = true;
LOGGER.info("Cerberus credentials have expired {}, re-authenticating...", expireDateTime);
}
if (needsToAuthenticate) {
// Release the read lock and acquire a write lock
readLock.unlock();
writeLock.lock();
Expand Down Expand Up @@ -217,10 +227,11 @@ protected String getEncryptedAuthData(final String iamPrincipalArn, Region regio
final String key = "auth_data";

if (authData.containsKey(key)) {
LOGGER.info(String.format("Authentication successful with AWS IAM principal ARN [%s] against [%s]",
iamPrincipalArn, url));
return authData.get(key);
} else {
throw new VaultClientException(
"Success response from IAM role authenticate endpoint missing auth data!");
throw new VaultClientException("Success response from IAM role authenticate endpoint missing auth data!");
}
} catch (IOException e) {
throw new VaultClientException("I/O error while communicating with Cerberus", e);
Expand Down

0 comments on commit 4d1361b

Please sign in to comment.