Table of Contents

Class StatementSigner

Namespace
Xapi.Client
Assembly
Xapi.Client.dll

Signs Statements as IEEE 9274.1.1, 4.2.6 "Statement Signing" describes: a JSON Web Signature (RFC 7515, Compact Serialization, RS256, RS384 or RS512) of the Statement, sent as an Attachment with usage type SignatureUsageType and content type application/octet-stream.

public static class StatementSigner
Inheritance
StatementSigner
Inherited Members

Remarks

An LRS checks that the signature is well formed and, when the JWS header carries the signer's certificate (x5c), that it verifies with that certificate. Whether the signer is trusted is for whoever reads the Statement to decide.

Properties

SignatureUsageType

The usage type of a signature Attachment, http://adlnet.gov/expapi/attachments/signature.

public static Iri SignatureUsageType { get; }

Property Value

Iri

Methods

Sign(Statement, RSA, XapiVersion, HashAlgorithmName, IReadOnlyList<X509Certificate2>?)

Signs a Statement with an RSA private key.

public static SignedStatement Sign(Statement statement, RSA privateKey, XapiVersion version, HashAlgorithmName hashAlgorithm = default, IReadOnlyList<X509Certificate2>? certificateChain = null)

Parameters

statement Statement

The complete Statement to sign. It must not have a signature Attachment yet.

privateKey RSA

The RSA private key, for example from X509Certificate2's GetRSAPrivateKey().

version XapiVersion

The xAPI version the Statement is serialized and sent in.

hashAlgorithm HashAlgorithmName

SHA-256, SHA-384 or SHA-512, for the JWS algorithm RS256, RS384 or RS512. The default value means SHA-256.

certificateChain IReadOnlyList<X509Certificate2>

The certificate of privateKey followed by the rest of its chain, put in the JWS x5c header (4.2.6: should be included when an X.509 certificate is used to sign). Optional.

Returns

SignedStatement

The Statement with its signature Attachment object, and the signature to send with it.

Exceptions

ArgumentException

The Statement already has a signature Attachment, the hash algorithm is not one of the three, or the chain contains a null entry.