Package com.ibm.cloud.sdk.core.security
Class ContainerAuthenticator
- java.lang.Object
-
- com.ibm.cloud.sdk.core.security.AuthenticatorBase
-
- com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator<IamToken,IamToken>
-
- com.ibm.cloud.sdk.core.security.IamRequestBasedAuthenticator
-
- com.ibm.cloud.sdk.core.security.ContainerAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class ContainerAuthenticator extends IamRequestBasedAuthenticator implements Authenticator
ContainerAuthenticator implements an IAM-based authentication scheme whereby it retrieves a "compute resource token" from the local compute resource (VM) and uses that to obtain an IAM access token by invoking the IAM "get token" operation with grant-type=cr-token. The resulting IAM access token is then added to outbound requests in an Authorization header of the form: Authorization: Bearer <access-token>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classContainerAuthenticator.BuilderThis Builder class is used to construct ContainerAuthenticator instances.
-
Field Summary
-
Fields inherited from class com.ibm.cloud.sdk.core.security.AuthenticatorBase
ERRORMSG_ATLEAST_ONE_PROP_ERROR, ERRORMSG_ATMOST_ONE_PROP_ERROR, ERRORMSG_EXCLUSIVE_PROP_ERROR, ERRORMSG_PROP_INVALID, ERRORMSG_PROP_INVALID_INTEGER_VALUE, ERRORMSG_PROP_MISSING, ERRORMSG_REQ_FAILED
-
Fields inherited from interface com.ibm.cloud.sdk.core.security.Authenticator
AUTHTYPE_BASIC, AUTHTYPE_BEARER_TOKEN, AUTHTYPE_CONTAINER, AUTHTYPE_CP4D, AUTHTYPE_CP4D_SERVICE, AUTHTYPE_CP4D_SERVICE_INSTANCE, AUTHTYPE_IAM, AUTHTYPE_NOAUTH, AUTHTYPE_VPC, PROPNAME_APIKEY, PROPNAME_AUTH_TYPE, PROPNAME_BEARER_TOKEN, PROPNAME_CLIENT_ID, PROPNAME_CLIENT_SECRET, PROPNAME_CR_TOKEN_FILENAME, PROPNAME_DISABLE_SSL, PROPNAME_DISPLAY_NAME, PROPNAME_EXPIRATION_TIME, PROPNAME_IAM_PROFILE_CRN, PROPNAME_IAM_PROFILE_ID, PROPNAME_IAM_PROFILE_NAME, PROPNAME_PASSWORD, PROPNAME_PERMISSIONS, PROPNAME_SCOPE, PROPNAME_SERVICE_BROKER_SECRET, PROPNAME_SERVICE_INSTANCE_ID, PROPNAME_UID, PROPNAME_URL, PROPNAME_USERNAME
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringauthenticationType()Returns the authentication type associated with this Authenticator.static ContainerAuthenticatorfromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Constructs a ContainerAuthenticator instance using properties contained in the specified Map.java.lang.StringgetCrTokenFilename()java.lang.StringgetIamProfileId()java.lang.StringgetIamProfileName()ContainerAuthenticator.BuildernewBuilder()Returns a new Builder instance pre-loaded with the configuration from "this".IamTokenrequestToken()Fetches an IAM access token for the apikey using the configured URL.voidvalidate()Validates the configuration properties associated with the Authenticator.-
Methods inherited from class com.ibm.cloud.sdk.core.security.IamRequestBasedAuthenticator
getClientId, getClientSecret, getScope, getURL, setClientIdAndSecret, setScope, setURL
-
Methods inherited from class com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator
authenticate, getClient, getDisableSSLVerification, getHeaders, getProxy, getProxyAuthenticator, getToken, setClient, setDisableSSLVerification, setHeaders, setProxy, setProxyAuthenticator
-
Methods inherited from class com.ibm.cloud.sdk.core.security.AuthenticatorBase
constructBasicAuthHeader, constructBearerTokenAuthHeader
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ibm.cloud.sdk.core.security.Authenticator
authenticate
-
-
-
-
Method Detail
-
newBuilder
public ContainerAuthenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the Builder instance
-
fromConfiguration
public static ContainerAuthenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Constructs a ContainerAuthenticator instance using properties contained in the specified Map.- Parameters:
config- a map containing the configuration properties- Returns:
- the ContainerAuthenticator instance
-
validate
public void validate()
Description copied from class:TokenRequestBasedAuthenticatorValidates the configuration properties associated with the Authenticator. Each concrete subclass must implement this method.- Specified by:
validatein interfaceAuthenticator- Overrides:
validatein classIamRequestBasedAuthenticator
-
authenticationType
public java.lang.String authenticationType()
Description copied from class:TokenRequestBasedAuthenticatorReturns the authentication type associated with this Authenticator. Each concrete subclass must implement this method.- Specified by:
authenticationTypein interfaceAuthenticator- Specified by:
authenticationTypein classTokenRequestBasedAuthenticator<IamToken,IamToken>- Returns:
- the authentication type
-
getCrTokenFilename
public java.lang.String getCrTokenFilename()
- Returns:
- the crTokenFilename configured on this Authenticator.
-
getIamProfileName
public java.lang.String getIamProfileName()
- Returns:
- the iamProfileName configured on this Authenticator.
-
getIamProfileId
public java.lang.String getIamProfileId()
- Returns:
- the iamProfileId configured on this Authenticator.
-
requestToken
public IamToken requestToken()
Fetches an IAM access token for the apikey using the configured URL.- Specified by:
requestTokenin classTokenRequestBasedAuthenticator<IamToken,IamToken>- Returns:
- an IamToken instance that contains the access token
-
-