| | | 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 | | using System.Collections.ObjectModel; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Security |
| | | 8 | | { |
| | | 9 | | public sealed class SecureConversationServiceCredential |
| | | 10 | | { |
| | 6 | 11 | | private static readonly SecurityStateEncoder s_defaultSecurityStateEncoder = new DataProtectionSecurityStateEnco |
| | | 12 | | private SecurityStateEncoder _securityStateEncoder; |
| | | 13 | | private bool _isReadOnly; |
| | | 14 | | |
| | 52 | 15 | | internal SecureConversationServiceCredential() |
| | | 16 | | { |
| | 52 | 17 | | _securityStateEncoder = s_defaultSecurityStateEncoder; |
| | 52 | 18 | | SecurityContextClaimTypes = new Collection<Type>(); |
| | | 19 | | // SamlAssertion.AddSamlClaimTypes(securityContextClaimTypes); |
| | 52 | 20 | | } |
| | | 21 | | |
| | 66 | 22 | | internal SecureConversationServiceCredential(SecureConversationServiceCredential other) |
| | | 23 | | { |
| | 66 | 24 | | _securityStateEncoder = other._securityStateEncoder; |
| | 66 | 25 | | SecurityContextClaimTypes = new Collection<Type>(); |
| | 132 | 26 | | for (int i = 0; i < other.SecurityContextClaimTypes.Count; ++i) |
| | | 27 | | { |
| | 0 | 28 | | SecurityContextClaimTypes.Add(other.SecurityContextClaimTypes[i]); |
| | | 29 | | } |
| | 66 | 30 | | _isReadOnly = other._isReadOnly; |
| | 66 | 31 | | } |
| | | 32 | | |
| | | 33 | | public SecurityStateEncoder SecurityStateEncoder |
| | | 34 | | { |
| | | 35 | | get |
| | | 36 | | { |
| | 79 | 37 | | return _securityStateEncoder; |
| | | 38 | | } |
| | | 39 | | set |
| | | 40 | | { |
| | 0 | 41 | | ThrowIfImmutable(); |
| | 0 | 42 | | _securityStateEncoder = value; |
| | 0 | 43 | | } |
| | | 44 | | } |
| | | 45 | | |
| | 145 | 46 | | public Collection<Type> SecurityContextClaimTypes { get; } |
| | | 47 | | |
| | | 48 | | internal void MakeReadOnly() |
| | | 49 | | { |
| | 0 | 50 | | _isReadOnly = true; |
| | 0 | 51 | | } |
| | | 52 | | |
| | | 53 | | private void ThrowIfImmutable() |
| | | 54 | | { |
| | 0 | 55 | | if (_isReadOnly) |
| | | 56 | | { |
| | 0 | 57 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.ObjectIsReadO |
| | | 58 | | } |
| | 0 | 59 | | } |
| | | 60 | | } |
| | | 61 | | } |