// 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.Security.Claims; using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Authentication { /// /// Base context for remote authentication. /// public abstract class RemoteAuthenticationContext : HandleRequestContext where TOptions : AuthenticationSchemeOptions { /// /// Constructor. /// /// The context. /// The authentication scheme. /// The authentication options associated with the scheme. /// The authentication properties. protected RemoteAuthenticationContext( HttpContext context, AuthenticationScheme scheme, TOptions options, AuthenticationProperties properties) : base(context, scheme, options) => Properties = properties ?? new AuthenticationProperties(); /// /// Gets the containing the user claims. /// public ClaimsPrincipal Principal { get; set; } /// /// Gets or sets the . /// public virtual AuthenticationProperties Properties { get; set; } /// /// Calls success creating a ticket with the and . /// public void Success() => Result = HandleRequestResult.Success(new AuthenticationTicket(Principal, Properties, Scheme.Name)); public void Fail(Exception failure) => Result = HandleRequestResult.Fail(failure); public void Fail(string failureMessage) => Result = HandleRequestResult.Fail(failureMessage); } }