Skip to content

Commit

Permalink
remove some dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 27, 2024
1 parent d1e1717 commit a660995
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 183 deletions.
155 changes: 0 additions & 155 deletions src/EntityFramework.Storage/Extensions/StringsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.Encodings.Web;

namespace Duende.IdentityServer.EntityFramework.Extensions;

Expand All @@ -23,116 +21,6 @@ public static string ToSpaceSeparatedString(this IEnumerable<string> list)
return String.Join(' ', list);
}

[DebuggerStepThrough]
public static IEnumerable<string> FromSpaceSeparatedString(this string input)
{
input = input.Trim();
return input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}

public static List<string> ParseScopesString(this string scopes)
{
if (scopes.IsMissing())
{
return null;
}

scopes = scopes.Trim();
var parsedScopes = scopes.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();

if (parsedScopes.Any())
{
parsedScopes.Sort();
return parsedScopes;
}

return null;
}

[DebuggerStepThrough]
public static bool IsMissing(this string value)
{
return string.IsNullOrWhiteSpace(value);
}

[DebuggerStepThrough]
public static bool IsMissingOrTooLong(this string value, int maxLength)
{
if (string.IsNullOrWhiteSpace(value))
{
return true;
}
if (value.Length > maxLength)
{
return true;
}

return false;
}

[DebuggerStepThrough]
public static bool IsPresent(this string value)
{
return !string.IsNullOrWhiteSpace(value);
}

[DebuggerStepThrough]
public static string EnsureLeadingSlash(this string url)
{
if (url != null && !url.StartsWith('/'))
{
return "/" + url;
}

return url;
}

[DebuggerStepThrough]
public static string EnsureTrailingSlash(this string url)
{
if (url != null && !url.EndsWith('/'))
{
return url + "/";
}

return url;
}

[DebuggerStepThrough]
public static string RemoveLeadingSlash(this string url)
{
if (url != null && url.StartsWith('/'))
{
url = url.Substring(1);
}

return url;
}

[DebuggerStepThrough]
public static string RemoveTrailingSlash(this string url)
{
if (url != null && url.EndsWith('/'))
{
url = url.Substring(0, url.Length - 1);
}

return url;
}

[DebuggerStepThrough]
public static string CleanUrlPath(this string url)
{
if (String.IsNullOrWhiteSpace(url)) url = "/";

if (url != "/" && url.EndsWith('/'))
{
url = url.Substring(0, url.Length - 1);
}

return url;
}

[DebuggerStepThrough]
public static bool IsLocalUrl(this string url)
{
Expand Down Expand Up @@ -195,47 +83,4 @@ static bool HasControlCharacter(ReadOnlySpan<char> readOnlySpan)
return false;
}
}

[DebuggerStepThrough]
public static string AddQueryString(this string url, string query)
{
if (!url.Contains('?'))
{
url += "?";
}
else if (!url.EndsWith('&'))
{
url += "&";
}

return url + query;
}

[DebuggerStepThrough]
public static string AddQueryString(this string url, string name, string value)
{
return url.AddQueryString(name + "=" + UrlEncoder.Default.Encode(value));
}

[DebuggerStepThrough]
public static string AddHashFragment(this string url, string query)
{
if (!url.Contains('#'))
{
url += "#";
}

return url + query;
}

public static string Obfuscate(this string value)
{
var last4Chars = "****";
if (value.IsPresent() && value.Length > 4)
{
last4Chars = value.Substring(value.Length - 4);
}

return "****" + last4Chars;
}
}
22 changes: 0 additions & 22 deletions src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,4 @@ private TokenErrorResult Error(string error, string errorDescription = null, Dic

return new TokenErrorResult(response);
}

private void LogResponse(DeviceAuthorizationResponse response, DeviceAuthorizationRequestValidationResult requestResult)
{
var clientId = $"{requestResult.ValidatedRequest.Client.ClientId} ({requestResult.ValidatedRequest.Client?.ClientName ?? "no name set"})";

if (response.DeviceCode != null)
{
_logger.LogTrace("Device code issued for {clientId}: {deviceCode}", clientId, response.DeviceCode);
}
if (response.UserCode != null)
{
_logger.LogTrace("User code issued for {clientId}: {userCode}", clientId, response.UserCode);
}
if (response.VerificationUri != null)
{
_logger.LogTrace("Verification URI issued for {clientId}: {verificationUri}", clientId, response.VerificationUri);
}
if (response.VerificationUriComplete != null)
{
_logger.LogTrace("Verification URI (Complete) issued for {clientId}: {verificationUriComplete}", clientId, response.VerificationUriComplete);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,4 @@ private void LogError(string message, ValidatedAuthorizeRequest request)
var requestDetails = new AuthorizeRequestValidationLog(request, _options.Logging.AuthorizeRequestSensitiveValuesFilter);
_logger.LogError(message + "\n{@requestDetails}", requestDetails);
}

private void LogError(string message, string detail, ValidatedAuthorizeRequest request)
{
var requestDetails = new AuthorizeRequestValidationLog(request, _options.Logging.AuthorizeRequestSensitiveValuesFilter);
_logger.LogError(message + ": {detail}\n{@requestDetails}", detail, requestDetails);
}
}

0 comments on commit a660995

Please sign in to comment.