| | | 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.ComponentModel; |
| | | 6 | | using CoreWCF.Channels; |
| | | 7 | | using CoreWCF.Runtime; |
| | | 8 | | using CoreWCF.Security; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF |
| | | 11 | | { |
| | | 12 | | public sealed class WSFederationHttpSecurity |
| | | 13 | | { |
| | | 14 | | internal const WSFederationHttpSecurityMode DefaultMode = WSFederationHttpSecurityMode.Message; |
| | | 15 | | private WSFederationHttpSecurityMode _mode; |
| | | 16 | | private FederatedMessageSecurityOverHttp _messageSecurity; |
| | | 17 | | |
| | | 18 | | public WSFederationHttpSecurity() |
| | 2 | 19 | | : this(DefaultMode, new FederatedMessageSecurityOverHttp()) |
| | | 20 | | { |
| | 2 | 21 | | } |
| | | 22 | | |
| | 2 | 23 | | private WSFederationHttpSecurity(WSFederationHttpSecurityMode mode, FederatedMessageSecurityOverHttp messageSecu |
| | | 24 | | { |
| | | 25 | | Fx.Assert(WSFederationHttpSecurityModeHelper.IsDefined(mode), string.Format("Invalid WSFederationHttpSecurit |
| | 2 | 26 | | _mode = mode; |
| | 2 | 27 | | _messageSecurity = messageSecurity == null ? new FederatedMessageSecurityOverHttp() : messageSecurity; |
| | 2 | 28 | | } |
| | | 29 | | |
| | | 30 | | public WSFederationHttpSecurityMode Mode |
| | | 31 | | { |
| | 264 | 32 | | get { return _mode; } |
| | | 33 | | set |
| | | 34 | | { |
| | 2 | 35 | | if (!WSFederationHttpSecurityModeHelper.IsDefined(value)) |
| | | 36 | | { |
| | 0 | 37 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val |
| | | 38 | | } |
| | 2 | 39 | | _mode = value; |
| | 2 | 40 | | } |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | public FederatedMessageSecurityOverHttp Message |
| | | 44 | | { |
| | 4 | 45 | | get { return _messageSecurity; } |
| | 0 | 46 | | set { _messageSecurity = value; } |
| | | 47 | | } |
| | | 48 | | |
| | | 49 | | internal SecurityBindingElement CreateMessageSecurity(bool isReliableSessionEnabled, MessageSecurityVersion vers |
| | | 50 | | { |
| | 50 | 51 | | if (_mode == WSFederationHttpSecurityMode.Message || _mode == WSFederationHttpSecurityMode.TransportWithMess |
| | | 52 | | { |
| | 50 | 53 | | return _messageSecurity.CreateSecurityBindingElement(Mode == WSFederationHttpSecurityMode.TransportWithM |
| | | 54 | | } |
| | | 55 | | else |
| | | 56 | | { |
| | 0 | 57 | | return null; |
| | | 58 | | } |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | } |
| | | 62 | | } |