Package com.ibm.cloud.sdk.core.security
Class CloudPakForDataAuthenticator
- java.lang.Object
-
- com.ibm.cloud.sdk.core.security.AuthenticatorBase
-
- com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator<Cp4dToken,Cp4dTokenResponse>
-
- com.ibm.cloud.sdk.core.security.CloudPakForDataAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class CloudPakForDataAuthenticator extends TokenRequestBasedAuthenticator<Cp4dToken,Cp4dTokenResponse> 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 an access token from the CloudPakForData token service. When the access token expires, a new access token will be fetched. This authenticator uses the "POST /v1/authorize" operation supported by the CloudPakForData token service. As such, you can configure either the username and passord properies, or the username and apikey properties. The url, username and one of password/apikey are required.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCloudPakForDataAuthenticator.BuilderThis Builder class is used to construct CloudPakForDataAuthenticator 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 CloudPakForDataAuthenticator(java.lang.String url, java.lang.String username, java.lang.String password)Deprecated.As of 9.7.0, use CloudPakForDataAuthenticator.Builder() instead.CloudPakForDataAuthenticator(java.lang.String url, java.lang.String username, java.lang.String password, boolean disableSSLVerification, java.util.Map<java.lang.String,java.lang.String> headers)Deprecated.As of 9.7.0, use CloudPakForDataAuthenticator.Builder() instead.CloudPakForDataAuthenticator(java.util.Map<java.lang.String,java.lang.String> config)Deprecated.As of 9.7.0, use CloudPakForDataAuthenticator.fromConfiguration() instead.
-
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 CloudPakForDataAuthenticatorfromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Construct a CloudPakForDataAuthenticator instance using properties retrieved from the specified Map.java.lang.StringgetApikey()java.lang.StringgetPassword()java.lang.StringgetURL()java.lang.StringgetUsername()CloudPakForDataAuthenticator.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
-
-
-
-
Constructor Detail
-
CloudPakForDataAuthenticator
@Deprecated public CloudPakForDataAuthenticator(java.lang.String url, java.lang.String username, java.lang.String password)Deprecated.As of 9.7.0, use CloudPakForDataAuthenticator.Builder() instead.Constructs a CloudPakForDataAuthenticator with required properties configured with username/password.- Parameters:
url- the base URL associated with the token service. The path "/v1/authorize" will be appended to this value automatically.username- the username to be used when retrieving the access tokenpassword- the password to be used when retrieving the access token
-
CloudPakForDataAuthenticator
@Deprecated public CloudPakForDataAuthenticator(java.lang.String url, java.lang.String username, java.lang.String password, boolean disableSSLVerification, java.util.Map<java.lang.String,java.lang.String> headers)Deprecated.As of 9.7.0, use CloudPakForDataAuthenticator.Builder() instead.Constructs a CloudPakForDataAuthenticator with all properties configured with username/password.- Parameters:
url- the base URL associated with the token service. The path "/v1/authorize" will be appended to this value automatically.username- the username to be used when retrieving the access tokenpassword- the password to be used when retrieving the access tokendisableSSLVerification- a flag indicating whether SSL hostname verification should be disabledheaders- a set of user-supplied headers to be included in token service interactions
-
CloudPakForDataAuthenticator
@Deprecated public CloudPakForDataAuthenticator(java.util.Map<java.lang.String,java.lang.String> config)
Deprecated.As of 9.7.0, use CloudPakForDataAuthenticator.fromConfiguration() instead.Construct a CloudPakForDataAuthenticator instance using properties retrieved from the specified Map.- Parameters:
config- a map containing the configuration properties
-
-
Method Detail
-
newBuilder
public CloudPakForDataAuthenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the builder
-
fromConfiguration
public static CloudPakForDataAuthenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct a CloudPakForDataAuthenticator instance using properties retrieved from the specified Map.- Parameters:
config- a map containing the configuration properties- Returns:
- the CloudPakForDataAuthenticator instance
-
authenticationType
public java.lang.String authenticationType()
Returns the authentication type associated with this Authenticator.- Specified by:
authenticationTypein interfaceAuthenticator- Specified by:
authenticationTypein classTokenRequestBasedAuthenticator<Cp4dToken,Cp4dTokenResponse>- Returns:
- the authentication type
-
validate
public void validate()
Validates the configuration of this authenticator.- Specified by:
validatein interfaceAuthenticator- Specified by:
validatein classTokenRequestBasedAuthenticator<Cp4dToken,Cp4dTokenResponse>
-
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
-
getPassword
public java.lang.String getPassword()
- Returns:
- the password configured for this authenticator
-
getApikey
public java.lang.String getApikey()
- Returns:
- the apikey configured for this authenticator
-
requestToken
public Cp4dToken requestToken()
Obtains a CP4D access token for the configured authenticator.- Specified by:
requestTokenin classTokenRequestBasedAuthenticator<Cp4dToken,Cp4dTokenResponse>- Returns:
- a Cp4dToken instance that contains the access token
-
-