#### [Abblix\.Jwt](https://www.abblix.com/docs/api/abblix-jwt 'index')
### [Abblix\.Jwt](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt 'Abblix\.Jwt')

## SigningAlgorithmsProvider Class

Provides access to the collection of signing algorithms supported by the JWT infrastructure\.
Projects the set from the live keyed [ISignatureAlgorithm&lt;TJsonWebKey&gt;](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.Signing.ISignatureAlgorithm_TJsonWebKey_ 'Abblix\.Jwt\.Signing\.ISignatureAlgorithm\<TJsonWebKey\>') registrations, so
discovery always reflects exactly the signers the host currently has registered \- including
algorithms the host added or replaced \- with no registration\-time bookkeeping to keep in sync\.

```csharp
public sealed class SigningAlgorithmsProvider
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → SigningAlgorithmsProvider

### Remarks
The enumerated key types mirror the dispatch by key type that signing and verification make: a signer
registered for any other [JsonWebKey](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') subtype is unreachable at run time, so it is
deliberately not advertised\. The enumeration order \(none, RSA, EC, octet\) is the order these
algorithms appear in the discovery document, which consumers read verbatim\.
### Constructors

## SigningAlgorithmsProvider\(IServiceProvider\) Constructor {#Abblix.Jwt.SigningAlgorithmsProvider.SigningAlgorithmsProvider(System.IServiceProvider)}

Provides access to the collection of signing algorithms supported by the JWT infrastructure\.
Projects the set from the live keyed [ISignatureAlgorithm&lt;TJsonWebKey&gt;](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.Signing.ISignatureAlgorithm_TJsonWebKey_ 'Abblix\.Jwt\.Signing\.ISignatureAlgorithm\<TJsonWebKey\>') registrations, so
discovery always reflects exactly the signers the host currently has registered \- including
algorithms the host added or replaced \- with no registration\-time bookkeeping to keep in sync\.

```csharp
public SigningAlgorithmsProvider(System.IServiceProvider serviceProvider);
```
#### Parameters

###### `serviceProvider` [System\.IServiceProvider](https://learn.microsoft.com/en-us/dotnet/api/system.iserviceprovider 'System\.IServiceProvider') {#Abblix.Jwt.SigningAlgorithmsProvider.SigningAlgorithmsProvider(System.IServiceProvider).serviceProvider}

### Remarks
The enumerated key types mirror the dispatch by key type that signing and verification make: a signer
registered for any other [JsonWebKey](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') subtype is unreachable at run time, so it is
deliberately not advertised\. The enumeration order \(none, RSA, EC, octet\) is the order these
algorithms appear in the discovery document, which consumers read verbatim\.
### Properties

## SigningAlgorithmsProvider\.Algorithms Property {#Abblix.Jwt.SigningAlgorithmsProvider.Algorithms}

Gets the collection of signing algorithms supported for JWT creation and validation\.
Returns algorithm identifiers self\-declared by the registered signers \(e\.g\. "RS256", "ES384"\)\.

```csharp
public System.Collections.Generic.IEnumerable<string> Algorithms { get; }
```

#### Property Value
[System\.Collections\.Generic\.IEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
### Methods

## SigningAlgorithmsProvider\.CanSign\(JsonWebKey, string\) Method {#Abblix.Jwt.SigningAlgorithmsProvider.CanSign(Abblix.Jwt.JsonWebKey,string)}

Whether [key](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithmsProvider#Abblix.Jwt.SigningAlgorithmsProvider.CanSign(Abblix.Jwt.JsonWebKey,string).key 'Abblix\.Jwt\.SigningAlgorithmsProvider\.CanSign\(Abblix\.Jwt\.JsonWebKey, string\)\.key') may sign a JWS with [algorithm](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithmsProvider#Abblix.Jwt.SigningAlgorithmsProvider.CanSign(Abblix.Jwt.JsonWebKey,string).algorithm 'Abblix\.Jwt\.SigningAlgorithmsProvider\.CanSign\(Abblix\.Jwt\.JsonWebKey, string\)\.algorithm'): it declares that
algorithm or none, an algorithm of that name is registered for the key's type, and that algorithm accepts the
key's material\. The registry answering this is the one [Algorithms](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithmsProvider#Abblix.Jwt.SigningAlgorithmsProvider.Algorithms 'Abblix\.Jwt\.SigningAlgorithmsProvider\.Algorithms') lists and signing and
verification dispatch to, so an algorithm is advertised, matched to its keys and carried out by one and the
same registration\.

```csharp
public bool CanSign(Abblix.Jwt.JsonWebKey key, string algorithm);
```
#### Parameters

###### `key` [JsonWebKey](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') {#Abblix.Jwt.SigningAlgorithmsProvider.CanSign(Abblix.Jwt.JsonWebKey,string).key}

The key asked about\.

###### `algorithm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.SigningAlgorithmsProvider.CanSign(Abblix.Jwt.JsonWebKey,string).algorithm}

The JWS `alg` it would be used with\.

#### Returns
[System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean')

### Remarks
RFC 8725 section 3\.1: "each key MUST be used with exactly one algorithm, and this MUST be checked when the
cryptographic operation is performed", so a key declaring another algorithm is refused; RFC 7517 section 4\.4
makes `alg` optional, and a key imported from a certificate never carries one, so a key declaring none is
judged by its material\. A JWE key management algorithm is asked of
[CanEncrypt\(JsonWebKey, string\)](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.EncryptionAlgorithmsProvider#Abblix.Jwt.EncryptionAlgorithmsProvider.CanEncrypt(Abblix.Jwt.JsonWebKey,string) 'Abblix\.Jwt\.EncryptionAlgorithmsProvider\.CanEncrypt\(Abblix\.Jwt\.JsonWebKey, string\)'), and [None](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithms#Abblix.Jwt.SigningAlgorithms.None 'Abblix\.Jwt\.SigningAlgorithms\.None') is carried out
with no key, so no key signs with it\.

## SigningAlgorithmsProvider\.FirstSignedWith\(JsonWebKey, IEnumerable\<string\>\) Method {#Abblix.Jwt.SigningAlgorithmsProvider.FirstSignedWith(Abblix.Jwt.JsonWebKey,System.Collections.Generic.IEnumerable_string_)}

The first of [algorithms](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithmsProvider#Abblix.Jwt.SigningAlgorithmsProvider.FirstSignedWith(Abblix.Jwt.JsonWebKey,System.Collections.Generic.IEnumerable_string_).algorithms 'Abblix\.Jwt\.SigningAlgorithmsProvider\.FirstSignedWith\(Abblix\.Jwt\.JsonWebKey, System\.Collections\.Generic\.IEnumerable\<string\>\)\.algorithms')[key](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithmsProvider#Abblix.Jwt.SigningAlgorithmsProvider.FirstSignedWith(Abblix.Jwt.JsonWebKey,System.Collections.Generic.IEnumerable_string_).key 'Abblix\.Jwt\.SigningAlgorithmsProvider\.FirstSignedWith\(Abblix\.Jwt\.JsonWebKey, System\.Collections\.Generic\.IEnumerable\<string\>\)\.key') signs with, by [CanSign\(JsonWebKey, string\)](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithmsProvider#Abblix.Jwt.SigningAlgorithmsProvider.CanSign(Abblix.Jwt.JsonWebKey,string) 'Abblix\.Jwt\.SigningAlgorithmsProvider\.CanSign\(Abblix\.Jwt\.JsonWebKey, string\)'), or null
where it signs with none: the one it declares, or, for a key declaring none, as one taken from a certificate,
the first its material performs\.

```csharp
public string? FirstSignedWith(Abblix.Jwt.JsonWebKey key, System.Collections.Generic.IEnumerable<string> algorithms);
```
#### Parameters

###### `key` [JsonWebKey](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') {#Abblix.Jwt.SigningAlgorithmsProvider.FirstSignedWith(Abblix.Jwt.JsonWebKey,System.Collections.Generic.IEnumerable_string_).key}

The key asked about\.

###### `algorithms` [System\.Collections\.Generic\.IEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1') {#Abblix.Jwt.SigningAlgorithmsProvider.FirstSignedWith(Abblix.Jwt.JsonWebKey,System.Collections.Generic.IEnumerable_string_).algorithms}

The JWS algorithms acceptable to the caller, in its order of preference\.

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
