Configuration methods are methods of the ISlasconeClientV2 interface that configure the client but do not make API calls themselves.
They are used to configure authentication, signature verification, offline data storage, and HTTP behavior. All Set* methods return the current ISlasconeClientV2 instance, which allows fluent chaining.
AUTHENTICATION
The following methods configure the credential used for API requests. The provisioning key is typically provided during client construction via SlasconeClientV2Factory.BuildClient. These methods can be used to set or change credentials afterward.
Authentication methods are mutually exclusive. The client should use either a provisioning key, an admin key, or a bearer token.
SetProvisioningKey
Sets the provisioning API key for authentication. The provisioning key authorizes access to provisioning endpoints such as license activation and heartbeats.
ISlasconeClientV2 SetProvisioningKey(string provisioningKey)
Parameters
| Parameter | Type | Description |
|---|---|---|
provisioningKey | string | The provisioning API key. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
SetAdminKey
Sets the admin API key for authentication. The admin key authorizes access to administrative endpoints such as license management and customer management.
ISlasconeClientV2 SetAdminKey(string adminKey)
Parameters
| Parameter | Type | Description |
|---|---|---|
adminKey | string | The admin API key. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
SetBearer
Sets a JWT bearer token for authentication. The bearer token is provided by an identity provider and replaces API key based authentication.
ISlasconeClientV2 SetBearer(string bearer)
Parameters
| Parameter | Type | Description |
|---|---|---|
bearer | string | The JWT bearer token. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
SIGNATURE VERIFICATION
The following methods configure how the client verifies the digital signature returned in SLASCONE API responses. First set the validation mode, then provide the required key or certificate for the selected mode.
SetSignatureValidationMode
Sets the validation mode for the signature header returned in API responses.
ISlasconeClientV2 SetSignatureValidationMode(int signatureValidationMode)
Parameters
| Parameter | Type | Description |
|---|---|---|
signatureValidationMode | int | The validation mode: 0 = none, 1 = symmetric HMAC-based validation, 2 = asymmetric RSA-based validation. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
When set to 2, the client also enables replay attack protection by adding a unique X-Nonce header to each request and verifying the corresponding X-Nonce-Signature in the response.
SetSignatureCertificate
Sets the certificate containing the public key used to verify signatures in asymmetric mode. Use this method if your public key is available as certificate data.
ISlasconeClientV2 SetSignatureCertificate(byte[] rawData)
Parameters
| Parameter | Type | Description |
|---|---|---|
rawData | byte[] | The raw certificate data, for example the contents of a .cer or .pfx file. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
Internally, the client creates an X509Certificate2, extracts the public key, and delegates to SetSignaturePublicKey. This method is only applicable when SetSignatureValidationMode is set to 2.
SetSignaturePublicKeyXml
Sets the RSA public key from an XML string for signature verification in asymmetric mode.
ISlasconeClientV2 SetSignaturePublicKeyXml(string publicKeyXml)
Parameters
| Parameter | Type | Description |
|---|---|---|
publicKeyXml | string | The RSA public key in XML format. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
Internally, the client creates an RSACryptoServiceProvider and imports the XML key. This method is only applicable when SetSignatureValidationMode is set to 2.
SetSignaturePublicKey
Sets the RSA public key directly for signature verification in asymmetric mode.
ISlasconeClientV2 SetSignaturePublicKey(PublicKey publicKey)
Parameters
| Parameter | Type | Description |
|---|---|---|
publicKey | System.Security.Cryptography.X509Certificates.PublicKey | An RSA public key object. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Exceptions
| Exception | Condition |
|---|---|
ArgumentException | The provided publicKey is not an RSA key. |
Remarks
This method is only applicable when SetSignatureValidationMode is set to 2.
SetSignatureSymmetricKey
Sets the symmetric key used to verify signatures in symmetric mode.
ISlasconeClientV2 SetSignatureSymmetricKey(string symmetricEncryptionKey)
Parameters
| Parameter | Type | Description |
|---|---|---|
symmetricEncryptionKey | string | The symmetric encryption key. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
This method is only applicable when SetSignatureValidationMode is set to 1.
OFFLINE DATA STORAGE
The following methods configure how the client stores and retrieves license data locally for offline scenarios.
There are two mutually exclusive strategies: the default file-based strategy configured with SetAppDataFolder, and a custom strategy configured with SetOfflineDataStorageStrategy. Do not combine both.
SetAppDataFolder
Sets the application data folder for the default file-based offline data storage strategy. License information gathered from API calls, such as heartbeats, is automatically stored in this folder for offline use.
ISlasconeClientV2 SetAppDataFolder(string appDataFolder)
Parameters
| Parameter | Type | Description |
|---|---|---|
appDataFolder | string | The path to the folder where offline license files are stored. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
This method uses the default AppDataFolderOfflineDataStorageStrategy. If no app data folder is set, features such as GetOfflineLicense() and temporary offline license handling are not available. Do not use this method together with SetOfflineDataStorageStrategy.
SetOfflineDataStorageStrategy
Sets a custom strategy for storing offline data. Use this method to provide your own implementation of the ITemporaryOfflineDataStorageStrategy interface, for example to store offline data in a database instead of the local file system.
ISlasconeClientV2 SetOfflineDataStorageStrategy(ITemporaryOfflineDataStorageStrategy strategy)
Parameters
| Parameter | Type | Description |
|---|---|---|
strategy | ITemporaryOfflineDataStorageStrategy | A custom implementation of the offline data storage strategy interface. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
When using a custom strategy, do not use SetAppDataFolder, SetTempOfflineLicenseFilenames, or SetTempOfflineSessionFilename, because these methods configure the default file-based strategy only.
SetTempOfflineLicenseFilenames
Sets the filenames for the temporary offline license and signature files used by the default file-based storage strategy.
ISlasconeClientV2 SetTempOfflineLicenseFilenames(string licenseFileName, string signatureFileName)
Parameters
| Parameter | Type | Description |
|---|---|---|
licenseFileName | string | The filename for the temporary offline license file. Default: license.json. |
signatureFileName | string | The filename for the temporary offline signature file. Default: license_signature.txt. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
This method is only applicable when using the default file-based storage strategy via SetAppDataFolder. Do not use it when a custom ITemporaryOfflineDataStorageStrategy is set.
SetTempOfflineSessionFilename
Sets the filename for the temporary offline session file used by the default file-based storage strategy.
ISlasconeClientV2 SetTempOfflineSessionFilename(string sessionFileName)
Parameters
| Parameter | Type | Description |
|---|---|---|
sessionFileName | string | The filename for the temporary offline session file. Default: session.token. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
This method is only applicable when using the default file-based storage strategy via SetAppDataFolder. Do not use it when a custom ITemporaryOfflineDataStorageStrategy is set.
HTTP CONFIGURATION
The following methods configure aspects of the underlying HTTP client used for API requests, including timeouts, custom headers, HTTPS diagnostics, and user tracking.
SetHttpClientTimeout
Sets the timeout for all HTTP requests made by the client.
ISlasconeClientV2 SetHttpClientTimeout(TimeSpan timeout)
Parameters
| Parameter | Type | Description |
|---|---|---|
timeout | System.TimeSpan | The timeout duration for HTTP requests. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
The default timeout is 100 seconds. This timeout applies to all API requests made by the client.
SetCheckHttpsCertificate
Activates recording of the HTTPS certificate chain of trust for the next API call.
ISlasconeClientV2 SetCheckHttpsCertificate(bool check = true)
Parameters
| Parameter | Type | Description |
|---|---|---|
check | bool | true to enable recording, false to disable. Defaults to true. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
When enabled, the next API call records information about the HTTPS certificate chain of trust. The recorded data can be retrieved through the HttpsChainOfTrust property. Recording is performed only once to avoid performance overhead.
SetLastModifiedByHeader
Sets the LastModifiedBy HTTP header on requests. When API key authentication is used, this header can identify the user sending the request. The value is recorded in history entries on the SLASCONE backend.
ISlasconeClientV2 SetLastModifiedByHeader(string lastModifiedById)
Parameters
| Parameter | Type | Description |
|---|---|---|
lastModifiedById | string | An identifier for the user making the request, for example an email address or user ID. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
Remarks
This method is only relevant when using API key authentication through SetProvisioningKey or SetAdminKey. If bearer token authentication is used, this header is ignored because the user identity is already conveyed by the token.
SetHttpRequestHeader
Sets, replaces, or removes a specific HTTP header for all subsequent API requests. If the header already exists, its value is replaced. If headerValue is null or empty, the header is removed.
ISlasconeClientV2 SetHttpRequestHeader(string headerName, string headerValue)
Parameters
| Parameter | Type | Description |
|---|---|---|
headerName | string | The name of the HTTP header. |
headerValue | string | The value of the HTTP header. If null or empty, the header is removed. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
AddHttpRequestHeader
Adds a specific HTTP header for all subsequent API requests. Unlike SetHttpRequestHeader, this method does not replace existing values. It adds an additional value for the same header name and can therefore be used for multi-value headers.
ISlasconeClientV2 AddHttpRequestHeader(string headerName, string headerValue)
Parameters
| Parameter | Type | Description |
|---|---|---|
headerName | string | The name of the HTTP header. |
headerValue | string | The value to add for the HTTP header. |
Returns
ISlasconeClientV2, the current client instance for fluent chaining.
TryGetHttpRequestHeader
Tries to retrieve the value or values of a specific HTTP header that has been configured on the client.
bool TryGetHttpRequestHeader(string headerName, out IEnumerable<string> values)
Parameters
| Parameter | Type | Description |
|---|---|---|
headerName | string | The name of the HTTP header to retrieve. |
values | out IEnumerable<string> | When the method returns true, contains the header values. |
Returns
true if the header exists and its values were retrieved; otherwise, false.
Comments
0 comments
Article is closed for comments.