forked from OPCFoundation/UA-.NETStandard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIApplicationConfigurationBuilder.cs
More file actions
696 lines (593 loc) · 33.4 KB
/
IApplicationConfigurationBuilder.cs
File metadata and controls
696 lines (593 loc) · 33.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
/* ========================================================================
* Copyright (c) 2005-2024 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
namespace Opc.Ua.Configuration
{
/// <summary>
/// A fluent API to build the application configuration.
/// </summary>
public interface IApplicationConfigurationBuilder
: IApplicationConfigurationBuilderTypes,
IApplicationConfigurationBuilderTransportQuotasSet,
IApplicationConfigurationBuilderServerSelected,
IApplicationConfigurationBuilderServerOptions,
IApplicationConfigurationBuilderClientSelected,
IApplicationConfigurationBuilderSecurity,
IApplicationConfigurationBuilderSecurityOptions,
IApplicationConfigurationBuilderSecurityOptionStores,
IApplicationConfigurationBuilderServerPolicies,
IApplicationConfigurationBuilderCreate;
/// <summary>
/// The client or server configuration types to choose.
/// </summary>
public interface IApplicationConfigurationBuilderTypes
: IApplicationConfigurationBuilderTransportQuotas
;
/// <summary>
/// The set transport quota state.
/// </summary>
public interface IApplicationConfigurationBuilderTransportQuotas
: IApplicationConfigurationBuilderServer,
IApplicationConfigurationBuilderClient
{
/// <summary>
/// Set the transport quotas for this application (client and server).
/// </summary>
/// <param name="transportQuotas">The object with the new transport quotas.</param>
IApplicationConfigurationBuilderTransportQuotasSet SetTransportQuotas(
TransportQuotas transportQuotas);
/// <inheritdoc cref="TransportQuotas.OperationTimeout"/>
/// <remarks>applies to <see cref="TransportQuotas.OperationTimeout"/></remarks>
/// <param name="operationTimeout">The operation timeout in ms.</param>
IApplicationConfigurationBuilderTransportQuotas SetOperationTimeout(int operationTimeout);
/// <inheritdoc cref="TransportQuotas.MaxStringLength"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxStringLength"/></remarks>
/// <param name="maxStringLength">The max string length.</param>
IApplicationConfigurationBuilderTransportQuotas SetMaxStringLength(int maxStringLength);
/// <inheritdoc cref="TransportQuotas.MaxByteStringLength"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxByteStringLength"/></remarks>
/// <param name="maxByteStringLength">The max byte string length.</param>
IApplicationConfigurationBuilderTransportQuotas SetMaxByteStringLength(
int maxByteStringLength);
/// <inheritdoc cref="TransportQuotas.MaxArrayLength"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxArrayLength"/></remarks>
/// <param name="maxArrayLength">The max array length.</param>
IApplicationConfigurationBuilderTransportQuotas SetMaxArrayLength(int maxArrayLength);
/// <inheritdoc cref="TransportQuotas.MaxMessageSize"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxMessageSize"/></remarks>
/// <param name="maxMessageSize">The max message size.</param>
IApplicationConfigurationBuilderTransportQuotas SetMaxMessageSize(int maxMessageSize);
/// <inheritdoc cref="TransportQuotas.MaxBufferSize"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxBufferSize"/></remarks>
/// <param name="maxBufferSize">The max buffer size.</param>
IApplicationConfigurationBuilderTransportQuotas SetMaxBufferSize(int maxBufferSize);
/// <inheritdoc cref="TransportQuotas.MaxEncodingNestingLevels"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxEncodingNestingLevels"/></remarks>
IApplicationConfigurationBuilderTransportQuotas SetMaxEncodingNestingLevels(
int maxEncodingNestingLevels);
/// <inheritdoc cref="TransportQuotas.MaxDecoderRecoveries"/>
/// <remarks>applies to <see cref="TransportQuotas.MaxDecoderRecoveries"/></remarks>
IApplicationConfigurationBuilderTransportQuotas SetMaxDecoderRecoveries(
int maxDecoderRecoveries);
/// <inheritdoc cref="TransportQuotas.ChannelLifetime"/>
/// <remarks>applies to <see cref="TransportQuotas.ChannelLifetime"/></remarks>
/// <param name="channelLifetime">The lifetime.</param>
IApplicationConfigurationBuilderTransportQuotas SetChannelLifetime(int channelLifetime);
/// <inheritdoc cref="TransportQuotas.SecurityTokenLifetime"/>
/// <remarks>applies to <see cref="TransportQuotas.SecurityTokenLifetime"/></remarks>
/// <param name="securityTokenLifetime">The lifetime in milliseconds.</param>
IApplicationConfigurationBuilderTransportQuotas SetSecurityTokenLifetime(
int securityTokenLifetime);
}
/// <summary>
/// The set transport quota state.
/// </summary>
public interface IApplicationConfigurationBuilderTransportQuotasSet
: IApplicationConfigurationBuilderServer,
IApplicationConfigurationBuilderClient;
/// <summary>
/// The interfaces to implement if a server is selected.
/// </summary>
public interface IApplicationConfigurationBuilderServerSelected
: IApplicationConfigurationBuilderServerPolicies,
IApplicationConfigurationBuilderServerOptions
;
/// <summary>
/// The options which can be set if a server is selected.
/// </summary>
public interface IApplicationConfigurationBuilderServerOptions
: IApplicationConfigurationBuilderClient,
IApplicationConfigurationBuilderSecurity
{
/// <inheritdoc cref="ServerBaseConfiguration.MinRequestThreadCount"/>
IApplicationConfigurationBuilderServerOptions SetMinRequestThreadCount(
int minRequestThreadCount);
/// <inheritdoc cref="ServerBaseConfiguration.MaxRequestThreadCount"/>
IApplicationConfigurationBuilderServerOptions SetMaxRequestThreadCount(
int maxRequestThreadCount);
/// <inheritdoc cref="ServerBaseConfiguration.MaxQueuedRequestCount"/>
IApplicationConfigurationBuilderServerOptions SetMaxQueuedRequestCount(
int maxQueuedRequestCount);
/// <inheritdoc cref="ServerConfiguration.DiagnosticsEnabled"/>
IApplicationConfigurationBuilderServerOptions SetDiagnosticsEnabled(
bool diagnosticsEnabled);
/// <inheritdoc cref="ServerConfiguration.MaxSessionCount"/>
IApplicationConfigurationBuilderServerOptions SetMaxSessionCount(int maxSessionCount);
/// <inheritdoc cref="ServerConfiguration.MaxChannelCount"/>
/// <remarks>applies to <see cref="ServerConfiguration.MaxChannelCount"/></remarks>
/// <param name="maxChannelCount">The lifetime.</param>
IApplicationConfigurationBuilderServerOptions SetMaxChannelCount(int maxChannelCount);
/// <inheritdoc cref="ServerConfiguration.MinSessionTimeout"/>
IApplicationConfigurationBuilderServerOptions SetMinSessionTimeout(int minSessionTimeout);
/// <inheritdoc cref="ServerConfiguration.MaxSessionTimeout"/>
IApplicationConfigurationBuilderServerOptions SetMaxSessionTimeout(int maxSessionTimeout);
/// <inheritdoc cref="ServerConfiguration.MaxBrowseContinuationPoints"/>
IApplicationConfigurationBuilderServerOptions SetMaxBrowseContinuationPoints(
int maxBrowseContinuationPoints);
/// <inheritdoc cref="ServerConfiguration.MaxQueryContinuationPoints"/>
IApplicationConfigurationBuilderServerOptions SetMaxQueryContinuationPoints(
int maxQueryContinuationPoints);
/// <inheritdoc cref="ServerConfiguration.MaxHistoryContinuationPoints"/>
IApplicationConfigurationBuilderServerOptions SetMaxHistoryContinuationPoints(
int maxHistoryContinuationPoints);
/// <inheritdoc cref="ServerConfiguration.MaxRequestAge"/>
IApplicationConfigurationBuilderServerOptions SetMaxRequestAge(int maxRequestAge);
/// <inheritdoc cref="ServerConfiguration.MinPublishingInterval"/>
IApplicationConfigurationBuilderServerOptions SetMinPublishingInterval(
int minPublishingInterval);
/// <inheritdoc cref="ServerConfiguration.MaxPublishingInterval"/>
IApplicationConfigurationBuilderServerOptions SetMaxPublishingInterval(
int maxPublishingInterval);
/// <inheritdoc cref="ServerConfiguration.PublishingResolution"/>
IApplicationConfigurationBuilderServerOptions SetPublishingResolution(
int publishingResolution);
/// <inheritdoc cref="ServerConfiguration.MaxSubscriptionLifetime"/>
IApplicationConfigurationBuilderServerOptions SetMaxSubscriptionLifetime(
int maxSubscriptionLifetime);
/// <inheritdoc cref="ServerConfiguration.MaxMessageQueueSize"/>
IApplicationConfigurationBuilderServerOptions SetMaxMessageQueueSize(
int maxMessageQueueSize);
/// <inheritdoc cref="ServerConfiguration.MaxNotificationQueueSize"/>
IApplicationConfigurationBuilderServerOptions SetMaxNotificationQueueSize(
int maxNotificationQueueSize);
/// <inheritdoc cref="ServerConfiguration.MaxNotificationsPerPublish"/>
IApplicationConfigurationBuilderServerOptions SetMaxNotificationsPerPublish(
int maxNotificationsPerPublish);
/// <inheritdoc cref="ServerConfiguration.MinMetadataSamplingInterval"/>
IApplicationConfigurationBuilderServerOptions SetMinMetadataSamplingInterval(
int minMetadataSamplingInterval);
/// <inheritdoc cref="ServerConfiguration.AvailableSamplingRates"/>
IApplicationConfigurationBuilderServerOptions SetAvailableSamplingRates(
SamplingRateGroupCollection availableSampleRates);
/// <inheritdoc cref="ServerConfiguration.RegistrationEndpoint"/>
IApplicationConfigurationBuilderServerOptions SetRegistrationEndpoint(
EndpointDescription registrationEndpoint);
/// <inheritdoc cref="ServerConfiguration.MaxRegistrationInterval"/>
IApplicationConfigurationBuilderServerOptions SetMaxRegistrationInterval(
int maxRegistrationInterval);
/// <inheritdoc cref="ServerConfiguration.NodeManagerSaveFile"/>
IApplicationConfigurationBuilderServerOptions SetNodeManagerSaveFile(
string nodeManagerSaveFile);
/// <inheritdoc cref="ServerConfiguration.MinSubscriptionLifetime"/>
IApplicationConfigurationBuilderServerOptions SetMinSubscriptionLifetime(
int minSubscriptionLifetime);
/// <inheritdoc cref="ServerConfiguration.MaxPublishRequestCount"/>
IApplicationConfigurationBuilderServerOptions SetMaxPublishRequestCount(
int maxPublishRequestCount);
/// <inheritdoc cref="ServerConfiguration.MaxSubscriptionCount"/>
IApplicationConfigurationBuilderServerOptions SetMaxSubscriptionCount(
int maxSubscriptionCount);
/// <inheritdoc cref="ServerConfiguration.MaxEventQueueSize"/>
IApplicationConfigurationBuilderServerOptions SetMaxEventQueueSize(
int setMaxEventQueueSize);
/// <inheritdoc cref="ServerConfiguration.ServerProfileArray" path="/summary"/>
/// <param name="serverProfile">Add a server profile to the array.</param>
IApplicationConfigurationBuilderServerOptions AddServerProfile(string serverProfile);
/// <inheritdoc cref="ServerConfiguration.ShutdownDelay"/>
IApplicationConfigurationBuilderServerOptions SetShutdownDelay(int shutdownDelay);
/// <inheritdoc cref="ServerConfiguration.ServerCapabilities" path="/summary"/>
/// <param name="serverCapability">The server capability to add.</param>
IApplicationConfigurationBuilderServerOptions AddServerCapabilities(
string serverCapability);
/// <inheritdoc cref="ServerConfiguration.SupportedPrivateKeyFormats"/>
IApplicationConfigurationBuilderServerOptions SetSupportedPrivateKeyFormats(
StringCollection supportedPrivateKeyFormats);
/// <inheritdoc cref="ServerConfiguration.MaxTrustListSize"/>
IApplicationConfigurationBuilderServerOptions SetMaxTrustListSize(int maxTrustListSize);
/// <inheritdoc cref="ServerConfiguration.MultiCastDnsEnabled"/>
IApplicationConfigurationBuilderServerOptions SetMultiCastDnsEnabled(
bool multiCastDnsEnabled);
/// <inheritdoc cref="ServerConfiguration.ReverseConnect"/>
IApplicationConfigurationBuilderServerOptions SetReverseConnect(
ReverseConnectServerConfiguration reverseConnectConfiguration);
/// <inheritdoc cref="ServerConfiguration.OperationLimits"/>
IApplicationConfigurationBuilderServerOptions SetOperationLimits(
OperationLimits operationLimits);
/// <inheritdoc cref="ServerConfiguration.AuditingEnabled"/>
IApplicationConfigurationBuilderServerOptions SetAuditingEnabled(bool auditingEnabled);
/// <inheritdoc cref="ServerConfiguration.HttpsMutualTls"/>
IApplicationConfigurationBuilderServerOptions SetHttpsMutualTls(bool mTlsEnabled);
/// <inheritdoc cref="ServerConfiguration.DurableSubscriptionsEnabled"/>
IApplicationConfigurationBuilderServerOptions SetDurableSubscriptionsEnabled(
bool durableSubscriptionsEnabled);
/// <inheritdoc cref="ServerConfiguration.MaxDurableNotificationQueueSize"/>
IApplicationConfigurationBuilderServerOptions SetMaxDurableNotificationQueueSize(
int maxDurableNotificationQueueSize);
/// <inheritdoc cref="ServerConfiguration.MaxDurableEventQueueSize"/>
IApplicationConfigurationBuilderServerOptions SetMaxDurableEventQueueSize(
int maxDurableEventQueueSize);
/// <inheritdoc cref="ServerConfiguration.MaxDurableSubscriptionLifetimeInHours"/>
IApplicationConfigurationBuilderServerOptions SetMaxDurableSubscriptionLifetime(
int maxDurableSubscriptionLifetimeInHours);
}
/// <summary>
/// The interfaces to implement if a client is selected.
/// </summary>
public interface IApplicationConfigurationBuilderClientSelected
: IApplicationConfigurationBuilderClientOptions;
/// <summary>
/// The options to set if a client is selected.
/// </summary>
public interface IApplicationConfigurationBuilderClientOptions : IApplicationConfigurationBuilderSecurity
{
/// <inheritdoc cref="ClientConfiguration.DefaultSessionTimeout"/>
IApplicationConfigurationBuilderClientOptions SetDefaultSessionTimeout(
int defaultSessionTimeout);
/// <inheritdoc cref="ClientConfiguration.WellKnownDiscoveryUrls"/>
/// <param name="wellKnownDiscoveryUrl">The well known discovery server url to add.</param>
IApplicationConfigurationBuilderClientOptions AddWellKnownDiscoveryUrls(
string wellKnownDiscoveryUrl);
/// <inheritdoc cref="ClientConfiguration.DiscoveryServers"/>
/// <param name="discoveryServer">The discovery server endpoint description to add.</param>
IApplicationConfigurationBuilderClientOptions AddDiscoveryServer(
EndpointDescription discoveryServer);
/// <inheritdoc cref="ClientConfiguration.EndpointCacheFilePath"/>
IApplicationConfigurationBuilderClientOptions SetEndpointCacheFilePath(
string endpointCacheFilePath);
/// <inheritdoc cref="ClientConfiguration.MinSubscriptionLifetime"/>
IApplicationConfigurationBuilderClientOptions SetMinSubscriptionLifetime(
int minSubscriptionLifetime);
/// <inheritdoc cref="ClientConfiguration.ReverseConnect"/>
IApplicationConfigurationBuilderClientOptions SetReverseConnect(
ReverseConnectClientConfiguration reverseConnect);
/// <inheritdoc cref="ClientConfiguration.OperationLimits"/>
IApplicationConfigurationBuilderClientOptions SetClientOperationLimits(
OperationLimits operationLimits);
}
/// <summary>
/// Add the server configuration (optional).
/// </summary>
public interface IApplicationConfigurationBuilderServer
{
/// <summary>
/// Configure instance to be used for UA server.
/// </summary>
IApplicationConfigurationBuilderServerSelected AsServer(
string[] baseAddresses,
string[] alternateBaseAddresses = null);
}
/// <summary>
/// Add the client configuration (optional).
/// </summary>
public interface IApplicationConfigurationBuilderClient
{
/// <summary>
/// Configure instance to be used for UA client.
/// </summary>
IApplicationConfigurationBuilderClientSelected AsClient();
}
/// <summary>
/// Add the supported server policies.
/// </summary>
public interface IApplicationConfigurationBuilderServerPolicies
{
/// <summary>
/// Add the unsecure security policy type none to server configuration.
/// </summary>
/// <param name="addPolicy">Add policy if true.</param>
IApplicationConfigurationBuilderServerSelected AddUnsecurePolicyNone(bool addPolicy = true);
/// <summary>
/// Add the sign security policies to the server configuration.
/// </summary>
/// <param name="addPolicies">Add policies if true.</param>
IApplicationConfigurationBuilderServerSelected AddSignPolicies(bool addPolicies = true);
/// <summary>
/// Add the sign and encrypt security policies to the server configuration.
/// </summary>
/// <param name="addPolicies">Add policies if true.</param>
IApplicationConfigurationBuilderServerSelected AddSignAndEncryptPolicies(
bool addPolicies = true);
/// <summary>
/// Add the ECCsign security policies to the server configuration.
/// </summary>
/// <remarks>
/// The policies are only added if the platform supports the ECC policies.
/// </remarks>
IApplicationConfigurationBuilderServerSelected AddEccSignPolicies();
/// <summary>
/// Add the ECC sign and encrypt security policies to the server configuration.
/// </summary>
/// <remarks>
/// The policies are only added if the platform supports the ECC policies.
/// </remarks>
IApplicationConfigurationBuilderServerSelected AddEccSignAndEncryptPolicies();
/// <summary>
/// Add the specified security policy with the specified security mode.
/// </summary>
/// <param name="securityMode">The message security mode to add the policy to.</param>
/// <param name="securityPolicy">The security policy Uri string.</param>
IApplicationConfigurationBuilderServerSelected AddPolicy(
MessageSecurityMode securityMode,
string securityPolicy);
/// <summary>
/// Add user token policy to the server configuration.
/// </summary>
/// <param name="userTokenType">The user token type to add.</param>
IApplicationConfigurationBuilderServerSelected AddUserTokenPolicy(
UserTokenType userTokenType);
/// <summary>
/// Add user token policy to the server configuration.
/// </summary>
/// <param name="userTokenPolicy">The user token policy to add.</param>
IApplicationConfigurationBuilderServerSelected AddUserTokenPolicy(
UserTokenPolicy userTokenPolicy);
}
/// <summary>
/// Add the security configuration (mandatory).
/// </summary>
public interface IApplicationConfigurationBuilderSecurity
{
/// <summary>
/// Add the security configuration.
/// </summary>
/// <remarks>
/// The pki root path default to the certificate store
/// location as defined in <see cref="CertificateStoreIdentifier.DefaultPKIRoot"/>
/// A <see cref="CertificateStoreType"/> defaults to the corresponding default store location.
/// </remarks>
/// <param name="subjectName">Application certificate subject name as distinguished name. A DC=localhost entry is converted to the hostname. The common name CN= is mandatory.</param>
/// <param name="pkiRoot">The path to the pki root. By default all cert stores use the pki root.</param>
/// <param name="appRoot">The path to the app cert store, if different than the pki root.</param>
/// <param name="rejectedRoot">The path to the rejected certificate store.</param>
[Obsolete(
"Use AddSecurityConfiguration(CertificateIdentifierCollection certIdList, string pkiRoot = null, string rejectedRoot = null) instead."
)]
IApplicationConfigurationBuilderSecurityOptions AddSecurityConfiguration(
string subjectName,
string pkiRoot = null,
string appRoot = null,
string rejectedRoot = null);
/// <summary>
/// Add the security configuration.
/// </summary>
/// <remarks>
/// The pki root path default to the certificate store
/// location as defined in <see cref="CertificateStoreIdentifier.DefaultPKIRoot"/>
/// A <see cref="CertificateStoreType"/> defaults to the corresponding default store location.
/// </remarks>
/// <param name="certIdList">A list of Certificate identifiers</param>
/// <param name="pkiRoot">The path to the pki root. By default all cert stores use the pki root.</param>
/// <param name="rejectedRoot">The path to the rejected certificate store.</param>
IApplicationConfigurationBuilderSecurityOptions AddSecurityConfiguration(
CertificateIdentifierCollection certIdList,
string pkiRoot = null,
string rejectedRoot = null);
/// <summary>
/// Add the security configuration for mandatory application, issuer and trusted stores.
/// </summary>
/// <param name="subjectName">Application certificate subject name as distinguished name.
/// A DC=localhost entry is converted to the hostname. The common name CN= is mandatory.</param>
/// <param name="appRoot">The path to the app cert store.</param>
/// <param name="trustedRoot">The path to the trusted cert store.</param>
/// <param name="issuerRoot">The path to the issuer cert store.</param>
/// <param name="rejectedRoot">The path to the rejected certificate store.</param>
IApplicationConfigurationBuilderSecurityOptionStores AddSecurityConfigurationStores(
string subjectName,
string appRoot,
string trustedRoot,
string issuerRoot,
string rejectedRoot = null);
}
/// <summary>
/// Add security options to the configuration.
/// </summary>
public interface IApplicationConfigurationBuilderSecurityOptionStores
: IApplicationConfigurationBuilderSecurityOptions
{
/// <summary>
/// Add the security configuration for the user certificate issuer and trusted stores.
/// </summary>
/// <param name="trustedRoot">The path to the trusted cert store.</param>
/// <param name="issuerRoot">The path to the issuer cert store.</param>
IApplicationConfigurationBuilderSecurityOptionStores AddSecurityConfigurationUserStore(
string trustedRoot,
string issuerRoot);
/// <summary>
/// Add the security configuration for the https certificate issuer and trusted stores.
/// </summary>
/// <param name="trustedRoot">The path to the trusted cert store.</param>
/// <param name="issuerRoot">The path to the issuer cert store.</param>
IApplicationConfigurationBuilderSecurityOptionStores AddSecurityConfigurationHttpsStore(
string trustedRoot,
string issuerRoot);
}
/// <summary>
/// Add security options to the configuration.
/// </summary>
public interface IApplicationConfigurationBuilderSecurityOptions
: IApplicationConfigurationBuilderGlobalConfiguration,
IApplicationConfigurationBuilderExtension
{
/// <summary>
/// The certificate types that should be supported.
/// </summary>
/// <remarks>
/// At this time the following types are supported, if the platform OS and .NET version can handle it.
/// Rsa,nistP256,nistP384,brainpoolP256r1,brainpoolP384r1
/// </remarks>
/// <param name="certIdList">A list of Certificate identifiers</param>
IApplicationConfigurationBuilderSecurityOptions SetApplicationCertificates(
CertificateIdentifierCollection certIdList);
/// <summary>
/// The number of rejected certificates to keep in the store.
/// </summary>
/// <param name="maxRejectedCertificates">
/// The number of certificates to keep in the rejected store before it is updated.
/// <see langword="0"/> to keep all rejected certificates.
/// A negative number to keep no history.
/// </param>
IApplicationConfigurationBuilderSecurityOptions SetMaxRejectedCertificates(
int maxRejectedCertificates);
/// <summary>
/// Whether an unknown application certificate should be accepted
/// once all other security checks passed.
/// </summary>
/// <param name="autoAccept"><see langword="true"/> to accept unknown application certificates.</param>
IApplicationConfigurationBuilderSecurityOptions SetAutoAcceptUntrustedCertificates(
bool autoAccept);
/// <summary>
/// Whether a newly created application certificate should be added to the trusted store.
/// This function is only useful if multiple UA applications share the same trusted store.
/// </summary>
/// <param name="addToTrustedStore"><see langword="true"/> to add the cert to the trusted store.</param>
IApplicationConfigurationBuilderSecurityOptions SetAddAppCertToTrustedStore(
bool addToTrustedStore);
/// <summary>
/// Reject SHA1 signed certificates.
/// </summary>
/// <param name="rejectSHA1Signed"><see langword="false"/> to accept SHA1 signed certificates.</param>
IApplicationConfigurationBuilderSecurityOptions SetRejectSHA1SignedCertificates(
bool rejectSHA1Signed);
/// <summary>
/// Reject chain validation with CA certs with unknown revocation status,
/// e.g. when the CRL is not available or the OCSP provider is offline.
/// </summary>
/// <param name="rejectUnknownRevocationStatus"><see langword="false"/> to accept CA certs with unknown revocation status.</param>
IApplicationConfigurationBuilderSecurityOptions SetRejectUnknownRevocationStatus(
bool rejectUnknownRevocationStatus);
/// <summary>
/// Use the validated certificates for fast Validation.
/// </summary>
/// <param name="useValidatedCertificates"><see langword="true"/> to use the validated certificates.</param>
IApplicationConfigurationBuilderSecurityOptions SetUseValidatedCertificates(
bool useValidatedCertificates);
/// <summary>
/// Whether to suppress errors which are caused by clients and servers which provide
/// zero nonce values or nonce with insufficient entropy.
/// Suppressing this error is a security risk and may allow an attacker to decrypt user tokens.
/// Only use if interoperability issues with legacy servers or clients leave no other choice to operate.
/// </summary>
/// <param name="suppressNonceValidationErrors"><see langword="true"/> to suppress nonce validation errors.</param>
IApplicationConfigurationBuilderSecurityOptions SetSuppressNonceValidationErrors(
bool suppressNonceValidationErrors);
/// <summary>
/// Whether to reject certificates with an ApplicationUri that does not match the configuration.
/// If set to true, an exception will be thrown when the ApplicationUri in the configuration
/// does not match the ApplicationUri in the certificate.
/// If set to false (default), the configuration ApplicationUri will be updated to match the certificate for backward compatibility.
/// </summary>
/// <param name="rejectCertificateUriMismatch"><see langword="true"/> to reject certificates with mismatched ApplicationUri.</param>
IApplicationConfigurationBuilderSecurityOptions SetRejectCertificateUriMismatch(
bool rejectCertificateUriMismatch);
/// <summary>
/// Whether a certificate chain should be sent with the application certificate.
/// Only used if the application certificate is CA signed.
/// </summary>
/// <param name="sendCertificateChain"><see langword="true"/> to send the certificate chain with the application certificate.</param>
IApplicationConfigurationBuilderSecurityOptions SetSendCertificateChain(
bool sendCertificateChain);
/// <summary>
/// The minimum RSA key size to accept.
/// By default the key size is set to <see cref="CertificateFactory.DefaultKeySize"/>.
/// </summary>
/// <param name="keySize">The minimum RSA key size to accept.</param>
IApplicationConfigurationBuilderSecurityOptions SetMinimumCertificateKeySize(
ushort keySize);
/// <summary>
/// Add a certificate password provider.
/// </summary>
/// <param name="certificatePasswordProvider">The certificate password provider to use.</param>
IApplicationConfigurationBuilderSecurityOptions AddCertificatePasswordProvider(
ICertificatePasswordProvider certificatePasswordProvider);
}
/// <summary>
/// Add extensions configuration.
/// </summary>
public interface IApplicationConfigurationBuilderExtension : IApplicationConfigurationBuilderTraceConfiguration
{
/// <summary>
/// Add an extension to the configuration.
/// </summary>
/// <typeparam name="T">The type of the object to add as an extension.</typeparam>
/// <param name="elementName">The name of the extension, null to use the name.</param>
/// <param name="value">The object to add and encode.</param>
IApplicationConfigurationBuilderExtension AddExtension<T>(
XmlQualifiedName elementName,
object value);
}
/// <summary>
/// Add some global configuration settings.
/// </summary>
public interface IApplicationConfigurationBuilderGlobalConfiguration
: IApplicationConfigurationBuilderCreate,
IApplicationConfigurationBuilderTraceConfiguration
{
/// <summary>
/// Set the high resolution clock to disabled or enabled.
/// </summary>
/// <param name="hiResClockDisabled"><value><c>true</c> if high resolution clock is disabled; otherwise, <c>false</c>.</value></param>
IApplicationConfigurationBuilderGlobalConfiguration SetHiResClockDisabled(
bool hiResClockDisabled);
}
/// <summary>
/// Add the trace configuration.
/// </summary>
public interface IApplicationConfigurationBuilderTraceConfiguration : IApplicationConfigurationBuilderCreate
{
/// <inheritdoc cref="TraceConfiguration.OutputFilePath"/>
IApplicationConfigurationBuilderTraceConfiguration SetOutputFilePath(string outputFilePath);
/// <inheritdoc cref="TraceConfiguration.DeleteOnLoad"/>
IApplicationConfigurationBuilderTraceConfiguration SetDeleteOnLoad(bool deleteOnLoad);
/// <inheritdoc cref="TraceConfiguration.TraceMasks"/>
IApplicationConfigurationBuilderTraceConfiguration SetTraceMasks(int traceMasks);
}
/// <summary>
/// Create and validate the application configuration.
/// </summary>
public interface IApplicationConfigurationBuilderCreate
{
/// <summary>
/// Creates and updates the application configuration.
/// </summary>
Task<ApplicationConfiguration> CreateAsync(CancellationToken ct = default);
}
}