| | | 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 CoreWCF.Channels; |
| | | 5 | | using CoreWCF.Diagnostics; |
| | | 6 | | using CoreWCF.Dispatcher; |
| | | 7 | | using CoreWCF.IdentityModel; |
| | | 8 | | using CoreWCF.IdentityModel.Policy; |
| | | 9 | | using CoreWCF.Runtime; |
| | | 10 | | using CoreWCF.Security.Tokens; |
| | | 11 | | using System; |
| | | 12 | | using System.Collections.Generic; |
| | | 13 | | using System.Collections.ObjectModel; |
| | | 14 | | using System.IO; |
| | | 15 | | using System.Runtime.Serialization; |
| | | 16 | | using System.Security.Authentication.ExtendedProtection; |
| | | 17 | | using System.Security.Cryptography; |
| | | 18 | | using System.Threading.Tasks; |
| | | 19 | | using System.Xml; |
| | | 20 | | using CanonicalizationDriver = CoreWCF.IdentityModel.CanonicalizationDriver; |
| | | 21 | | using Psha1DerivedKeyGenerator = CoreWCF.IdentityModel.Psha1DerivedKeyGenerator; |
| | | 22 | | |
| | | 23 | | namespace CoreWCF.Security |
| | | 24 | | { |
| | | 25 | | internal abstract class SspiNegotiationTokenAuthenticator : NegotiationTokenAuthenticator<SspiNegotiationTokenAuthen |
| | | 26 | | { |
| | | 27 | | private string _defaultServiceBinding; |
| | | 28 | | |
| | | 29 | | protected SspiNegotiationTokenAuthenticator() |
| | 1 | 30 | | : base() |
| | | 31 | | { |
| | 1 | 32 | | } |
| | | 33 | | |
| | 1 | 34 | | public ExtendedProtectionPolicy ExtendedProtectionPolicy { get; set; } |
| | | 35 | | |
| | 1 | 36 | | protected object ThisLock { get; } = new object(); |
| | | 37 | | |
| | | 38 | | public string DefaultServiceBinding |
| | | 39 | | { |
| | | 40 | | get |
| | | 41 | | { |
| | 0 | 42 | | if (_defaultServiceBinding == null) |
| | | 43 | | { |
| | 0 | 44 | | lock (ThisLock) |
| | | 45 | | { |
| | 0 | 46 | | if (_defaultServiceBinding == null) |
| | | 47 | | { |
| | 0 | 48 | | _defaultServiceBinding = SecurityUtils.GetSpnFromIdentity( |
| | 0 | 49 | | SecurityUtils.CreateWindowsIdentity(), |
| | 0 | 50 | | new EndpointAddress(ListenUri)); |
| | | 51 | | } |
| | 0 | 52 | | } |
| | | 53 | | } |
| | | 54 | | |
| | 0 | 55 | | return _defaultServiceBinding; |
| | | 56 | | } |
| | 0 | 57 | | set { _defaultServiceBinding = value; } |
| | | 58 | | } |
| | | 59 | | |
| | | 60 | | // abstract methods |
| | | 61 | | public abstract XmlDictionaryString NegotiationValueType { get; } |
| | | 62 | | protected abstract ValueTask<ReadOnlyCollection<IAuthorizationPolicy>> ValidateSspiNegotiationAsync(ISspiNegotia |
| | | 63 | | protected abstract SspiNegotiationTokenAuthenticatorState CreateSspiState(byte[] incomingBlob, string incomingVa |
| | | 64 | | |
| | | 65 | | // helpers |
| | | 66 | | protected virtual void IssueServiceToken(SspiNegotiationTokenAuthenticatorState sspiState, ReadOnlyCollection<IA |
| | | 67 | | out int issuedKeySize) |
| | | 68 | | { |
| | 0 | 69 | | UniqueId contextId = SecurityUtils.GenerateUniqueId(); |
| | 0 | 70 | | string id = SecurityUtils.GenerateId(); |
| | 0 | 71 | | if (sspiState.RequestedKeySize == 0) |
| | | 72 | | { |
| | 0 | 73 | | issuedKeySize = SecurityAlgorithmSuite.DefaultSymmetricKeyLength; |
| | | 74 | | } |
| | | 75 | | else |
| | | 76 | | { |
| | 0 | 77 | | issuedKeySize = sspiState.RequestedKeySize; |
| | | 78 | | } |
| | 0 | 79 | | byte[] key = new byte[issuedKeySize / 8]; |
| | 0 | 80 | | CryptoHelper.FillRandomBytes(key); |
| | 0 | 81 | | DateTime effectiveTime = DateTime.UtcNow; |
| | 0 | 82 | | DateTime expirationTime = TimeoutHelper.Add(effectiveTime, ServiceTokenLifetime); |
| | 0 | 83 | | serviceToken = IssueSecurityContextToken(contextId, id, key, effectiveTime, expirationTime, authorizationPol |
| | 0 | 84 | | proofToken = new WrappedKeySecurityToken(string.Empty, key, sspiState.SspiNegotiation); |
| | 0 | 85 | | } |
| | | 86 | | |
| | | 87 | | protected virtual void ValidateIncomingBinaryNegotiation(BinaryNegotiation incomingNego) |
| | | 88 | | { |
| | 0 | 89 | | if (incomingNego == null) |
| | | 90 | | { |
| | 0 | 91 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityNegotiationException(SR.Format(SR. |
| | | 92 | | } |
| | 0 | 93 | | incomingNego.Validate(NegotiationValueType); |
| | 0 | 94 | | } |
| | | 95 | | |
| | | 96 | | protected virtual BinaryNegotiation GetOutgoingBinaryNegotiation(ISspiNegotiation sspiNegotiation, byte[] outgoi |
| | | 97 | | { |
| | 0 | 98 | | return new BinaryNegotiation(NegotiationValueType, outgoingBlob); |
| | | 99 | | } |
| | | 100 | | |
| | | 101 | | private static void AddToDigest(IncrementalHash negotiationDigest, Stream stream) |
| | | 102 | | { |
| | 0 | 103 | | stream.Flush(); |
| | 0 | 104 | | stream.Seek(0, SeekOrigin.Begin); |
| | 0 | 105 | | CanonicalizationDriver canonicalizer = new CanonicalizationDriver(); |
| | 0 | 106 | | canonicalizer.SetInput(stream); |
| | 0 | 107 | | byte[] canonicalizedData = canonicalizer.GetBytes(); |
| | 0 | 108 | | lock (negotiationDigest) |
| | | 109 | | { |
| | 0 | 110 | | negotiationDigest.AppendData(canonicalizedData); |
| | 0 | 111 | | } |
| | 0 | 112 | | } |
| | | 113 | | |
| | | 114 | | private static void AddToDigest(SspiNegotiationTokenAuthenticatorState sspiState, RequestSecurityToken rst) |
| | | 115 | | { |
| | 0 | 116 | | MemoryStream stream = new MemoryStream(); |
| | 0 | 117 | | XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream); |
| | 0 | 118 | | rst.RequestSecurityTokenXml.WriteTo(writer); |
| | 0 | 119 | | writer.Flush(); |
| | 0 | 120 | | AddToDigest(sspiState.NegotiationDigest, stream); |
| | 0 | 121 | | } |
| | | 122 | | |
| | | 123 | | private static void AddToDigest(SspiNegotiationTokenAuthenticatorState sspiState, RequestSecurityTokenResponse r |
| | | 124 | | { |
| | 0 | 125 | | MemoryStream stream = new MemoryStream(); |
| | 0 | 126 | | XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream); |
| | 0 | 127 | | if (wasReceived) |
| | | 128 | | { |
| | 0 | 129 | | rstr.RequestSecurityTokenResponseXml.WriteTo(writer); |
| | | 130 | | } |
| | | 131 | | else |
| | | 132 | | { |
| | 0 | 133 | | rstr.WriteTo(writer); |
| | | 134 | | } |
| | 0 | 135 | | writer.Flush(); |
| | 0 | 136 | | AddToDigest(sspiState.NegotiationDigest, stream); |
| | 0 | 137 | | } |
| | | 138 | | |
| | | 139 | | private static byte[] ComputeAuthenticator(SspiNegotiationTokenAuthenticatorState sspiState, byte[] key) |
| | | 140 | | { |
| | | 141 | | byte[] negotiationHash; |
| | 0 | 142 | | lock (sspiState.NegotiationDigest) |
| | | 143 | | { |
| | 0 | 144 | | negotiationHash = sspiState.NegotiationDigest.GetHashAndReset(); |
| | 0 | 145 | | } |
| | 0 | 146 | | Psha1DerivedKeyGenerator generator = new Psha1DerivedKeyGenerator(key); |
| | 0 | 147 | | return generator.GenerateDerivedKey(SecurityUtils.CombinedHashLabel, negotiationHash, 256, 0); |
| | | 148 | | } |
| | | 149 | | |
| | | 150 | | // overrides |
| | | 151 | | protected override bool IsMultiLegNegotiation |
| | | 152 | | { |
| | | 153 | | get |
| | | 154 | | { |
| | 0 | 155 | | return true; |
| | | 156 | | } |
| | | 157 | | } |
| | | 158 | | |
| | | 159 | | protected override Binding GetNegotiationBinding(Binding binding) |
| | | 160 | | { |
| | 0 | 161 | | return binding; |
| | | 162 | | } |
| | | 163 | | |
| | | 164 | | protected override MessageFilter GetListenerFilter() |
| | | 165 | | { |
| | 1 | 166 | | return new SspiNegotiationFilter(this); |
| | | 167 | | } |
| | | 168 | | |
| | | 169 | | protected override async ValueTask<(BodyWriter, SspiNegotiationTokenAuthenticatorState)> ProcessRequestSecurityT |
| | | 170 | | { |
| | 0 | 171 | | if (request == null) |
| | | 172 | | { |
| | 0 | 173 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(request)); |
| | | 174 | | } |
| | 0 | 175 | | if (requestSecurityToken == null) |
| | | 176 | | { |
| | 0 | 177 | | throw TraceUtility.ThrowHelperArgumentNull(nameof(requestSecurityToken), request); |
| | | 178 | | } |
| | 0 | 179 | | if (requestSecurityToken.RequestType != null && requestSecurityToken.RequestType != StandardsManager.TrustDr |
| | | 180 | | { |
| | 0 | 181 | | throw TraceUtility.ThrowHelperWarning(new SecurityNegotiationException(SR.Format(SR.InvalidRstRequestTyp |
| | | 182 | | } |
| | 0 | 183 | | BinaryNegotiation incomingNego = requestSecurityToken.GetBinaryNegotiation(); |
| | 0 | 184 | | ValidateIncomingBinaryNegotiation(incomingNego); |
| | 0 | 185 | | SspiNegotiationTokenAuthenticatorState negotiationState = CreateSspiState(incomingNego.GetNegotiationData(), |
| | 0 | 186 | | AddToDigest(negotiationState, requestSecurityToken); |
| | 0 | 187 | | negotiationState.Context = requestSecurityToken.Context; |
| | 0 | 188 | | if (requestSecurityToken.KeySize != 0) |
| | | 189 | | { |
| | 0 | 190 | | WSTrust.Driver.ValidateRequestedKeySize(requestSecurityToken.KeySize, SecurityAlgorithmSuite); |
| | | 191 | | } |
| | 0 | 192 | | negotiationState.RequestedKeySize = requestSecurityToken.KeySize; |
| | | 193 | | string appliesToNamespace; |
| | | 194 | | string appliesToName; |
| | 0 | 195 | | requestSecurityToken.GetAppliesToQName(out appliesToName, out appliesToNamespace); |
| | 0 | 196 | | if (appliesToName == AddressingStrings.EndpointReference && appliesToNamespace == request.Version.Addressing |
| | | 197 | | { |
| | | 198 | | DataContractSerializer serializer; |
| | 0 | 199 | | if (request.Version.Addressing == AddressingVersion.WSAddressing10) |
| | | 200 | | { |
| | 0 | 201 | | serializer = DataContractSerializerDefaults.CreateSerializer(typeof(EndpointAddress10), DataContract |
| | 0 | 202 | | negotiationState.AppliesTo = requestSecurityToken.GetAppliesTo<EndpointAddress10>(serializer).ToEndp |
| | | 203 | | } |
| | 0 | 204 | | else if (request.Version.Addressing == AddressingVersion.WSAddressingAugust2004) |
| | | 205 | | { |
| | 0 | 206 | | serializer = DataContractSerializerDefaults.CreateSerializer(typeof(EndpointAddressAugust2004), Data |
| | 0 | 207 | | negotiationState.AppliesTo = requestSecurityToken.GetAppliesTo<EndpointAddressAugust2004>(serializer |
| | | 208 | | } |
| | | 209 | | else |
| | | 210 | | { |
| | 0 | 211 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( |
| | 0 | 212 | | new ProtocolException(SR.Format(SR.AddressingVersionNotSupported, request.Version.Addressing))); |
| | | 213 | | } |
| | | 214 | | |
| | 0 | 215 | | negotiationState.AppliesToSerializer = serializer; |
| | | 216 | | } |
| | 0 | 217 | | var bodyWriter = await ProcessNegotiationAsync(negotiationState, request, incomingNego); |
| | 0 | 218 | | return (bodyWriter, negotiationState); |
| | 0 | 219 | | } |
| | | 220 | | |
| | | 221 | | protected override ValueTask<BodyWriter> ProcessRequestSecurityTokenResponseAsync(SspiNegotiationTokenAuthentica |
| | | 222 | | { |
| | 0 | 223 | | if (request == null) |
| | | 224 | | { |
| | 0 | 225 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(request)); |
| | | 226 | | } |
| | 0 | 227 | | if (requestSecurityTokenResponse == null) |
| | | 228 | | { |
| | 0 | 229 | | throw TraceUtility.ThrowHelperArgumentNull(nameof(requestSecurityTokenResponse), request); |
| | | 230 | | } |
| | 0 | 231 | | if (requestSecurityTokenResponse.Context != negotiationState.Context) |
| | | 232 | | { |
| | 0 | 233 | | throw TraceUtility.ThrowHelperError(new SecurityNegotiationException(SR.Format(SR.BadSecurityNegotiation |
| | | 234 | | } |
| | 0 | 235 | | AddToDigest(negotiationState, requestSecurityTokenResponse, true); |
| | 0 | 236 | | BinaryNegotiation incomingNego = requestSecurityTokenResponse.GetBinaryNegotiation(); |
| | 0 | 237 | | ValidateIncomingBinaryNegotiation(incomingNego); |
| | 0 | 238 | | return ProcessNegotiationAsync(negotiationState, request, incomingNego); |
| | | 239 | | } |
| | | 240 | | |
| | | 241 | | private async ValueTask<BodyWriter> ProcessNegotiationAsync(SspiNegotiationTokenAuthenticatorState negotiationSt |
| | | 242 | | { |
| | 0 | 243 | | ISspiNegotiation sspiNegotiation = negotiationState.SspiNegotiation; |
| | | 244 | | |
| | 0 | 245 | | byte[] outgoingBlob = sspiNegotiation.GetOutgoingBlob(incomingNego.GetNegotiationData(), |
| | 0 | 246 | | SecurityUtils.GetChannelBindingFromMessage(incomingMessage), |
| | 0 | 247 | | ExtendedProtectionPolicy); |
| | | 248 | | |
| | 0 | 249 | | if (sspiNegotiation.IsValidContext == false) |
| | | 250 | | { |
| | 0 | 251 | | throw TraceUtility.ThrowHelperError(new SecurityNegotiationException(SR.Format(SR.InvalidSspiNegotiation |
| | | 252 | | } |
| | | 253 | | // if there is no blob to send back the nego must be complete from the server side |
| | 0 | 254 | | if (outgoingBlob == null && sspiNegotiation.IsCompleted == false) |
| | | 255 | | { |
| | 0 | 256 | | throw TraceUtility.ThrowHelperError(new SecurityNegotiationException(SR.Format(SR.NoBinaryNegoToSend)), |
| | | 257 | | } |
| | | 258 | | BinaryNegotiation outgoingBinaryNegotiation; |
| | 0 | 259 | | if (outgoingBlob != null) |
| | | 260 | | { |
| | 0 | 261 | | outgoingBinaryNegotiation = GetOutgoingBinaryNegotiation(sspiNegotiation, outgoingBlob); |
| | | 262 | | } |
| | | 263 | | else |
| | | 264 | | { |
| | 0 | 265 | | outgoingBinaryNegotiation = null; |
| | | 266 | | } |
| | | 267 | | BodyWriter replyBody; |
| | 0 | 268 | | if (sspiNegotiation.IsCompleted) |
| | | 269 | | { |
| | 0 | 270 | | ReadOnlyCollection<IAuthorizationPolicy> authorizationPolicies = await ValidateSspiNegotiationAsync(sspi |
| | | 271 | | SecurityContextSecurityToken serviceToken; |
| | | 272 | | WrappedKeySecurityToken proofToken; |
| | | 273 | | int issuedKeySize; |
| | 0 | 274 | | IssueServiceToken(negotiationState, authorizationPolicies, out serviceToken, out proofToken, out issuedK |
| | 0 | 275 | | negotiationState.SetServiceToken(serviceToken); |
| | | 276 | | |
| | 0 | 277 | | SecurityKeyIdentifierClause externalTokenReference = IssuedSecurityTokenParameters.CreateKeyIdentifierCl |
| | 0 | 278 | | SecurityKeyIdentifierClause internalTokenReference = IssuedSecurityTokenParameters.CreateKeyIdentifierCl |
| | | 279 | | |
| | 0 | 280 | | RequestSecurityTokenResponse dummyRstr = new RequestSecurityTokenResponse(StandardsManager) |
| | 0 | 281 | | { |
| | 0 | 282 | | Context = negotiationState.Context, |
| | 0 | 283 | | KeySize = issuedKeySize, |
| | 0 | 284 | | TokenType = SecurityContextTokenUri |
| | 0 | 285 | | }; |
| | 0 | 286 | | if (outgoingBinaryNegotiation != null) |
| | | 287 | | { |
| | 0 | 288 | | dummyRstr.SetBinaryNegotiation(outgoingBinaryNegotiation); |
| | | 289 | | } |
| | 0 | 290 | | dummyRstr.RequestedUnattachedReference = externalTokenReference; |
| | 0 | 291 | | dummyRstr.RequestedAttachedReference = internalTokenReference; |
| | 0 | 292 | | dummyRstr.SetLifetime(serviceToken.ValidFrom, serviceToken.ValidTo); |
| | 0 | 293 | | if (negotiationState.AppliesTo != null) |
| | | 294 | | { |
| | 0 | 295 | | if (incomingMessage.Version.Addressing == AddressingVersion.WSAddressing10) |
| | | 296 | | { |
| | 0 | 297 | | dummyRstr.SetAppliesTo<EndpointAddress10>(EndpointAddress10.FromEndpointAddress( |
| | 0 | 298 | | negotiationState.AppliesTo), |
| | 0 | 299 | | negotiationState.AppliesToSerializer); |
| | | 300 | | } |
| | 0 | 301 | | else if (incomingMessage.Version.Addressing == AddressingVersion.WSAddressingAugust2004) |
| | | 302 | | { |
| | 0 | 303 | | dummyRstr.SetAppliesTo<EndpointAddressAugust2004>(EndpointAddressAugust2004.FromEndpointAddress( |
| | 0 | 304 | | negotiationState.AppliesTo), |
| | 0 | 305 | | negotiationState.AppliesToSerializer); |
| | | 306 | | } |
| | | 307 | | else |
| | | 308 | | { |
| | 0 | 309 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( |
| | 0 | 310 | | new ProtocolException(SR.Format(SR.AddressingVersionNotSupported, incomingMessage.Version.Ad |
| | | 311 | | } |
| | | 312 | | } |
| | 0 | 313 | | dummyRstr.MakeReadOnly(); |
| | 0 | 314 | | AddToDigest(negotiationState, dummyRstr, false); |
| | 0 | 315 | | RequestSecurityTokenResponse negotiationRstr = new RequestSecurityTokenResponse(StandardsManager) |
| | 0 | 316 | | { |
| | 0 | 317 | | RequestedSecurityToken = serviceToken, |
| | 0 | 318 | | |
| | 0 | 319 | | RequestedProofToken = proofToken, |
| | 0 | 320 | | Context = negotiationState.Context, |
| | 0 | 321 | | KeySize = issuedKeySize, |
| | 0 | 322 | | TokenType = SecurityContextTokenUri |
| | 0 | 323 | | }; |
| | 0 | 324 | | if (outgoingBinaryNegotiation != null) |
| | | 325 | | { |
| | 0 | 326 | | negotiationRstr.SetBinaryNegotiation(outgoingBinaryNegotiation); |
| | | 327 | | } |
| | 0 | 328 | | negotiationRstr.RequestedAttachedReference = internalTokenReference; |
| | 0 | 329 | | negotiationRstr.RequestedUnattachedReference = externalTokenReference; |
| | 0 | 330 | | if (negotiationState.AppliesTo != null) |
| | | 331 | | { |
| | 0 | 332 | | if (incomingMessage.Version.Addressing == AddressingVersion.WSAddressing10) |
| | | 333 | | { |
| | 0 | 334 | | negotiationRstr.SetAppliesTo<EndpointAddress10>( |
| | 0 | 335 | | EndpointAddress10.FromEndpointAddress(negotiationState.AppliesTo), |
| | 0 | 336 | | negotiationState.AppliesToSerializer); |
| | | 337 | | } |
| | 0 | 338 | | else if (incomingMessage.Version.Addressing == AddressingVersion.WSAddressingAugust2004) |
| | | 339 | | { |
| | 0 | 340 | | negotiationRstr.SetAppliesTo<EndpointAddressAugust2004>( |
| | 0 | 341 | | EndpointAddressAugust2004.FromEndpointAddress(negotiationState.AppliesTo), |
| | 0 | 342 | | negotiationState.AppliesToSerializer); |
| | | 343 | | } |
| | | 344 | | else |
| | | 345 | | { |
| | 0 | 346 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( |
| | 0 | 347 | | new ProtocolException(SR.Format(SR.AddressingVersionNotSupported, incomingMessage.Version.Ad |
| | | 348 | | } |
| | | 349 | | } |
| | 0 | 350 | | negotiationRstr.MakeReadOnly(); |
| | | 351 | | |
| | 0 | 352 | | byte[] authenticator = ComputeAuthenticator(negotiationState, serviceToken.GetKeyBytes()); |
| | 0 | 353 | | RequestSecurityTokenResponse authenticatorRstr = new RequestSecurityTokenResponse(StandardsManager) |
| | 0 | 354 | | { |
| | 0 | 355 | | Context = negotiationState.Context |
| | 0 | 356 | | }; |
| | 0 | 357 | | authenticatorRstr.SetAuthenticator(authenticator); |
| | 0 | 358 | | authenticatorRstr.MakeReadOnly(); |
| | | 359 | | |
| | 0 | 360 | | List<RequestSecurityTokenResponse> rstrList = new List<RequestSecurityTokenResponse>(2) |
| | 0 | 361 | | { |
| | 0 | 362 | | negotiationRstr, |
| | 0 | 363 | | authenticatorRstr |
| | 0 | 364 | | }; |
| | 0 | 365 | | replyBody = new RequestSecurityTokenResponseCollection(rstrList, StandardsManager); |
| | | 366 | | |
| | | 367 | | } |
| | | 368 | | else |
| | | 369 | | { |
| | 0 | 370 | | RequestSecurityTokenResponse rstr = new RequestSecurityTokenResponse(StandardsManager) |
| | 0 | 371 | | { |
| | 0 | 372 | | Context = negotiationState.Context |
| | 0 | 373 | | }; |
| | 0 | 374 | | rstr.SetBinaryNegotiation(outgoingBinaryNegotiation); |
| | 0 | 375 | | rstr.MakeReadOnly(); |
| | 0 | 376 | | AddToDigest(negotiationState, rstr, false); |
| | 0 | 377 | | replyBody = rstr; |
| | | 378 | | } |
| | | 379 | | |
| | 0 | 380 | | return replyBody; |
| | 0 | 381 | | } |
| | | 382 | | |
| | | 383 | | private class SspiNegotiationFilter : HeaderFilter |
| | | 384 | | { |
| | | 385 | | private readonly SspiNegotiationTokenAuthenticator _authenticator; |
| | | 386 | | |
| | 1 | 387 | | public SspiNegotiationFilter(SspiNegotiationTokenAuthenticator authenticator) |
| | | 388 | | { |
| | 1 | 389 | | _authenticator = authenticator; |
| | 1 | 390 | | } |
| | | 391 | | |
| | | 392 | | public override bool Match(Message message) |
| | | 393 | | { |
| | 0 | 394 | | if (message.Headers.Action == _authenticator.RequestSecurityTokenAction.Value |
| | 0 | 395 | | || message.Headers.Action == _authenticator.RequestSecurityTokenResponseAction.Value) |
| | | 396 | | { |
| | 0 | 397 | | return !SecurityVersion.Default.DoesMessageContainSecurityHeader(message); |
| | | 398 | | } |
| | | 399 | | else |
| | | 400 | | { |
| | 0 | 401 | | return false; |
| | | 402 | | } |
| | | 403 | | } |
| | | 404 | | } |
| | | 405 | | } |
| | | 406 | | } |