| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | |
| | | 6 | | namespace CoreWCF.Security |
| | | 7 | | { |
| | | 8 | | public sealed class WindowsServiceCredential |
| | | 9 | | { |
| | | 10 | | private bool _allowAnonymousLogons = SspiSecurityTokenProvider.DefaultAllowUnauthenticatedCallers; |
| | 118 | 11 | | private bool _includeWindowsGroups = SspiSecurityTokenProvider.DefaultExtractWindowsGroupClaims; |
| | | 12 | | private bool _isReadOnly; |
| | | 13 | | private LdapSettings _ldapSettings; |
| | | 14 | | |
| | 52 | 15 | | internal WindowsServiceCredential() |
| | | 16 | | { |
| | | 17 | | // empty |
| | 52 | 18 | | } |
| | | 19 | | |
| | 66 | 20 | | internal WindowsServiceCredential(WindowsServiceCredential other) |
| | | 21 | | { |
| | 66 | 22 | | _allowAnonymousLogons = other._allowAnonymousLogons; |
| | 66 | 23 | | _includeWindowsGroups = other._includeWindowsGroups; |
| | 66 | 24 | | _isReadOnly = other._isReadOnly; |
| | 66 | 25 | | _ldapSettings = other._ldapSettings; |
| | 66 | 26 | | } |
| | | 27 | | |
| | | 28 | | public bool AllowAnonymousLogons |
| | | 29 | | { |
| | | 30 | | get |
| | | 31 | | { |
| | 13 | 32 | | return _allowAnonymousLogons; |
| | | 33 | | } |
| | | 34 | | set |
| | | 35 | | { |
| | 0 | 36 | | ThrowIfImmutable(); |
| | 0 | 37 | | _allowAnonymousLogons = value; |
| | 0 | 38 | | } |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | public bool IncludeWindowsGroups |
| | | 42 | | { |
| | | 43 | | get |
| | | 44 | | { |
| | 13 | 45 | | return _includeWindowsGroups; |
| | | 46 | | } |
| | | 47 | | set |
| | | 48 | | { |
| | 0 | 49 | | ThrowIfImmutable(); |
| | 0 | 50 | | _includeWindowsGroups = value; |
| | 0 | 51 | | } |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | public LdapSettings LdapSetting |
| | | 55 | | { |
| | | 56 | | get |
| | | 57 | | { |
| | 13 | 58 | | return _ldapSettings; |
| | | 59 | | } |
| | | 60 | | set |
| | | 61 | | { |
| | 9 | 62 | | ThrowIfImmutable(); |
| | 9 | 63 | | value.Validate(); |
| | 9 | 64 | | _ldapSettings = value; |
| | 9 | 65 | | } |
| | | 66 | | } |
| | | 67 | | |
| | | 68 | | |
| | | 69 | | internal void MakeReadOnly() |
| | | 70 | | { |
| | 0 | 71 | | _isReadOnly = true; |
| | 0 | 72 | | } |
| | | 73 | | |
| | | 74 | | private void ThrowIfImmutable() |
| | | 75 | | { |
| | 9 | 76 | | if (_isReadOnly) |
| | | 77 | | { |
| | 0 | 78 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO |
| | | 79 | | } |
| | 9 | 80 | | } |
| | | 81 | | } |
| | | 82 | | } |