// 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;
namespace Microsoft.AspNetCore.Authentication
{
///
/// Contains the result of an Authenticate call
///
public class HandleRequestResult : AuthenticateResult
{
///
/// Indicates that stage of authentication was directly handled by
/// user intervention and no further processing should be attempted.
///
public bool Handled { get; private set; }
///
/// Indicates that the default authentication logic should be
/// skipped and that the rest of the pipeline should be invoked.
///
public bool Skipped { get; private set; }
///
/// Indicates that authentication was successful.
///
/// The ticket representing the authentication result.
/// The result.
public static new HandleRequestResult Success(AuthenticationTicket ticket)
{
if (ticket == null)
{
throw new ArgumentNullException(nameof(ticket));
}
return new HandleRequestResult() { Ticket = ticket };
}
///
/// Indicates that there was a failure during authentication.
///
/// The failure exception.
/// The result.
public static new HandleRequestResult Fail(Exception failure)
{
return new HandleRequestResult() { Failure = failure };
}
///
/// Indicates that there was a failure during authentication.
///
/// The failure message.
/// The result.
public static new HandleRequestResult Fail(string failureMessage)
{
return new HandleRequestResult() { Failure = new Exception(failureMessage) };
}
///
/// Discontinue all processing for this request and return to the client.
/// The caller is responsible for generating the full response.
///
/// The result.
public static HandleRequestResult Handle()
{
return new HandleRequestResult() { Handled = true };
}
///
/// Discontinue processing the request in the current handler.
///
/// The result.
public static HandleRequestResult SkipHandler()
{
return new HandleRequestResult() { Skipped = true };
}
}
}