コード例 #1
0
        /// <summary>
        /// Initializes a module and prepares it to handle requests.
        /// </summary>
        /// <param name="context">
        /// An <see cref="HttpApplication" /> that provides access to the methods,
        /// properties, and events common to all application objects within an ASP.NET application
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="context"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// <paramref name="context"/> does not implement <see cref="IJwtValidationParametersProvider"/>.
        /// </exception>
        public void Init(HttpApplication context)
        {
            context.AssertNotNull("context");

            var app = context as IJwtValidationParametersProvider;

            if (app == null)
            {
                throw new InvalidOperationException(InvariantStrings.InvalidHttpApplication);
            }

            this.tokenValidationParameters = app.TokenValidationParameters;

            context.AuthenticateRequest += this.Application_AuthenticateRequest;
        }