Module org.elasticsearch.xcore
Class ApiKeyCredentials
java.lang.Object
org.elasticsearch.xpack.core.security.action.apikey.ApiKeyCredentials
- All Implemented Interfaces:
Closeable,AutoCloseable,AuthenticationToken
Credentials for API key authentication. Holds the decoded id and secret from the
encoded API key string (Base64(id + ":" + secret)).
-
Constructor Summary
ConstructorsConstructorDescriptionApiKeyCredentials(String id, SecureString key, ApiKey.Type expectedType) ApiKeyCredentials(String id, SecureString key, ApiKey.Type expectedType, String certificateIdentity) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidclose()The identity (Subject DistinguishedName) of the X.509 certificate that was provided by the client alongside the API during authenticate.getId()getKey()static ApiKeyCredentialsparse(SecureString apiKeyString, String certificateIdentity, ApiKey.Type expectedType) Parses the encoded API key credential (Base64(id + ":" + secret)) into anApiKeyCredentialsinstance.
-
Constructor Details
-
ApiKeyCredentials
-
ApiKeyCredentials
public ApiKeyCredentials(String id, SecureString key, ApiKey.Type expectedType, @Nullable String certificateIdentity)
-
-
Method Details
-
parse
public static ApiKeyCredentials parse(SecureString apiKeyString, @Nullable String certificateIdentity, ApiKey.Type expectedType) Parses the encoded API key credential (Base64(id + ":" + secret)) into anApiKeyCredentialsinstance.- Parameters:
apiKeyString- the encoded API key string, or nullcertificateIdentity- optional certificate identity for cross-cluster API keysexpectedType- the expected API key type (validates secret length for cross-cluster keys)- Returns:
- the parsed credentials, or null if apiKeyString is null
- Throws:
IllegalArgumentException- if the value is invalid
-
getId
-
getKey
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
principal
- Specified by:
principalin interfaceAuthenticationToken
-
credentials
- Specified by:
credentialsin interfaceAuthenticationToken
-
clearCredentials
public void clearCredentials()- Specified by:
clearCredentialsin interfaceAuthenticationToken
-
getExpectedType
-
getCertificateIdentity
The identity (Subject DistinguishedName) of the X.509 certificate that was provided by the client alongside the API during authenticate. At the time of writing, the only place where this is used is for cross cluster request signing
-