Package com.ibm.cloud.sdk.core.security
Class IamAuthenticator
- 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.IamAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class IamAuthenticator extends IamRequestBasedAuthenticator implements Authenticator
This class provides an Authenticator implementation for IAM (Identity and Access Management). This authenticator will use the url and apikey values to automatically fetch an access token from the IAM token service via the "POST /identity/token" operation. When the access token expires, a new access token will be fetched.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIamAuthenticator.BuilderThis Builder class is used to construct IamAuthenticator 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
-
-
Constructor Summary
Constructors Constructor Description IamAuthenticator(java.lang.String apikey)Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadIamAuthenticator(java.lang.String apikey, java.lang.String url, java.lang.String clientId, java.lang.String clientSecret, boolean disableSSLVerification, java.util.Map<java.lang.String,java.lang.String> headers)Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadIamAuthenticator(java.lang.String apikey, java.lang.String url, java.lang.String clientId, java.lang.String clientSecret, boolean disableSSLVerification, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String scope)Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadIamAuthenticator(java.util.Map<java.lang.String,java.lang.String> config)Deprecated.As of 9.7.0, use IamAuthenticator.Builder() instead
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.StringauthenticationType()Returns the authentication type associated with this Authenticator.static IamAuthenticatorfromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Construct a IamAuthenticator instance using properties retrieved from the specified Map.java.lang.StringgetApiKey()java.lang.StringgetPassword()Deprecated.As of 9.7.0, use getClientSecret() insteadjava.lang.StringgetUsername()Deprecated.As of 9.7.0, use getClientId() insteadIamAuthenticator.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.voidsetBasicAuthInfo(java.lang.String clientId, java.lang.String clientSecret)Deprecated.As of 9.7.0, use IamAuthenticator.setClientIdAndSecret() insteadvoidvalidate()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
-
-
-
-
Constructor Detail
-
IamAuthenticator
@Deprecated public IamAuthenticator(java.lang.String apikey)
Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadConstructs an IamAuthenticator with required properties.- Parameters:
apikey- the apikey to be used when retrieving the access token
-
IamAuthenticator
@Deprecated public IamAuthenticator(java.lang.String apikey, java.lang.String url, java.lang.String clientId, java.lang.String clientSecret, boolean disableSSLVerification, java.util.Map<java.lang.String,java.lang.String> headers)Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadConstructs an IamAuthenticator with all properties.- Parameters:
apikey- the apikey to be used when retrieving the access tokenurl- the base URL of the IAM token service (if null/empty, then "https://iam.cloud.ibm.com" is used)clientId- the clientId to be used in token server interactionsclientSecret- the clientSecret to be used in token server interactionsdisableSSLVerification- a flag indicating whether SSL hostname verification should be disabledheaders- a set of user-supplied headers to be included in token server interactions
-
IamAuthenticator
@Deprecated public IamAuthenticator(java.lang.String apikey, java.lang.String url, java.lang.String clientId, java.lang.String clientSecret, boolean disableSSLVerification, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String scope)Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadConstructs an IamAuthenticator with all properties.- Parameters:
apikey- the apikey to be used when retrieving the access tokenurl- the base URL of the IAM token service (if null/empty, then "https://iam.cloud.ibm.com" is used)clientId- the clientId to be used in token server interactionsclientSecret- the clientSecret to be used in token server interactionsdisableSSLVerification- a flag indicating whether SSL hostname verification should be disabledheaders- a set of user-supplied headers to be included in token server interactionsscope- the "scope" to use when fetching the bearer token from the IAM token server. This can be used to obtain an access token with a specific scope.
-
IamAuthenticator
@Deprecated public IamAuthenticator(java.util.Map<java.lang.String,java.lang.String> config)
Deprecated.As of 9.7.0, use IamAuthenticator.Builder() insteadConstruct an IamAuthenticator instance using properties retrieved from the specified Map.- Parameters:
config- a map containing the configuration properties
-
-
Method Detail
-
newBuilder
public IamAuthenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the Builder instance
-
fromConfiguration
public static IamAuthenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct a IamAuthenticator instance using properties retrieved from the specified Map.- Parameters:
config- a map containing the configuration properties- Returns:
- the IamAuthenticator 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
-
getApiKey
public java.lang.String getApiKey()
- Returns:
- the apikey configured on this Authenticator.
-
getUsername
public java.lang.String getUsername()
Deprecated.As of 9.7.0, use getClientId() instead- Returns:
- the basic auth username (clientId) configured for this Authenticator.
-
getPassword
public java.lang.String getPassword()
Deprecated.As of 9.7.0, use getClientSecret() instead- Returns:
- the basic auth password (clientSecret) configured for this Authenticator.
-
setBasicAuthInfo
@Deprecated public void setBasicAuthInfo(java.lang.String clientId, java.lang.String clientSecret)Deprecated.As of 9.7.0, use IamAuthenticator.setClientIdAndSecret() insteadSets the basic auth username and password values in this Authenticator. These values will be used to build a basic auth Authorization header that will be sent with each request to the token service.- Parameters:
clientId- the basic auth usernameclientSecret- the basic auth password
-
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
-
-