Class MarshalledCredentialBinding

java.lang.Object
org.apache.hadoop.fs.s3a.auth.MarshalledCredentialBinding

public final class MarshalledCredentialBinding extends Object
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 Details

    • NO_AWS_CREDENTIALS

      @VisibleForTesting public static final String 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

      public static MarshalledCredentials fromEnvironment(Map<String,String> env)
      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 URI
      conf - 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 credentials
      typeRequired - type of credentials required
      component - component name for exception messages.
      Returns:
      a new set of credentials
      Throws:
      NoAuthWithAWSException - validation failure
      NoAwsCredentialsException - 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 STS
      configuration - AWS client configuration
      stsEndpoint - an endpoint, use "" for none
      stsRegion - 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