Package com.ibm.cloud.sdk.core.security
Class MCSPV2Authenticator
- java.lang.Object
-
- com.ibm.cloud.sdk.core.security.AuthenticatorBase
-
- com.ibm.cloud.sdk.core.security.TokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPV2TokenResponse>
-
- com.ibm.cloud.sdk.core.security.MCSPV2Authenticator
-
- All Implemented Interfaces:
Authenticator
public class MCSPV2Authenticator extends TokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPV2TokenResponse> implements Authenticator
This class provides an Authenticator implementation for the Multi-Cloud Saas Platform (MCSP) v2 environment. This authenticator invokes the MCSP v2 token-exchange operation (POST /api/2.0/{scopeCollectionType}/{scopeId}/apikeys/token) to obtain an access token for an apikey, and adds the access token to requests via an Authorization header of the form: "Authorization: Bearer <access-token>" When the access token expires, a new access token will be fetched.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMCSPV2Authenticator.BuilderThis Builder class is used to construct MCSPV2Authenticator 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_BOOL, 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_MCSPV2, AUTHTYPE_NOAUTH, AUTHTYPE_VPC, PROPNAME_APIKEY, PROPNAME_AUTH_TYPE, PROPNAME_BEARER_TOKEN, PROPNAME_CALLER_EXT_CLAIM, 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_INCLUDE_BUILTIN_ACTIONS, PROPNAME_INCLUDE_CUSTOM_ACTIONS, PROPNAME_INCLUDE_ROLES, PROPNAME_PASSWORD, PROPNAME_PERMISSIONS, PROPNAME_PREFIX_ROLES, PROPNAME_SCOPE, PROPNAME_SCOPE_COLLECTION_TYPE, PROPNAME_SCOPE_ID, 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 MCSPV2AuthenticatorfromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Construct an MCSPV2Authenticator instance using properties retrieved from "config".java.lang.StringgetApiKey()java.util.Map<java.lang.String,java.lang.String>getCallerExtClaim()java.lang.StringgetScopeCollectionType()java.lang.StringgetScopeId()java.lang.StringgetURL()booleanincludeBuiltinActions()booleanincludeCustomActions()booleanincludeRoles()MCSPV2Authenticator.BuildernewBuilder()Returns a new Builder instance pre-loaded with the configuration from "this".booleanprefixRoles()MCSPTokenrequestToken()Fetches an access token for the current authenticator configuration.voidvalidate()Validates the configuration.-
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 MCSPV2Authenticator.Builder newBuilder()
Returns a new Builder instance pre-loaded with the configuration from "this".- Returns:
- the Builder instance
-
fromConfiguration
public static MCSPV2Authenticator fromConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Construct an MCSPV2Authenticator instance using properties retrieved from "config".- Parameters:
config- a Map containing the configuration properties- Returns:
- the MCSPV2Authenticator instance
-
validate
public void validate()
Validates the configuration.- Specified by:
validatein interfaceAuthenticator- Specified by:
validatein classTokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPV2TokenResponse>
-
authenticationType
public java.lang.String authenticationType()
Description copied from class:TokenRequestBasedAuthenticatorImmutableReturns the authentication type associated with this Authenticator. Each concrete subclass must implement this method.- Specified by:
authenticationTypein interfaceAuthenticator- Specified by:
authenticationTypein classTokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPV2TokenResponse>- Returns:
- the authentication type
-
getApiKey
public java.lang.String getApiKey()
- Returns:
- the apikey property configured on this Authenticator.
-
getURL
public java.lang.String getURL()
- Returns:
- the url property configured on this Authenticator.
-
getScopeCollectionType
public java.lang.String getScopeCollectionType()
- Returns:
- the scopeCollectionType property configured on this Authenticator.
-
getScopeId
public java.lang.String getScopeId()
- Returns:
- the scopeId property configured on this Authenticator.
-
includeBuiltinActions
public boolean includeBuiltinActions()
- Returns:
- the includeBuiltinActions property configured on this Authenticator.
-
includeCustomActions
public boolean includeCustomActions()
- Returns:
- the includeCustomActions property configured on this Authenticator.
-
includeRoles
public boolean includeRoles()
- Returns:
- the includeRoles property configured on this Authenticator.
-
prefixRoles
public boolean prefixRoles()
- Returns:
- the prefixRoles property configured on this Authenticator.
-
getCallerExtClaim
public java.util.Map<java.lang.String,java.lang.String> getCallerExtClaim()
- Returns:
- the callerExtClaim property configured on this Authenticator.
-
requestToken
public MCSPToken requestToken()
Fetches an access token for the current authenticator configuration.- Specified by:
requestTokenin classTokenRequestBasedAuthenticatorImmutable<MCSPToken,MCSPV2TokenResponse>- Returns:
- an MCSPToken instance that contains the access token
-
-