| | | 1 | | /* |
| | | 2 | | * Copyright 2018 Stanislav Muhametsin. All rights Reserved. |
| | | 3 | | * |
| | | 4 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | 5 | | * you may not use this file except in compliance with the License. |
| | | 6 | | * You may obtain a copy of the License at |
| | | 7 | | * |
| | | 8 | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | 9 | | * |
| | | 10 | | * Unless required by applicable law or agreed to in writing, software |
| | | 11 | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | 12 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| | | 13 | | * implied. |
| | | 14 | | * |
| | | 15 | | * See the License for the specific language governing permissions and |
| | | 16 | | * limitations under the License. |
| | | 17 | | */ |
| | | 18 | | using IOUtils.Network.Configuration; |
| | | 19 | | using System; |
| | | 20 | | using System.Text; |
| | | 21 | | |
| | | 22 | | namespace CBAM.NATS |
| | | 23 | | { |
| | | 24 | | |
| | | 25 | | public sealed class NATSConnectionCreationInfo : NetworkConnectionCreationInfo<NATSConnectionCreationInfoData, NATSCo |
| | | 26 | | { |
| | | 27 | | public NATSConnectionCreationInfo( NATSConnectionCreationInfoData data ) |
| | 2 | 28 | | : base( data ) |
| | | 29 | | { |
| | 2 | 30 | | } |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | public sealed class NATSConnectionCreationInfoData : NetworkConnectionCreationInfoData<NATSConnectionConfiguration, N |
| | | 34 | | { |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | public sealed class NATSConnectionConfiguration : NetworkConnectionConfiguration |
| | | 38 | | { |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | public sealed class NATSInitializationConfiguration : NetworkInitializationConfiguration<NATSProtocolConfiguration, N |
| | | 42 | | { |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | public sealed class NATSProtocolConfiguration |
| | | 46 | | { |
| | | 47 | | public const Int32 DEFAULT_BUFFER_SIZE = 0x10000; |
| | | 48 | | |
| | | 49 | | public Boolean Verbose { get; set; } |
| | | 50 | | |
| | | 51 | | public Boolean Pedantic { get; set; } |
| | | 52 | | |
| | | 53 | | public String ClientName { get; set; } = "CBAM.NATS"; |
| | | 54 | | |
| | | 55 | | public String ClientLanguage { get; set; } = "CLR"; |
| | | 56 | | |
| | | 57 | | public String ClientVersion { get; set; } = "0.1"; |
| | | 58 | | |
| | | 59 | | public Int32 StreamBufferSize { get; set; } = DEFAULT_BUFFER_SIZE; |
| | | 60 | | } |
| | | 61 | | |
| | | 62 | | public sealed class NATSPoolingConfiguration : NetworkPoolingConfiguration |
| | | 63 | | { |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | public sealed class NATSAuthenticationConfiguration |
| | | 67 | | { |
| | | 68 | | internal static readonly Encoding PasswordByteEncoding = new UTF8Encoding( false, true ); |
| | | 69 | | |
| | | 70 | | private Byte[] _pwBytes; |
| | | 71 | | private Byte[] _tokenBytes; |
| | | 72 | | |
| | | 73 | | public String Username { get; set; } |
| | | 74 | | public String Password |
| | | 75 | | { |
| | | 76 | | get |
| | | 77 | | { |
| | | 78 | | var arr = this._pwBytes; |
| | | 79 | | return arr == null ? null : PasswordByteEncoding.GetString( arr, 0, arr.Length ); |
| | | 80 | | } |
| | | 81 | | set |
| | | 82 | | { |
| | | 83 | | this._pwBytes = value == null ? null : PasswordByteEncoding.GetBytes( value ); |
| | | 84 | | } |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | public String AuthenticationToken |
| | | 88 | | { |
| | | 89 | | get |
| | | 90 | | { |
| | | 91 | | var arr = this._tokenBytes; |
| | | 92 | | return arr == null ? null : PasswordByteEncoding.GetString( arr, 0, arr.Length ); |
| | | 93 | | } |
| | | 94 | | set |
| | | 95 | | { |
| | | 96 | | this._tokenBytes = value == null ? null : PasswordByteEncoding.GetBytes( value ); |
| | | 97 | | } |
| | | 98 | | } |
| | | 99 | | } |
| | | 100 | | } |