9 changed files with 93 additions and 41 deletions
@ -0,0 +1,40 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace OpenIddict { |
||||
|
public static class OpenIddictHelpers { |
||||
|
public static async Task<bool> IsConfidentialApplicationAsync<TUser, TApplication>( |
||||
|
this OpenIddictManager<TUser, TApplication> manager, TApplication application) |
||||
|
where TUser : class |
||||
|
where TApplication : class { |
||||
|
if (manager == null) { |
||||
|
throw new ArgumentNullException(nameof(manager)); |
||||
|
} |
||||
|
|
||||
|
if (application == null) { |
||||
|
throw new ArgumentNullException(nameof(application)); |
||||
|
} |
||||
|
|
||||
|
var type = await manager.GetApplicationTypeAsync(application); |
||||
|
|
||||
|
return string.Equals(type, OpenIddictConstants.ApplicationTypes.Confidential, StringComparison.OrdinalIgnoreCase); |
||||
|
} |
||||
|
|
||||
|
public static async Task<bool> IsPublicApplicationAsync<TUser, TApplication>( |
||||
|
this OpenIddictManager<TUser, TApplication> manager, TApplication application) |
||||
|
where TUser : class |
||||
|
where TApplication : class { |
||||
|
if (manager == null) { |
||||
|
throw new ArgumentNullException(nameof(manager)); |
||||
|
} |
||||
|
|
||||
|
if (application == null) { |
||||
|
throw new ArgumentNullException(nameof(application)); |
||||
|
} |
||||
|
|
||||
|
var type = await manager.GetApplicationTypeAsync(application); |
||||
|
|
||||
|
return string.Equals(type, OpenIddictConstants.ApplicationTypes.Public, StringComparison.OrdinalIgnoreCase); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,12 +0,0 @@ |
|||||
/* |
|
||||
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
|
|
||||
* See https://github.com/openiddict/core for more information concerning
|
|
||||
* the license and the contributors participating to this project. |
|
||||
*/ |
|
||||
|
|
||||
namespace OpenIddict.Models { |
|
||||
public enum ApplicationType { |
|
||||
Public = 0, |
|
||||
Confidential = 1 |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue