/// <summary>
        /// Sets a property in the server transaction using the specified name and value.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="transaction">The server transaction.</param>
        /// <param name="name">The property name.</param>
        /// <param name="value">The property value.</param>
        /// <returns>The server transaction, so that calls can be easily chained.</returns>
        public static OpenIddictServerTransaction SetProperty <TProperty>(
            [NotNull] this OpenIddictServerTransaction transaction,
            [NotNull] string name, [CanBeNull] TProperty value) where TProperty : class
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The property name cannot be null or empty.", nameof(name));
            }

            if (value == null)
            {
                transaction.Properties.Remove(name);
            }

            else
            {
                transaction.Properties[name] = value;
            }

            return(transaction);
        }
Esempio n. 2
0
        /// <summary>
        /// Sets a property in the server transaction using the specified name and value.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="transaction">The server transaction.</param>
        /// <param name="name">The property name.</param>
        /// <param name="value">The property value.</param>
        /// <returns>The server transaction, so that calls can be easily chained.</returns>
        public static OpenIddictServerTransaction SetProperty <TProperty>(
            this OpenIddictServerTransaction transaction,
            string name, TProperty?value) where TProperty : class
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException(SR.GetResourceString(SR.ID1105), nameof(name));
            }

            if (value == null)
            {
                transaction.Properties.Remove(name);
            }

            else
            {
                transaction.Properties[name] = value;
            }

            return(transaction);
        }
        /// <summary>
        /// Retrieves a property value from the server transaction using the specified name.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="transaction">The server transaction.</param>
        /// <param name="name">The property name.</param>
        /// <returns>The property value or <c>null</c> if it couldn't be found.</returns>
        public static TProperty GetProperty <TProperty>(
            [NotNull] this OpenIddictServerTransaction transaction, [NotNull] string name) where TProperty : class
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("The property name cannot be null or empty.", nameof(name));
            }

            if (transaction.Properties.TryGetValue(name, out var property) && property is TProperty result)
            {
                return(result);
            }

            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Retrieves a property value from the server transaction using the specified name.
        /// </summary>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="transaction">The server transaction.</param>
        /// <param name="name">The property name.</param>
        /// <returns>The property value or <c>null</c> if it couldn't be found.</returns>
        public static TProperty?GetProperty <TProperty>(
            this OpenIddictServerTransaction transaction, string name) where TProperty : class
        {
            if (transaction == null)
            {
                throw new ArgumentNullException(nameof(transaction));
            }

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException(SR.GetResourceString(SR.ID1105), nameof(name));
            }

            if (transaction.Properties.TryGetValue(name, out var property) && property is TProperty result)
            {
                return(result);
            }

            return(null);
        }
Esempio n. 5
0
 /// <summary>
 /// Creates a new instance of the <see cref="ExtractRevocationRequestContext"/> class.
 /// </summary>
 public ExtractRevocationRequestContext(OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ExtractLogoutRequestContext"/> class.
 /// </summary>
 public ExtractLogoutRequestContext(OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ExtractAuthorizationRequestContext"/> class.
 /// </summary>
 public ExtractAuthorizationRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a new instance of the <see cref="HandleConfigurationRequestContext"/> class.
 /// </summary>
 public HandleConfigurationRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Creates a new instance of the <see cref="HandleCryptographyRequestContext"/> class.
 /// </summary>
 public HandleCryptographyRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="HandleIntrospectionRequestContext"/> class.
 /// </summary>
 public HandleIntrospectionRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 11
0
 /// <summary>
 /// Creates a new instance of the <see cref="DeserializeIdentityTokenContext"/> class.
 /// </summary>
 public DeserializeIdentityTokenContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
     => TokenUsage = TokenUsages.IdToken;
Esempio n. 12
0
 /// <summary>
 /// Creates a new instance of the <see cref="DeserializeAuthorizationCodeContext"/> class.
 /// </summary>
 public DeserializeAuthorizationCodeContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
     => TokenUsage = TokenUsages.AuthorizationCode;
Esempio n. 13
0
 /// <summary>
 /// Creates a new instance of the <see cref="SerializeAccessTokenContext"/> class.
 /// </summary>
 public SerializeAccessTokenContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
     => TokenUsage = TokenUsages.AccessToken;
 /// <summary>
 /// Creates a new instance of the <see cref="ValidateUserinfoRequestContext"/> class.
 /// </summary>
 public ValidateUserinfoRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 15
0
 /// <summary>
 /// Creates a new instance of the <see cref="ExtractUserinfoRequestContext"/> class.
 /// </summary>
 public ExtractUserinfoRequestContext(OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="BaseContext"/> class.
 /// </summary>
 protected BaseContext([NotNull] OpenIddictServerTransaction transaction)
 => Transaction = transaction ?? throw new ArgumentNullException(nameof(transaction));
 /// <summary>
 /// Creates a new instance of the <see cref="ApplyIntrospectionResponseContext"/> class.
 /// </summary>
 public ApplyIntrospectionResponseContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Creates a new instance of the <see cref="DeserializeRefreshTokenContext"/> class.
 /// </summary>
 public DeserializeRefreshTokenContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
     => TokenUsage = TokenUsages.RefreshToken;
Esempio n. 19
0
 /// <summary>
 /// Creates a new instance of the <see cref="BaseSerializingContext"/> class.
 /// </summary>
 public BaseSerializingContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="HandleDeviceRequestContext"/> class.
 /// </summary>
 public HandleDeviceRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 21
0
 /// <summary>
 /// Creates a new instance of the <see cref="ApplyConfigurationResponseContext"/> class.
 /// </summary>
 public ApplyConfigurationResponseContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ApplyDeviceResponseContext"/> class.
 /// </summary>
 public ApplyDeviceResponseContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
Esempio n. 23
0
 /// <summary>
 /// Creates a new instance of the <see cref="ApplyCryptographyResponseContext"/> class.
 /// </summary>
 public ApplyCryptographyResponseContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ExtractVerificationRequestContext"/> class.
 /// </summary>
 public ExtractVerificationRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ApplyAuthorizationResponseContext"/> class.
 /// </summary>
 public ApplyAuthorizationResponseContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ValidateTokenRequestContext"/> class.
 /// </summary>
 public ValidateTokenRequestContext(OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ValidateAuthorizationRequestContext"/> class.
 /// </summary>
 public ValidateAuthorizationRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
     // Infer the redirect_uri from the value specified by the client application.
     => RedirectUri = Request?.RedirectUri;
Esempio n. 28
0
 /// <summary>
 /// Creates a new instance of the <see cref="ValidateRevocationRequestContext"/> class.
 /// </summary>
 public ValidateRevocationRequestContext([NotNull] OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }
 /// <summary>
 /// Creates a new instance of the <see cref="ValidateLogoutRequestContext"/> class.
 /// </summary>
 public ValidateLogoutRequestContext(OpenIddictServerTransaction transaction)
     : base(transaction)
     // Infer the post_logout_redirect_uri from the value specified by the client application.
     => PostLogoutRedirectUri = Request?.PostLogoutRedirectUri;
 /// <summary>
 /// Creates a new instance of the <see cref="ExtractDeviceRequestContext"/> class.
 /// </summary>
 public ExtractDeviceRequestContext(OpenIddictServerTransaction transaction)
     : base(transaction)
 {
 }