-
Notifications
You must be signed in to change notification settings - Fork 916
Add new Identity interfaces #3773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7a8f551
Add new Identity interfaces
gosar 04fd713
Move Impl classes to own files
gosar b2a44e8
Add missing @Immutable
gosar 444848d
Address feedback - interface override and javadoc edits
gosar f03400a
Mark the new interfaces @ThreadSafe
gosar acbd8bf
Remove static create methods in AwsCredentialsIdentity and impls
gosar c6f4a58
Add japicmp excludes for methods moved to parent interface
gosar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...dentity-spi/src/main/java/software/amazon/awssdk/identity/spi/AwsCredentialsIdentity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.identity.spi; | ||
|
||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
|
||
/** | ||
* Provides access to the AWS credentials used for accessing services: AWS access key ID and secret access key. These | ||
* credentials are used to securely sign requests to services (e.g., AWS services) that use them for authentication. | ||
* | ||
* <p>For more details on AWS access keys, see: | ||
* <a href="https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys"> | ||
* https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys</a></p> | ||
*/ | ||
@SdkPublicApi | ||
@ThreadSafe | ||
public interface AwsCredentialsIdentity extends Identity { | ||
|
||
/** | ||
* Retrieve the AWS access key, used to identify the user interacting with services. | ||
*/ | ||
String accessKeyId(); | ||
|
||
/** | ||
* Retrieve the AWS secret access key, used to authenticate the user interacting with services. | ||
*/ | ||
String secretAccessKey(); | ||
} |
35 changes: 35 additions & 0 deletions
35
...-spi/src/main/java/software/amazon/awssdk/identity/spi/AwsSessionCredentialsIdentity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.identity.spi; | ||
|
||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
|
||
/** | ||
* A special type of {@link AwsCredentialsIdentity} that provides a session token to be used in service authentication. Session | ||
* tokens are typically provided by a token broker service, like AWS Security Token Service, and provide temporary access to an | ||
* AWS service. | ||
*/ | ||
@SdkPublicApi | ||
@ThreadSafe | ||
public interface AwsSessionCredentialsIdentity extends AwsCredentialsIdentity { | ||
|
||
/** | ||
* Retrieve the AWS session token. This token is retrieved from an AWS token service, and is used for authenticating that this | ||
* user has received temporary permission to access some resource. | ||
*/ | ||
String sessionToken(); | ||
} |
41 changes: 41 additions & 0 deletions
41
core/identity-spi/src/main/java/software/amazon/awssdk/identity/spi/Identity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.identity.spi; | ||
|
||
import java.time.Instant; | ||
import java.util.Optional; | ||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
|
||
/** | ||
* Interface to represent <b>who</b> is using the SDK, i.e., the identity of the caller, used for authentication. | ||
* | ||
* <p>Examples include {@link AwsCredentialsIdentity} and {@link TokenIdentity}.</p> | ||
* | ||
* @see IdentityProvider | ||
*/ | ||
@SdkPublicApi | ||
@ThreadSafe | ||
public interface Identity { | ||
/** | ||
* The time after which this identity will no longer be valid. If this is empty, | ||
* an expiration time is not known (but the identity may still expire at some | ||
* time in the future). | ||
*/ | ||
default Optional<Instant> expirationTime() { | ||
return Optional.empty(); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
core/identity-spi/src/main/java/software/amazon/awssdk/identity/spi/IdentityProperty.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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 software.amazon.awssdk.identity.spi; | ||
|
||
import java.util.Objects; | ||
import software.amazon.awssdk.annotations.Immutable; | ||
import software.amazon.awssdk.annotations.SdkProtectedApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
import software.amazon.awssdk.utils.ToString; | ||
import software.amazon.awssdk.utils.Validate; | ||
|
||
/** | ||
* A strongly-typed property for input to an {@link IdentityProvider}. | ||
* @param <T> The type of the attribute. | ||
*/ | ||
@SdkProtectedApi | ||
@Immutable | ||
@ThreadSafe | ||
public final class IdentityProperty<T> { | ||
private final Class<T> clazz; | ||
private final String name; | ||
|
||
private IdentityProperty(Class<T> clazz, String name) { | ||
Validate.paramNotNull(clazz, "clazz"); | ||
Validate.paramNotBlank(name, "name"); | ||
|
||
this.clazz = clazz; | ||
this.name = name; | ||
} | ||
|
||
public static <T> IdentityProperty<T> create(Class<T> clazz, String name) { | ||
return new IdentityProperty<>(clazz, name); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToString.builder("IdentityProperty") | ||
.add("clazz", clazz) | ||
.add("name", name) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
|
||
IdentityProperty<?> that = (IdentityProperty<?>) o; | ||
|
||
return Objects.equals(clazz, that.clazz) && | ||
Objects.equals(name, that.name); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hashCode = 1; | ||
hashCode = 31 * hashCode + Objects.hashCode(clazz); | ||
hashCode = 31 * hashCode + Objects.hashCode(name); | ||
return hashCode; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.