@InterfaceAudience.Private public final class MarshalledCredentials extends Object implements org.apache.hadoop.io.Writable, Serializable
Writable, so can be marshalled inside a
delegation token.
The class is designed so that keys inside are kept non-null; to be
unset just set them to the empty string. This is to simplify marshalling.
Important: Add no references to any AWS SDK class, to
ensure it can be safely deserialized whenever the relevant token
identifier of a token type declared in this JAR is examined.| Modifier and Type | Class and Description |
|---|---|
static class |
MarshalledCredentials.CredentialTypeRequired
Enumeration of credential types for use in validation methods.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
INVALID_CREDENTIALS
Error text on invalid non-empty credentials: "Invalid AWS credentials".
|
| Constructor and Description |
|---|
MarshalledCredentials()
Constructor.
|
MarshalledCredentials(String accessKey,
String secretKey,
String sessionToken)
Create from a set of properties.
|
| Modifier and Type | Method and Description |
|---|---|
String |
buildInvalidCredentialsError(MarshalledCredentials.CredentialTypeRequired typeRequired)
Build an error string for when the credentials do not match
those required.
|
static MarshalledCredentials |
empty()
Return a set of empty credentials.
|
boolean |
equals(Object o) |
String |
getAccessKey() |
long |
getExpiration()
Expiration; will be 0 for none known.
|
Optional<OffsetDateTime> |
getExpirationDateTime()
Get a temporal representing the time of expiration, if there
is one.
|
String |
getRoleARN() |
String |
getSecretKey() |
String |
getSessionToken() |
int |
hashCode() |
boolean |
hasSessionToken()
Does this set of credentials have a session token.
|
boolean |
isEmpty()
Is this empty: does it contain any credentials at all?
This test returns true if either the access key or secret key is empty.
|
boolean |
isValid(MarshalledCredentials.CredentialTypeRequired required)
Is this a valid set of credentials tokens?
|
void |
readFields(DataInput in)
Read in the fields.
|
void |
setAccessKey(String accessKey) |
void |
setExpiration(long expiration) |
void |
setRoleARN(String roleARN) |
void |
setSecretKey(String secretKey) |
void |
setSecretsInConfiguration(org.apache.hadoop.conf.Configuration config)
Patch a configuration with the secrets.
|
void |
setSessionToken(String sessionToken) |
String |
toString()
String value MUST NOT include any secrets.
|
void |
validate(String message,
MarshalledCredentials.CredentialTypeRequired typeRequired)
Verify that a set of credentials is valid.
|
void |
write(DataOutput out)
Write the token.
|
@VisibleForTesting public static final String INVALID_CREDENTIALS
public String getAccessKey()
public String getSecretKey()
public String getSessionToken()
public long getExpiration()
public void setExpiration(long expiration)
public Optional<OffsetDateTime> getExpirationDateTime()
public String getRoleARN()
public void setRoleARN(String roleARN)
public void setAccessKey(String accessKey)
public void setSecretKey(String secretKey)
public void setSessionToken(String sessionToken)
public String toString()
public boolean isEmpty()
public boolean isValid(MarshalledCredentials.CredentialTypeRequired required)
required - credential type required.public boolean hasSessionToken()
public void write(DataOutput out) throws IOException
write in interface org.apache.hadoop.io.Writableout - stream to serialize to.IOException - if the serialization failed.public void readFields(DataInput in) throws IOException
readFields in interface org.apache.hadoop.io.WritableIOException - IO problempublic void validate(String message, MarshalledCredentials.CredentialTypeRequired typeRequired) throws IOException
message - message to prefix errors;typeRequired - credential type required.DelegationTokenIOException - if they aren'tIOExceptionpublic String buildInvalidCredentialsError(MarshalledCredentials.CredentialTypeRequired typeRequired)
typeRequired - credential type required.public void setSecretsInConfiguration(org.apache.hadoop.conf.Configuration config)
config - configuration to patchpublic static MarshalledCredentials empty()
Copyright © 2008–2024 Apache Software Foundation. All rights reserved.