Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MTlsPort.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
5using Waher.Things;
8
10{
15 {
19 public MTlsPort()
20 : base(null, null)
21 {
22 this.ClientCertificates = ClientCertificates.NotUsed;
23 this.TrustClientCertificates = false;
24 this.PortNumber = 0;
25 }
26
36 : base(Source, Parent)
37 {
38 this.PortNumber = PortNumber;
39 this.ClientCertificates = ClientCertificates;
40 this.TrustClientCertificates = TrustCertificates;
41 }
42
46 [Page(7, "Configuration")]
47 [Header(41, "Port Number:")]
48 [ToolTip(106, "mTLS-configuration specific for this port number.")]
49 [Range(1, 65535)]
50 [Text(TextPosition.AfterField, 63, "Note: Changes will take effect after broker has been restarted.")]
51 [Required]
52 public int PortNumber { get; set; }
53
57 [Page(7, "Configuration")]
58 [Header(14, "Client Certificates (mTLS):")]
59 [ToolTip(15, "How to allow clients authenticate themselves using X.509 certificates.")]
60 [Required]
61 [Option(ClientCertificates.NotUsed, 16, "Client certificates are not used, and will not be requested.")]
62 [Option(ClientCertificates.Optional, 17, "Client certificates are requested, but not required.")]
63 [Option(ClientCertificates.Required, 18, "Client certificates are requested, and required.")]
65
69 [Page(7, "Configuration")]
70 [Header(19, "Trust client certificates.")]
71 [ToolTip(20, "If client certificates should be trusted, even if they don't validate.")]
72 public bool TrustClientCertificates { get; set; }
73
77 public override string NodeId => "mTLS " + this.PortNumber.ToString();
78
83 public override Task<string> GetTypeNameAsync(Language Language) => Language.GetStringAsync(typeof(GatewayConfigSource), 45, "Port Number (mTLS)");
84
90 public override Task<bool> AcceptsParentAsync(INode Parent)
91 {
92 return Task.FromResult(Parent is WebServer);
93 }
94
101 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
102 {
103 LinkedList<Parameter> Parameters = new LinkedList<Parameter>();
105
106 Parameters.AddLast(new StringParameter("Protocol", await Namespace.GetStringAsync(108, "Certificates"), this.ClientCertificates.ToString()));
107 Parameters.AddLast(new BooleanParameter("Trust", await Namespace.GetStringAsync(109, "Trust"), this.TrustClientCertificates));
108
109 return Parameters;
110 }
111 }
112}
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
async Task< Namespace > GetNamespaceAsync(string Name)
Gets the namespace object, given its name, if available.
Definition: Language.cs:99
Contains information about a namespace in a language.
Definition: Namespace.cs:17
Task< LanguageString > GetStringAsync(int Id)
Gets the string object, given its ID, if available.
Definition: Namespace.cs:65
Abstract base class for gateway configuration nodes.
virtual INode Parent
Parent Node, or null if a root node.
GatewayConfigSource Source
Source hosting the node.
mTLS-configuration for a specific port number.
Definition: MTlsPort.cs:15
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
Definition: MTlsPort.cs:101
MTlsPort(GatewayConfigSource Source, WebServer Parent, int PortNumber, ClientCertificates ClientCertificates, bool TrustCertificates)
References a port number.
Definition: MTlsPort.cs:35
bool TrustClientCertificates
If certificates are to be trusted, or if they are required to be valid.
Definition: MTlsPort.cs:72
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
Definition: MTlsPort.cs:90
MTlsPort()
mTLS-configuration for a specific port number.
Definition: MTlsPort.cs:19
override Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
ClientCertificates ClientCertificates
mTLS-configuration
Definition: MTlsPort.cs:64
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
ClientCertificates
Client Certificate Options
TextPosition
Where the instructions are to be place.
Definition: TextAttribute.cs:9