Skip to content
Prev Previous commit
Next Next commit
Null agrument check added
  • Loading branch information
mihirdilip committed Mar 2, 2021
commit 32ac48aa492cde6f46d73952fe89bdee3d77e85c
12 changes: 7 additions & 5 deletions src/AspNetCore.Authentication.Basic/BasicUtils.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Copyright (c) Mihir Dilip. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;

namespace AspNetCore.Authentication.Basic
{
/// <summary>
/// Utility class.
/// </summary>
internal static class BasicUtils
/// <summary>
/// Utility class.
/// </summary>
internal static class BasicUtils
{
/// <summary>
/// Builds Claims Principal from the provided information.
Expand All @@ -24,8 +25,9 @@ internal static class BasicUtils
/// <returns></returns>
internal static ClaimsPrincipal BuildClaimsPrincipal(string username, string schemeName, string claimsIssuer, IEnumerable<Claim> claims = null)
{
var claimsList = new List<Claim>();
if (string.IsNullOrWhiteSpace(schemeName)) throw new ArgumentNullException(nameof(schemeName));

var claimsList = new List<Claim>();
if (claims != null) claimsList.AddRange(claims);

if (!claimsList.Any(c => c.Type == ClaimTypes.NameIdentifier))
Expand Down