Get Secured Protocol Connection of specified type, if CertificatePath info has been passed
# Number of lines of code in get_connection: 67
my ( $self, %args ) = @_;
my $protocolType = $args{'protocol_type'};
my $uri = $args{'uri'};
my $config = $args{'http_config'};
my $cert = $args{'certificate_path'};
if ( !$protocolType || !$uri ) {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.InvalidParameter',
args => ['protocol_type and uri']
);
throw InvalidParameter( $msg->str() );
}
if ( $protocolType eq
$Com::Vmware::Vapi::Protocol::ProtocolConstants::PROTOCOL_TYPE_HTTPS )
{
if ( !$cert ) {
$cert = undef;
}
my $httpBuilder =
my $sslConfig =
'trust_store' => $cert );
$httpBuilder->set_ssl_configuration( 'ssl_config_builder' => $sslConfig );
if (defined $config) {
$httpBuilder->set_so_timeout(
'so_timeout_builder' => $config->get_sso_timeout() );
$httpBuilder->set_io_thread_count(
'io_thread_count_builder' => $config->get_io_thread_count() );
$httpBuilder->set_library_type(
'library_type_builder' => $config->get_library_type() );
}
my $httpConfig = $httpBuilder->get_config();
return $self->get_http_connection(
'uri' => $uri,
'client_config' => undef,
'http_config' => $httpConfig,
);
}
elsif ( $protocolType eq
$Com::Vmware::Vapi::Protocol::ProtocolConstants::PROTOCOL_TYPE_HTTP )
{
return $self->get_insecure_connection(
protocol_type => $protocolType,
uri => $uri,
http_config => $config,
);
}
else {
my $message_factory =
Com::Vmware::Vapi::l10n::Runtime::get_runtime_message_factory();
my $msg = $message_factory->get_message(
id => 'Com.Vmware.Vapi.Protocol.ProtocolConnectionFactory.UnsupportedProtocolTypeException',
args => [ UnsupportedProtocolTypeException->description ]
);
throw UnsupportedProtocolTypeException( $msg->str() );
}
}