Class: IBMCloudSdkCore::ConfigBasedAuthenticatorFactory
- Inherits:
-
Authenticator
- Object
- Authenticator
- IBMCloudSdkCore::ConfigBasedAuthenticatorFactory
- Defined in:
- lib/ibm_cloud_sdk_core/authenticators/config_based_authenticator_factory.rb
Overview
Authenticator
Constant Summary
Constants inherited from Authenticator
Authenticator::AUTH_TYPE_BASIC, Authenticator::AUTH_TYPE_BEARER_TOKEN, Authenticator::AUTH_TYPE_CP4D, Authenticator::AUTH_TYPE_IAM, Authenticator::AUTH_TYPE_NO_AUTH
Instance Method Summary collapse
- #construct_authenticator(config) ⇒ Object
-
#get_authenticator(service_name:) ⇒ Object
Checks the credentials file and VCAP_SERVICES environment variable :param service_name: The service name :return: the authenticator.
Methods inherited from Authenticator
Instance Method Details
#construct_authenticator(config) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ibm_cloud_sdk_core/authenticators/config_based_authenticator_factory.rb', line 23 def construct_authenticator(config) if config[:auth_type].nil? auth_type = "iam" else auth_type = config[:auth_type] end config.delete(:url) unless config[:url].nil? config[:url] = config[:auth_url] unless config[:auth_url].nil? return BasicAuthenticator.new(config) if auth_type.casecmp(AUTH_TYPE_BASIC).zero? return BearerTokenAuthenticator.new(config) if auth_type.casecmp(AUTH_TYPE_BEARER_TOKEN).zero? return CloudPakForDataAuthenticator.new(config) if auth_type.casecmp(AUTH_TYPE_CP4D).zero? return IamAuthenticator.new(config) if auth_type.casecmp(AUTH_TYPE_IAM).zero? return NoAuthAuthenticator.new if auth_type.casecmp(AUTH_TYPE_NO_AUTH).zero? end |
#get_authenticator(service_name:) ⇒ Object
Checks the credentials file and VCAP_SERVICES environment variable :param service_name: The service name :return: the authenticator
18 19 20 21 |
# File 'lib/ibm_cloud_sdk_core/authenticators/config_based_authenticator_factory.rb', line 18 def get_authenticator(service_name:) config = get_service_properties(service_name) return construct_authenticator(config) unless config.nil? || config.empty? end |