Package com.ibm.cloud.sdk.core.security
Class MCSPAuthenticator
- java.lang.Object
-
- com.ibm.cloud.sdk.core.security.AuthenticatorBase
-
- com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticatorImmutable<T,R>
-
- com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator<MCSPToken,MCSPTokenResponse>
-
- com.ibm.cloud.sdk.core.security.MCSPAuthenticator
-
- All Implemented Interfaces:
Authenticator
public class MCSPAuthenticator extends TokenRequestBasedAuthenticator<MCSPToken,MCSPTokenResponse> implements Authenticator
This class provides an Authenticator implementation for the Multi-Cloud Saas Platform (MCSP) environment. This authenticator will use the url and apikey values to automatically fetch an access token from the MCSP token service via the "POST /siusermgr/api/1.0/apikeys/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 class
MCSPAuthenticator.Builder
This Builder class is used to construct MCSPAuthenticator instances.
-
Field Summary
-
Fields inherited from class com.ibm.cloud.sdk.core.security.AuthenticatorBase
ERRORMSG_ACCOUNTID_PROP_ERROR, 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_IAM_ASSUME, AUTHTYPE_MCSP, 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_ACCOUNT_ID, 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.String
authenticationType()
Returns the authentication type associated with this Authenticator.static MCSPAuthenticator
fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct an MCSPAuthenticator instance using properties retrieved from "config".java.lang.String
getApiKey()
java.lang.String
getURL()
MCSPAuthenticator.Builder
newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".MCSPToken
requestToken()
Fetches an access token for the apikey using the configured URL.void
validate()
Validates the configuration.-
Methods inherited from class com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticator
setClient, setDisableSSLVerification, setHeaders, setProxy, setProxyAuthenticator
-
Methods inherited from class com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticatorImmutable
authenticate, getClient, getDisableSSLVerification, getHeaders, getProxy, getProxyAuthenticator, getToken
-
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 MCSPAuthenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the Builder instance
-
fromConfiguration
public static MCSPAuthenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct an MCSPAuthenticator instance using properties retrieved from "config".- Parameters:
config
- a Map containing the configuration properties- Returns:
- the MCSPAuthenticator instance
-
validate
public void validate()
Validates the configuration.- Specified by:
validate
in interfaceAuthenticator
- Specified by:
validate
in classTokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPTokenResponse>
-
authenticationType
public java.lang.String authenticationType()
Description copied from class:TokenRequestBasedAuthenticatorImmutable
Returns the authentication type associated with this Authenticator. Each concrete subclass must implement this method.- Specified by:
authenticationType
in interfaceAuthenticator
- Specified by:
authenticationType
in classTokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPTokenResponse>
- Returns:
- the authentication type
-
getApiKey
public java.lang.String getApiKey()
- Returns:
- the apikey configured on this Authenticator.
-
getURL
public java.lang.String getURL()
- Returns:
- the url configured on this Authenticator.
-
requestToken
public MCSPToken requestToken()
Fetches an access token for the apikey using the configured URL.- Specified by:
requestToken
in classTokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPTokenResponse>
- Returns:
- an MCSPToken instance that contains the access token
-
-