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

Commit

Permalink
Merge pull request #22 from Nike-Inc/feature/add_client_version_heade…
Browse files Browse the repository at this point in the history
…r_to_all_calls

Allow X-Cerberus-Client override + update copyright
  • Loading branch information
sdford authored Jul 20, 2017
2 parents 3d35373 + 3d506d5 commit df0dd82
Show file tree
Hide file tree
Showing 36 changed files with 302 additions and 24 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion codequality/suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>

<!--
~ Copyright (c) 2016 Nike, Inc.
~ Copyright (c) 2017 Nike, Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016 Nike, Inc.
# Copyright (c) 2017 Nike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -13,6 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
version=2.4.0
version=3.0.0
groupId=com.nike
artifactId=cerberus-client
2 changes: 1 addition & 1 deletion gradle/bintray.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion gradle/buildscript.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion gradle/check.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion gradle/integration.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2016 Nike, Inc.
# Copyright (c) 2017 Nike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client.auth.aws;

import com.fieldju.commons.EnvUtils;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/nike/cerberus/client/ClientVersion.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client;

import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,4 +57,27 @@ public DefaultCerberusCredentialsProviderChain(UrlResolver urlResolver) {
new InstanceProfileArnVaultCredentialsProvider(urlResolver),
new InstanceRoleVaultCredentialsProvider(urlResolver));
}

/**
* Constructor that sets up a provider chain using the specified implementation of UrlResolver.
*
* @param xCerberusClientOverride - Overrides the default header value for the 'X-Cerberus-Client' header
*/
public DefaultCerberusCredentialsProviderChain(String xCerberusClientOverride) {
this(new DefaultCerberusUrlResolver(), xCerberusClientOverride);
}

/**
* Constructor that sets up a provider chain using the specified implementation of UrlResolver.
*
* @param urlResolver Resolves the Cerberus URL
* @param xCerberusClientOverride - Overrides the default header value for the 'X-Cerberus-Client' header
*/
public DefaultCerberusCredentialsProviderChain(UrlResolver urlResolver, String xCerberusClientOverride) {
super(new EnvironmentCerberusCredentialsProvider(),
new SystemPropertyCerberusCredentialsProvider(),
new InstanceProfileVaultCredentialsProvider(urlResolver, xCerberusClientOverride),
new InstanceProfileArnVaultCredentialsProvider(urlResolver, xCerberusClientOverride),
new InstanceRoleVaultCredentialsProvider(urlResolver, xCerberusClientOverride));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -107,6 +107,20 @@ public BaseAwsCredentialsProvider(UrlResolver urlResolver) {
LOGGER.info("Cerberus URL={}", urlResolver.resolve());
}

/**
* Constructor to setup credentials provider using the specified
* implementation of {@link UrlResolver}
*
* @param urlResolver Resolver for resolving the Cerberus URL
* @param xCerberusClientOverride - Overrides the default header value for the 'X-Cerberus-Client' header
*/
public BaseAwsCredentialsProvider(UrlResolver urlResolver, String xCerberusClientOverride) {
super();
this.urlResolver = urlResolver;
cerberusJavaClientHeaderValue = xCerberusClientOverride;
LOGGER.info("Cerberus URL={}", urlResolver.resolve());
}

/**
* Returns the Vault credentials. If none have been acquired yet or has
* expired, triggers a refresh.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client.auth.aws;

import com.amazonaws.regions.Region;
Expand All @@ -22,6 +38,17 @@ public InstanceProfileArnVaultCredentialsProvider(UrlResolver urlResolver) {
super(urlResolver);
}

/**
* Constructor to setup credentials provider using the specified
* implementation of {@link UrlResolver}
*
* @param urlResolver Resolver for resolving the Cerberus URL
* @param xCerberusClientOverride - Overrides the default header value for the 'X-Cerberus-Client' header
*/
public InstanceProfileArnVaultCredentialsProvider(UrlResolver urlResolver, String xCerberusClientOverride) {
super(urlResolver, xCerberusClientOverride);
}

@Override
protected void authenticate() {
EC2MetadataUtils.IAMInfo iamInfo = getIamInfo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client.auth.aws;

import com.amazonaws.regions.Region;
Expand Down Expand Up @@ -25,6 +41,17 @@ public InstanceProfileVaultCredentialsProvider(UrlResolver urlResolver) {
super(urlResolver);
}

/**
* Constructor to setup credentials provider using the specified
* implementation of {@link UrlResolver}
*
* @param urlResolver Resolver for resolving the Cerberus URL
* @param xCerberusClientOverride - Overrides the default header value for the 'X-Cerberus-Client' header
*/
public InstanceProfileVaultCredentialsProvider(UrlResolver urlResolver, String xCerberusClientOverride) {
super(urlResolver, xCerberusClientOverride);
}

@Override
protected void authenticate() {
EC2MetadataUtils.IAMInfo iamInfo = getIamInfo();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,6 +54,17 @@ public InstanceRoleVaultCredentialsProvider(UrlResolver urlResolver) {
super(urlResolver);
}

/**
* Constructor to setup credentials provider using the specified
* implementation of {@link UrlResolver}
*
* @param urlResolver Resolver for resolving the Cerberus URL
* @param xCerberusClientOverride - Overrides the default header value for the 'X-Cerberus-Client' header
*/
public InstanceRoleVaultCredentialsProvider(UrlResolver urlResolver, String xCerberusClientOverride) {
super(urlResolver, xCerberusClientOverride);
}

/**
* Looks up the IAM roles assigned to the instance via the EC2 metadata
* service. For each role assigned, an attempt is made to authenticate and
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Nike, Inc.
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client.auth.aws;

import com.amazonaws.regions.Region;
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/cerberus-java-client.properties
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
#
# Copyright (c) 2017 Nike, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

cerberus_java_client.version = @@JAVA_CLIENT_RELEASE@@
16 changes: 16 additions & 0 deletions src/test/java/com/nike/cerberus/client/ClientVersionTest.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client;

import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright (c) 2017 Nike, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nike.cerberus.client;

import com.nike.vault.client.VaultClient;
Expand Down
Loading

0 comments on commit df0dd82

Please sign in to comment.