Package com.ibm.cloud.sdk.core.security
Class CloudPakForDataServiceInstanceAuthenticator
- java.lang.Object
-
- com.ibm.cloud.sdk.core.security.AuthenticatorBase
-
- com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator<Cp4dToken,Cp4dServiceInstanceTokenResponse>
-
- com.ibm.cloud.sdk.core.security.CloudPakForDataServiceInstanceAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class CloudPakForDataServiceInstanceAuthenticator extends TokenRequestBasedAuthenticator<Cp4dToken,Cp4dServiceInstanceTokenResponse> implements Authenticator
This class provides an Authenticator implementation for the "CloudPakForData" environment. This authenticator will use the configured url and other properties to automatically fetch a service instance access token from the CloudPakForData token service. When the access token expires, a new access token will be fetched. This authenticator uses the "GET /v3/service_instances/{service_instance_id}/token" operation supported by the CloudPakForData token service. The url, username, apikey, and serviceInstanceId properties are required.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCloudPakForDataServiceInstanceAuthenticator.BuilderThis Builder class is used to construct CloudPakForDataServiceInstanceAuthenticator 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 CloudPakForDataServiceInstanceAuthenticatorfromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Construct a CloudPakForDataServiceInstanceAuthenticator instance using properties retrieved from the specified Map.java.lang.StringgetApikey()java.lang.StringgetServiceInstanceId()java.lang.StringgetURL()java.lang.StringgetUsername()CloudPakForDataServiceInstanceAuthenticator.BuildernewBuilder()Returns a new Builder instance pre-loaded with the configuration from "this".Cp4dTokenrequestToken()Obtains a CP4D access token for the configured authenticator.voidvalidate()Validates the configuration of this authenticator.-
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 CloudPakForDataServiceInstanceAuthenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the builder
-
fromConfiguration
public static CloudPakForDataServiceInstanceAuthenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct a CloudPakForDataServiceInstanceAuthenticator instance using properties retrieved from the specified Map.- Parameters:
config- a map containing the configuration properties- Returns:
- the CloudPakForDataServiceInstanceAuthenticator instance
-
authenticationType
public java.lang.String authenticationType()
Returns the authentication type associated with this Authenticator.- Specified by:
authenticationTypein interfaceAuthenticator- Specified by:
authenticationTypein classTokenRequestBasedAuthenticator<Cp4dToken,Cp4dServiceInstanceTokenResponse>- Returns:
- the authentication type
-
validate
public void validate()
Validates the configuration of this authenticator.- Specified by:
validatein interfaceAuthenticator- Specified by:
validatein classTokenRequestBasedAuthenticator<Cp4dToken,Cp4dServiceInstanceTokenResponse>
-
getURL
public java.lang.String getURL()
- Returns:
- the URL configured for this authenticator
-
getUsername
public java.lang.String getUsername()
- Returns:
- the username configured for this authenticator
-
getApikey
public java.lang.String getApikey()
- Returns:
- the apikey configured for this authenticator
-
getServiceInstanceId
public java.lang.String getServiceInstanceId()
- Returns:
- the service instance id configured for this authenticator
-
requestToken
public Cp4dToken requestToken()
Obtains a CP4D access token for the configured authenticator.- Specified by:
requestTokenin classTokenRequestBasedAuthenticator<Cp4dToken,Cp4dServiceInstanceTokenResponse>- Returns:
- a Cp4dToken instance that contains the access token
-
-