// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Diagnostics.CodeAnalysis; using Microsoft.AspNet.Http; using Microsoft.AspNet.Authentication.Notifications; namespace Microsoft.AspNet.Authentication.Cookies { /// /// Context object passed to the ICookieAuthenticationProvider method Exception. /// public class CookieExceptionContext : BaseContext { /// /// Creates a new instance of the context object. /// /// The HTTP request context /// The middleware options /// The location of the exception /// The exception thrown. /// The current ticket, if any. public CookieExceptionContext( HttpContext context, CookieAuthenticationOptions options, ExceptionLocation location, Exception exception, AuthenticationTicket ticket) : base(context, options) { Location = location; Exception = exception; Rethrow = true; Ticket = ticket; } /// /// The code paths where exceptions may be reported. /// [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope = "type", Target = "Microsoft.Owin.Security.Cookies.CookieExceptionContext+ExceptionLocation", Justification = "It is a directly related option.")] public enum ExceptionLocation { /// /// The exception was reported in the Authenticate code path. /// Authenticate, /// /// The exception was reported in the FinishResponse code path, during sign-in, sign-out, or refresh. /// FinishResponse, /// /// The exception was reported in the Unauthorized code path, during redirect generation. /// Unauthorized, /// /// The exception was reported in the Forbidden code path, during redirect generation. /// Forbidden, /// /// The exception was reported in the SignIn code path /// SignIn, /// /// The exception was reported in the SignOut code path /// SignOut, } /// /// The code path the exception occurred in. /// public ExceptionLocation Location { get; private set; } /// /// The exception thrown. /// public Exception Exception { get; private set; } /// /// True if the exception should be re-thrown (default), false if it should be suppressed. /// public bool Rethrow { get; set; } /// /// The current authentication ticket, if any. /// In the AuthenticateAsync code path, if the given exception is not re-thrown then this ticket /// will be returned to the application. The ticket may be replaced if needed. /// public AuthenticationTicket Ticket { get; set; } } }