// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Security.Claims; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Security; namespace Microsoft.AspNet.Security.OAuth { /// /// Base class used for certain event contexts /// public abstract class BaseValidatingTicketContext : BaseValidatingContext { /// /// Initializes base class used for certain event contexts /// protected BaseValidatingTicketContext( HttpContext context, TOptions options, AuthenticationTicket ticket) : base(context, options) { Ticket = ticket; } /// /// Contains the identity and properties for the application to authenticate. If the Validated method /// is invoked with an AuthenticationTicket or ClaimsIdentity argument, that new value is assigned to /// this property in addition to changing IsValidated to true. /// public AuthenticationTicket Ticket { get; private set; } /// /// Replaces the ticket information on this context and marks it as as validated by the application. /// IsValidated becomes true and HasError becomes false as a result of calling. /// /// Assigned to the Ticket property /// True if the validation has taken effect. public bool Validated(AuthenticationTicket ticket) { Ticket = ticket; return Validated(); } /// /// Alters the ticket information on this context and marks it as as validated by the application. /// IsValidated becomes true and HasError becomes false as a result of calling. /// /// Assigned to the Ticket.Identity property /// True if the validation has taken effect. public bool Validated(ClaimsIdentity identity) { AuthenticationProperties properties = Ticket != null ? Ticket.Properties : new AuthenticationProperties(); return Validated(new AuthenticationTicket(identity, properties)); } } }