// 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 Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Authentication
{
///
/// Base class used by other context classes.
///
public abstract class BaseContext where TOptions : AuthenticationSchemeOptions
{
///
/// Constructor.
///
/// The context.
/// The authentication scheme.
/// The authentication options associated with the scheme.
protected BaseContext(HttpContext context, AuthenticationScheme scheme, TOptions options)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (scheme == null)
{
throw new ArgumentNullException(nameof(scheme));
}
if (options == null)
{
throw new ArgumentNullException(nameof(options));
}
HttpContext = context;
Scheme = scheme;
Options = options;
}
///
/// The authentication scheme.
///
public AuthenticationScheme Scheme { get; }
///
/// Gets the authentication options associated with the scheme.
///
public TOptions Options { get; }
///
/// The context.
///
public HttpContext HttpContext { get; }
///
/// The request.
///
public HttpRequest Request => HttpContext.Request;
///
/// The response.
///
public HttpResponse Response => HttpContext.Response;
}
}