Package com.ibm.cloud.sdk.core.security
Class CloudPakForDataServiceAuthenticator
- 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.CloudPakForDataServiceAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class CloudPakForDataServiceAuthenticator 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 for service to service authentication from the CloudPakForData service token service. When the access token expires, a new access token will be fetched. This authenticator uses the "GET /v1/service_token" operation supported by the CloudPakForData service token service. As such, you can configure the username, displayName, uid, permissions and expirationTime properties. The url and serviceBrokerSecret properties are required, the rest are optional.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCloudPakForDataServiceAuthenticator.BuilderThis Builder class is used to construct CloudPakForDataServiceAuthenticator 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 CloudPakForDataServiceAuthenticatorfromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Construct a CloudPakForDataServiceAuthenticator instance using properties retrieved from the specified Map.java.lang.StringgetDisplayName()java.lang.StringgetExpirationTime()java.lang.StringgetPermissions()java.lang.StringgetServiceBrokerSecret()java.lang.StringgetUid()java.lang.StringgetURL()java.lang.StringgetUsername()CloudPakForDataServiceAuthenticator.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 CloudPakForDataServiceAuthenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the builder
-
fromConfiguration
public static CloudPakForDataServiceAuthenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct a CloudPakForDataServiceAuthenticator instance using properties retrieved from the specified Map.- Parameters:
config- a map containing the configuration properties- Returns:
- the CloudPakForDataServiceAuthenticator 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
-
getDisplayName
public java.lang.String getDisplayName()
- Returns:
- the displayName configured for this authenticator
-
getUid
public java.lang.String getUid()
- Returns:
- the uid configured for this authenticator
-
getPermissions
public java.lang.String getPermissions()
- Returns:
- the permissions configured for this authenticator
-
getExpirationTime
public java.lang.String getExpirationTime()
- Returns:
- the expirationTime configured for this authenticator
-
getServiceBrokerSecret
public java.lang.String getServiceBrokerSecret()
- Returns:
- the serviceBrokerSecret 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
-
-