Class JsonWebToken
Represents a simple implementation of JSON Web Token that is based on the standard RFC 7519 method for communicating claims securely between two parties. This class cannot be inherited.
Inheritance
Namespace: Cuemon.Security.Web
Assembly: Cuemon.Security.dll
Syntax
public sealed class JsonWebToken
Constructors
| Improve this DocJsonWebToken(JsonWebTokenHeader, JsonWebTokenPayload)
Initializes a new instance of the JsonWebToken class that is .
Declaration
public JsonWebToken(JsonWebTokenHeader header, JsonWebTokenPayload payload)
Parameters
Type | Name | Description |
---|---|---|
JsonWebTokenHeader | header | The first part of the JSON Web Token; the header information. |
JsonWebTokenPayload | payload | The second part of the JSON Web Token; the payload information. |
JsonWebToken(JsonWebTokenHeader, JsonWebTokenPayload, Byte[])
Initializes a new instance of the JsonWebToken class.
Declaration
public JsonWebToken(JsonWebTokenHeader header, JsonWebTokenPayload payload, byte[] secret)
Parameters
Type | Name | Description |
---|---|---|
JsonWebTokenHeader | header | The first part of the JSON Web Token; the header information. |
JsonWebTokenPayload | payload | The second part of the JSON Web Token; the payload information. |
System.Byte[] | secret | The optional secret that is used in the last part of the JSON Web Token; the signature. |
JsonWebToken(String, String, JsonWebTokenHashAlgorithm, Byte[])
Initializes a new instance of the JsonWebToken class.
Declaration
public JsonWebToken(string base64UrlEncodedHeader, string base64UrlEncodedPayload, JsonWebTokenHashAlgorithm algorithm, byte[] secret)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
JsonWebTokenHashAlgorithm | algorithm | The JsonWebTokenHashAlgorithm to use when signing the JSON Web Token. |
System.Byte[] | secret | The secret that is used when signing the JSON Web Token. |
Properties
| Improve this DocAlgorithm
Gets the JsonWebTokenHashAlgorithm of this JWT.
Declaration
public JsonWebTokenHashAlgorithm Algorithm { get; }
Property Value
Type | Description |
---|---|
JsonWebTokenHashAlgorithm | The JsonWebTokenHashAlgorithm of this JWT. |
Base64UrlEncodedHeader
Gets the header information of this JWT.
Declaration
public string Base64UrlEncodedHeader { get; }
Property Value
Type | Description |
---|---|
System.String | The header information of this JWT. |
Base64UrlEncodedPayload
Gets the payload information of this JWT.
Declaration
public string Base64UrlEncodedPayload { get; }
Property Value
Type | Description |
---|---|
System.String | The payload information of this JWT. |
Secret
Gets the secret (if any) of this JWT.
Declaration
public byte[] Secret { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | The secret (if any) of this JWT. |
Methods
| Improve this DocComputeSignature()
Computes the signature of the JSON Web Token.
Declaration
public string ComputeSignature()
Returns
Type | Description |
---|---|
System.String | A System.String that represent the signature of a JSON Web Token. |
ComputeSignature(String)
Computes the signature of the JSON Web Token.
Declaration
public string ComputeSignature(string base64UrlEncodedHeader)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
Returns
Type | Description |
---|---|
System.String | A System.String that represent the signature of a JSON Web Token. |
ComputeSignature(String, String)
Computes the signature of the JSON Web Token.
Declaration
public string ComputeSignature(string base64UrlEncodedHeader, string base64UrlEncodedPayload)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
Returns
Type | Description |
---|---|
System.String | A System.String that represent the signature of a JSON Web Token. |
ComputeSignature(String, String, JsonWebTokenHashAlgorithm)
Computes the signature of the JSON Web Token.
Declaration
public string ComputeSignature(string base64UrlEncodedHeader, string base64UrlEncodedPayload, JsonWebTokenHashAlgorithm algorithm)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
JsonWebTokenHashAlgorithm | algorithm | The JsonWebTokenHashAlgorithm to use when signing the JSON Web Token. |
Returns
Type | Description |
---|---|
System.String | A System.String that represent the signature of a JSON Web Token. |
ComputeSignature(String, String, JsonWebTokenHashAlgorithm, Byte[])
Computes the signature of the JSON Web Token.
Declaration
public string ComputeSignature(string base64UrlEncodedHeader, string base64UrlEncodedPayload, JsonWebTokenHashAlgorithm algorithm, byte[] secret)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
JsonWebTokenHashAlgorithm | algorithm | The JsonWebTokenHashAlgorithm to use when signing the JSON Web Token. |
System.Byte[] | secret | The secret that is used when signing the JSON Web Token. |
Returns
Type | Description |
---|---|
System.String | A System.String that represent the signature of a JSON Web Token. |
Tokenize()
Assemble the specified Base64UrlEncodedHeader and Base64UrlEncodedPayload to represent the first and second part of the JSON Web Token.
Declaration
public string Tokenize()
Returns
Type | Description |
---|---|
System.String | A System.String that represent a partial JSON Web Token that does not include the signature information. |
Tokenize(String, String)
Assemble the specified base64UrlEncodedHeader
and base64UrlEncodedPayload
to represent the first and second part of the JSON Web Token.
Declaration
public string Tokenize(string base64UrlEncodedHeader, string base64UrlEncodedPayload)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
Returns
Type | Description |
---|---|
System.String | A System.String that represent a partial JSON Web Token that does not include the signature information. |
ToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Overrides
Remarks
Calling this method provides the actual JSON Web Token.
ToString(String)
Returns a System.String that represents this instance.
Declaration
public string ToString(string base64UrlEncodedHeader)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String, String)
Returns a System.String that represents this instance.
Declaration
public string ToString(string base64UrlEncodedHeader, string base64UrlEncodedPayload)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String, String, JsonWebTokenHashAlgorithm)
Returns a System.String that represents this instance.
Declaration
public string ToString(string base64UrlEncodedHeader, string base64UrlEncodedPayload, JsonWebTokenHashAlgorithm algorithm)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
JsonWebTokenHashAlgorithm | algorithm | The JsonWebTokenHashAlgorithm to use when signing the JSON Web Token. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String, String, JsonWebTokenHashAlgorithm, Byte[])
Returns a System.String that represents this instance.
Declaration
public string ToString(string base64UrlEncodedHeader, string base64UrlEncodedPayload, JsonWebTokenHashAlgorithm algorithm, byte[] secret)
Parameters
Type | Name | Description |
---|---|---|
System.String | base64UrlEncodedHeader | The header information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
System.String | base64UrlEncodedPayload | The payload information of the JSON Web Token; encoded as a Base64 structure usable for transmission on the URL. |
JsonWebTokenHashAlgorithm | algorithm | The JsonWebTokenHashAlgorithm to use when signing the JSON Web Token. |
System.Byte[] | secret | The secret that is used when signing the JSON Web Token. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |