/// <summary>
        /// Gets the association to use for this authentication request.
        /// </summary>
        /// <returns>The association to use; <c>null</c> to use 'dumb mode'.</returns>
        private Association GetAssociation()
        {
            Association association = null;

            switch (this.associationPreference)
            {
            case AssociationPreference.IfPossible:
                association = this.RelyingParty.AssociationManager.GetOrCreateAssociation(this.endpoint.ProviderDescription);
                if (association == null)
                {
                    // Avoid trying to create the association again if the redirecting response
                    // is generated again.
                    this.associationPreference = AssociationPreference.IfAlreadyEstablished;
                }
                break;

            case AssociationPreference.IfAlreadyEstablished:
                association = this.RelyingParty.AssociationManager.GetExistingAssociation(this.endpoint.ProviderDescription);
                break;

            case AssociationPreference.Never:
                break;

            default:
                throw new InternalErrorException();
            }

            return(association);
        }
Exemple #2
0
        /// <summary>
        /// Gets the association to use for this authentication request.
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// The association to use; <c>null</c> to use 'dumb mode'.
        /// </returns>
        private async Task <Association> GetAssociationAsync(CancellationToken cancellationToken)
        {
            Association association = null;

            switch (this.associationPreference)
            {
            case AssociationPreference.IfPossible:
                association = await this.RelyingParty.AssociationManager.GetOrCreateAssociationAsync(this.DiscoveryResult, cancellationToken);

                if (association == null)
                {
                    // Avoid trying to create the association again if the redirecting response
                    // is generated again.
                    this.associationPreference = AssociationPreference.IfAlreadyEstablished;
                }
                break;

            case AssociationPreference.IfAlreadyEstablished:
                association = this.RelyingParty.AssociationManager.GetExistingAssociation(this.DiscoveryResult);
                break;

            case AssociationPreference.Never:
                break;

            default:
                throw new InternalErrorException();
            }

            return(association);
        }
		/// <summary>
		/// Gets the association to use for this authentication request.
		/// </summary>
		/// <returns>The association to use; <c>null</c> to use 'dumb mode'.</returns>
		private Association GetAssociation() {
			Association association = null;
			switch (this.associationPreference) {
				case AssociationPreference.IfPossible:
					association = this.RelyingParty.AssociationManager.GetOrCreateAssociation(this.DiscoveryResult);
					if (association == null) {
						// Avoid trying to create the association again if the redirecting response
						// is generated again.
						this.associationPreference = AssociationPreference.IfAlreadyEstablished;
					}
					break;
				case AssociationPreference.IfAlreadyEstablished:
					association = this.RelyingParty.AssociationManager.GetExistingAssociation(this.DiscoveryResult);
					break;
				case AssociationPreference.Never:
					break;
				default:
					throw new InternalErrorException();
			}

			return association;
		}