| | | 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 | | using CoreWCF.IdentityModel.Selectors; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.Security |
| | | 9 | | { |
| | | 10 | | internal sealed class MessageSecurityTokenVersion : SecurityTokenVersion |
| | | 11 | | { |
| | | 12 | | private readonly string _toString; |
| | | 13 | | private readonly ReadOnlyCollection<string> _supportedSpecs; |
| | | 14 | | private const string bsp10ns = @"http://ws-i.org/profiles/basic-security/core/1.0"; |
| | 3 | 15 | | private static readonly MessageSecurityTokenVersion s_wss10oasisdec2005bsp10 = new MessageSecurityTokenVersion( |
| | 3 | 16 | | SecurityVersion.WSSecurity10, |
| | 3 | 17 | | TrustVersion.WSTrust13, |
| | 3 | 18 | | SecureConversationVersion.WSSecureConversation13, |
| | 3 | 19 | | "WSSecurity10WSTrust13WSSecureConversation13BasicSecurityProfile10", |
| | 3 | 20 | | true, |
| | 3 | 21 | | XD.SecurityXXX2005Dictionary.Namespace.Value, |
| | 3 | 22 | | DXD.TrustDec2005Dictionary.Namespace.Value, |
| | 3 | 23 | | DXD.SecureConversationDec2005Dictionary.Namespace.Value |
| | 3 | 24 | | ); |
| | 3 | 25 | | private static readonly MessageSecurityTokenVersion s_wss11oasisdec2005 = new MessageSecurityTokenVersion( |
| | 3 | 26 | | SecurityVersion.WSSecurity11, |
| | 3 | 27 | | TrustVersion.WSTrust13, |
| | 3 | 28 | | SecureConversationVersion.WSSecureConversation13, |
| | 3 | 29 | | "WSSecurity11WSTrust13WSSecureConversation13", |
| | 3 | 30 | | false, |
| | 3 | 31 | | XD.SecurityJan2004Dictionary.Namespace.Value, |
| | 3 | 32 | | DXD.TrustDec2005Dictionary.Namespace.Value, |
| | 3 | 33 | | DXD.SecureConversationDec2005Dictionary.Namespace.Value |
| | 3 | 34 | | ); |
| | 3 | 35 | | private static readonly MessageSecurityTokenVersion s_wss11oasisdec2005bsp10 = new MessageSecurityTokenVersion( |
| | 3 | 36 | | SecurityVersion.WSSecurity11, |
| | 3 | 37 | | TrustVersion.WSTrust13, |
| | 3 | 38 | | SecureConversationVersion.WSSecureConversation13, |
| | 3 | 39 | | "WSSecurity11WSTrust13WSSecureConversation13BasicSecurityProfile10", |
| | 3 | 40 | | true, |
| | 3 | 41 | | XD.SecurityXXX2005Dictionary.Namespace.Value, |
| | 3 | 42 | | DXD.TrustDec2005Dictionary.Namespace.Value, |
| | 3 | 43 | | DXD.SecureConversationDec2005Dictionary.Namespace.Value |
| | 3 | 44 | | ); |
| | | 45 | | |
| | 180 | 46 | | public static MessageSecurityTokenVersion WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005 { get; |
| | 3 | 47 | | SecurityVersion.WSSecurity11, |
| | 3 | 48 | | TrustVersion.WSTrustFeb2005, |
| | 3 | 49 | | SecureConversationVersion.WSSecureConversationFeb2005, |
| | 3 | 50 | | "WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005", |
| | 3 | 51 | | false, |
| | 3 | 52 | | XD.SecurityXXX2005Dictionary.Namespace.Value, |
| | 3 | 53 | | XD.TrustFeb2005Dictionary.Namespace.Value, |
| | 3 | 54 | | XD.SecureConversationFeb2005Dictionary.Namespace.Value); |
| | | 55 | | |
| | 421 | 56 | | public static MessageSecurityTokenVersion WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005BasicSe |
| | 3 | 57 | | SecurityVersion.WSSecurity11, |
| | 3 | 58 | | TrustVersion.WSTrustFeb2005, |
| | 3 | 59 | | SecureConversationVersion.WSSecureConversationFeb2005, |
| | 3 | 60 | | "WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005BasicSecurityProfile10", |
| | 3 | 61 | | true, |
| | 3 | 62 | | XD.SecurityXXX2005Dictionary.Namespace.Value, |
| | 3 | 63 | | XD.TrustFeb2005Dictionary.Namespace.Value, |
| | 3 | 64 | | XD.SecureConversationFeb2005Dictionary.Namespace.Value, |
| | 3 | 65 | | bsp10ns); |
| | | 66 | | |
| | 89 | 67 | | public static MessageSecurityTokenVersion WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005BasicSe |
| | 3 | 68 | | SecurityVersion.WSSecurity10, |
| | 3 | 69 | | TrustVersion.WSTrustFeb2005, |
| | 3 | 70 | | SecureConversationVersion.WSSecureConversationFeb2005, |
| | 3 | 71 | | "WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005BasicSecurityProfile10", |
| | 3 | 72 | | true, |
| | 3 | 73 | | XD.SecurityJan2004Dictionary.Namespace.Value, |
| | 3 | 74 | | XD.TrustFeb2005Dictionary.Namespace.Value, |
| | 3 | 75 | | XD.SecureConversationFeb2005Dictionary.Namespace.Value, |
| | 3 | 76 | | bsp10ns); |
| | | 77 | | |
| | | 78 | | public static MessageSecurityTokenVersion WSSecurity10WSTrust13WSSecureConversation13BasicSecurityProfile10 |
| | | 79 | | { |
| | | 80 | | get |
| | | 81 | | { |
| | 5 | 82 | | return s_wss10oasisdec2005bsp10; |
| | | 83 | | } |
| | | 84 | | } |
| | | 85 | | |
| | | 86 | | public static MessageSecurityTokenVersion WSSecurity11WSTrust13WSSecureConversation13 |
| | | 87 | | { |
| | | 88 | | get |
| | | 89 | | { |
| | 5 | 90 | | return s_wss11oasisdec2005; |
| | | 91 | | } |
| | | 92 | | } |
| | | 93 | | |
| | | 94 | | public static MessageSecurityTokenVersion WSSecurity11WSTrust13WSSecureConversation13BasicSecurityProfile10 |
| | | 95 | | { |
| | | 96 | | get |
| | | 97 | | { |
| | 810 | 98 | | return s_wss11oasisdec2005bsp10; |
| | | 99 | | } |
| | | 100 | | } |
| | | 101 | | |
| | | 102 | | public static MessageSecurityTokenVersion GetSecurityTokenVersion(SecurityVersion version, bool emitBspAttribute |
| | | 103 | | { |
| | 0 | 104 | | if (version == SecurityVersion.WSSecurity10) |
| | | 105 | | { |
| | 0 | 106 | | if (emitBspAttributes) |
| | | 107 | | { |
| | 0 | 108 | | return WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005BasicSecurityProfile10; |
| | | 109 | | } |
| | | 110 | | else |
| | | 111 | | { |
| | 0 | 112 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); |
| | | 113 | | } |
| | | 114 | | } |
| | 0 | 115 | | else if (version == SecurityVersion.WSSecurity11) |
| | | 116 | | { |
| | 0 | 117 | | if (emitBspAttributes) |
| | | 118 | | { |
| | 0 | 119 | | return WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005BasicSecurityProfile10; |
| | | 120 | | } |
| | | 121 | | else |
| | | 122 | | { |
| | 0 | 123 | | return WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005; |
| | | 124 | | } |
| | | 125 | | } |
| | | 126 | | else |
| | | 127 | | { |
| | 0 | 128 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); |
| | | 129 | | } |
| | | 130 | | } |
| | | 131 | | |
| | | 132 | | private MessageSecurityTokenVersion(SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversati |
| | 18 | 133 | | : base() |
| | | 134 | | { |
| | 18 | 135 | | EmitBspRequiredAttributes = emitBspRequiredAttributes; |
| | 18 | 136 | | _supportedSpecs = new ReadOnlyCollection<string>(supportedSpecs); |
| | 18 | 137 | | _toString = toString; |
| | 18 | 138 | | SecurityVersion = securityVersion; |
| | 18 | 139 | | TrustVersion = trustVersion; |
| | 18 | 140 | | SecureConversationVersion = secureConversationVersion; |
| | 18 | 141 | | } |
| | | 142 | | |
| | 76 | 143 | | public bool EmitBspRequiredAttributes { get; } |
| | | 144 | | |
| | 911 | 145 | | public SecurityVersion SecurityVersion { get; } |
| | | 146 | | |
| | 327 | 147 | | public TrustVersion TrustVersion { get; } |
| | | 148 | | |
| | 257 | 149 | | public SecureConversationVersion SecureConversationVersion { get; } |
| | | 150 | | |
| | | 151 | | public override ReadOnlyCollection<string> GetSecuritySpecifications() |
| | | 152 | | { |
| | 2 | 153 | | return _supportedSpecs; |
| | | 154 | | } |
| | | 155 | | |
| | | 156 | | public override string ToString() |
| | | 157 | | { |
| | 0 | 158 | | return _toString; |
| | | 159 | | } |
| | | 160 | | } |
| | | 161 | | } |