Package org.apache.hadoop.fs.s3a.auth
Class MarshalledCredentialBinding
java.lang.Object
org.apache.hadoop.fs.s3a.auth.MarshalledCredentialBinding
Class to bridge from the serializable/marshallabled
MarshalledCredentialBinding class to/from AWS classes.
This is to keep that class isolated and not dependent on aws-sdk JARs
to load.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError text on empty credentials: "No AWS credentials". -
Method Summary
Modifier and TypeMethodDescriptionstatic MarshalledCredentialsfromAWSCredentials(software.amazon.awssdk.auth.credentials.AwsSessionCredentials credentials) Create from a set of AWS credentials.static MarshalledCredentialsfromEnvironment(Map<String, String> env) Build a set of credentials from the environment.static MarshalledCredentialsfromFileSystem(URI uri, org.apache.hadoop.conf.Configuration conf) Loads the credentials from the owning S3A FS, including from Hadoop credential providers.static MarshalledCredentialsfromSTSCredentials(software.amazon.awssdk.services.sts.model.Credentials credentials) Create a set of marshalled credentials from a set of credentials issued by an STS call.static MarshalledCredentialsrequestSessionCredentials(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider parentCredentials, org.apache.hadoop.conf.Configuration configuration, String stsEndpoint, String stsRegion, int duration, Invoker invoker, String bucket) Request a set of credentials from an STS endpoint.static software.amazon.awssdk.auth.credentials.AwsCredentialstoAWSCredentials(MarshalledCredentials marshalled, MarshalledCredentials.CredentialTypeRequired typeRequired, String component) Create an AWS credential set from a set of marshalled credentials.
-
Field Details
-
NO_AWS_CREDENTIALS
Error text on empty credentials: "No AWS credentials".- See Also:
-
-
Method Details
-
fromSTSCredentials
public static MarshalledCredentials fromSTSCredentials(software.amazon.awssdk.services.sts.model.Credentials credentials) Create a set of marshalled credentials from a set of credentials issued by an STS call.- Parameters:
credentials- AWS-provided session credentials- Returns:
- a set of marshalled credentials.
-
fromAWSCredentials
public static MarshalledCredentials fromAWSCredentials(software.amazon.awssdk.auth.credentials.AwsSessionCredentials credentials) Create from a set of AWS credentials.- Parameters:
credentials- source credential.- Returns:
- a set of marshalled credentials.
-
fromEnvironment
Build a set of credentials from the environment.- Parameters:
env- environment.- Returns:
- a possibly incomplete/invalid set of credentials.
-
fromFileSystem
public static MarshalledCredentials fromFileSystem(URI uri, org.apache.hadoop.conf.Configuration conf) throws IOException Loads the credentials from the owning S3A FS, including from Hadoop credential providers. There is no validation.- Parameters:
uri- binding URIconf- configuration to load from- Returns:
- the component
- Throws:
IOException- on any load failure
-
toAWSCredentials
public static software.amazon.awssdk.auth.credentials.AwsCredentials toAWSCredentials(MarshalledCredentials marshalled, MarshalledCredentials.CredentialTypeRequired typeRequired, String component) throws NoAuthWithAWSException, NoAwsCredentialsException Create an AWS credential set from a set of marshalled credentials. This code would seem to fit into (@link MarshalledCredentials}, and while it would from a code-hygiene perspective, to keep all AWS SDK references out of that class, the logic is implemented here instead,- Parameters:
marshalled- marshalled credentialstypeRequired- type of credentials requiredcomponent- component name for exception messages.- Returns:
- a new set of credentials
- Throws:
NoAuthWithAWSException- validation failureNoAwsCredentialsException- the credentials are actually empty.
-
requestSessionCredentials
@RetryTranslated public static MarshalledCredentials requestSessionCredentials(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider parentCredentials, org.apache.hadoop.conf.Configuration configuration, String stsEndpoint, String stsRegion, int duration, Invoker invoker, String bucket) throws IOException Request a set of credentials from an STS endpoint.- Parameters:
parentCredentials- the parent credentials needed to talk to STSconfiguration- AWS client configurationstsEndpoint- an endpoint, use "" for nonestsRegion- region; use if the endpoint isn't the AWS default.duration- duration of the credentials in seconds. Minimum value: 900.invoker- invoker to use for retrying the call.bucket- bucket name.- Returns:
- the credentials
- Throws:
IOException- on a failure of the request
-