C# Class OpenStack.Security.Authentication.IdentityV2AuthenticationService

This class defines an authentication service based on the OpenStack Identity Service V2.
Inheritance: IAuthenticationService
Show file Open project: crowdy/OpenStack-ConoHa Class Usage Examples

Public Methods

Method Description
AuthenticateRequestAsync ( HttpRequestMessage requestMessage, CancellationToken cancellationToken ) : Task

The base implementation of this authentication client sets the X-Auth-Token HTTP header of requests to the TokenId value obtained by authenticating with the OpenStack Identity Service V2.

GetBaseAddressAsync ( string serviceType, string serviceName, string region, bool internalAddress, CancellationToken cancellationToken ) : Task

The base implementation calls AuthenticateAsync to authenticate with the OpenStack Identity Service V2 if necessary, followed by calling GetBaseAddressImpl to locate a service endpoint within the user's service catalog.

IdentityV2AuthenticationService ( IIdentityService identityService, AuthenticationRequest authenticationRequest ) : System

Initializes a new instance of the IdentityV2AuthenticationService class with the specified OpenStack Identity Service V2 client and prepared authentication request.

Protected Methods

Method Description
AuthenticateAsync ( CancellationToken cancellationToken ) : Task

Authenticates the credentials provided in AuthenticationRequest with the OpenStack Identity Service V2.

This method caches the authentication result, and returns the cached result of a previous authentication request when possible to avoid unnecessary calls to the Identity API. If a cached authentication result is available but has either expired or will expire soon (see ExpirationOverlap), the cached result is discarded and the credentials are re-authenticated with the Identity Service.

FilterBaseAddress ( Uri baseAddress ) : Uri

This method allows an authentication service to adjust the raw URI provided as a base address in the service catalog prior to its use in resolving HTTP API calls.

The default implementation ensures that if the base address is an absolute URI, then it includes a trailing / character (adding one if necessary). This adjusts for a common case where a trailing / is omitted from a non-empty Uri.AbsolutePath of a URI in the service catalog. In this case, the use of RFC 3986 §5.2 for resolving relative URIs would result in the unintentional omission of the final path segment in the base address from the final absolute URI for an HTTP API call.

GetBaseAddressImpl ( Access access, string serviceType, string serviceName, string region, bool internalAddress ) : Uri

This method provides the core implementation of GetBaseAddressAsync after the OpenStack.Services.Identity.V2.Access details are obtained from the Identity Service.

GetEffectiveRegion ( Access access, string region ) : string

Gets the effective region to use for locating services in the service catalog, for the specified OpenStack.Services.Identity.V2.Access information and preferred region.

The default implementation simply returns region. Specific vendors may extend this functionality to provide a default value or other region selections as appropriate for their users and service offerings.

Method Details

AuthenticateAsync() protected method

Authenticates the credentials provided in AuthenticationRequest with the OpenStack Identity Service V2.

This method caches the authentication result, and returns the cached result of a previous authentication request when possible to avoid unnecessary calls to the Identity API. If a cached authentication result is available but has either expired or will expire soon (see ExpirationOverlap), the cached result is discarded and the credentials are re-authenticated with the Identity Service.

/// If an error occurs during an HTTP request as part of authenticating with the Identity API. ///
protected AuthenticateAsync ( CancellationToken cancellationToken ) : Task
cancellationToken System.Threading.CancellationToken The that the task will observe.
return Task

AuthenticateRequestAsync() public method

The base implementation of this authentication client sets the X-Auth-Token HTTP header of requests to the TokenId value obtained by authenticating with the OpenStack Identity Service V2.

public AuthenticateRequestAsync ( HttpRequestMessage requestMessage, CancellationToken cancellationToken ) : Task
requestMessage System.Net.Http.HttpRequestMessage
cancellationToken System.Threading.CancellationToken
return Task

FilterBaseAddress() protected method

This method allows an authentication service to adjust the raw URI provided as a base address in the service catalog prior to its use in resolving HTTP API calls.

The default implementation ensures that if the base address is an absolute URI, then it includes a trailing / character (adding one if necessary). This adjusts for a common case where a trailing / is omitted from a non-empty Uri.AbsolutePath of a URI in the service catalog. In this case, the use of RFC 3986 §5.2 for resolving relative URIs would result in the unintentional omission of the final path segment in the base address from the final absolute URI for an HTTP API call.

/// If is . ///
protected FilterBaseAddress ( Uri baseAddress ) : Uri
baseAddress System.Uri The base address for a service as provided in the service catalog.
return System.Uri

GetBaseAddressAsync() public method

The base implementation calls AuthenticateAsync to authenticate with the OpenStack Identity Service V2 if necessary, followed by calling GetBaseAddressImpl to locate a service endpoint within the user's service catalog.

public GetBaseAddressAsync ( string serviceType, string serviceName, string region, bool internalAddress, CancellationToken cancellationToken ) : Task
serviceType string
serviceName string
region string
internalAddress bool
cancellationToken System.Threading.CancellationToken
return Task

GetBaseAddressImpl() protected method

This method provides the core implementation of GetBaseAddressAsync after the OpenStack.Services.Identity.V2.Access details are obtained from the Identity Service.
/// If is . /// -or- /// If is . /// If is empty.
protected GetBaseAddressImpl ( Access access, string serviceType, string serviceName, string region, bool internalAddress ) : Uri
access OpenStack.Services.Identity.V2.Access An object containing the details /// for the authenticated user.
serviceType string The service type to locate.
serviceName string The preferred name of the service.
region string The preferred region for the service. This method calls /// with this value to obtain the actual region to consider for this /// algorithm.
internalAddress bool /// to return a base address for accessing the service over a local network. /// -or- /// to return a base address for accessing the service over a public network (the /// Internet).
return System.Uri

GetEffectiveRegion() protected method

Gets the effective region to use for locating services in the service catalog, for the specified OpenStack.Services.Identity.V2.Access information and preferred region.
The default implementation simply returns region. Specific vendors may extend this functionality to provide a default value or other region selections as appropriate for their users and service offerings.
If is .
protected GetEffectiveRegion ( Access access, string region ) : string
access OpenStack.Services.Identity.V2.Access The object providing details for /// the authenticated user.
region string The preferred region, as specified in the call to /// .
return string

IdentityV2AuthenticationService() public method

Initializes a new instance of the IdentityV2AuthenticationService class with the specified OpenStack Identity Service V2 client and prepared authentication request.
/// If is . /// -or- /// If is . ///
public IdentityV2AuthenticationService ( IIdentityService identityService, AuthenticationRequest authenticationRequest ) : System
identityService IIdentityService The instance to use for authentication /// purposes.
authenticationRequest OpenStack.Services.Identity.V2.AuthenticationRequest The authentication request, which contains the credentials to use for /// authenticating with the OpenStack Identity Service V2.
return System