| | | 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.Globalization; |
| | | 6 | | using System.Text; |
| | | 7 | | using CoreWCF.Channels; |
| | | 8 | | using CoreWCF.IdentityModel; |
| | | 9 | | using CoreWCF.IdentityModel.Selectors; |
| | | 10 | | using CoreWCF.IdentityModel.Tokens; |
| | | 11 | | |
| | | 12 | | namespace CoreWCF.Security.Tokens |
| | | 13 | | { |
| | | 14 | | public class SspiSecurityTokenParameters : SecurityTokenParameters |
| | | 15 | | { |
| | | 16 | | internal const bool defaultRequireCancellation = false; |
| | | 17 | | private BindingContext _issuerBindingContext; |
| | | 18 | | |
| | | 19 | | protected SspiSecurityTokenParameters(SspiSecurityTokenParameters other) |
| | 31 | 20 | | : base(other) |
| | | 21 | | { |
| | 31 | 22 | | RequireCancellation = other.RequireCancellation; |
| | 31 | 23 | | if (other._issuerBindingContext != null) |
| | | 24 | | { |
| | 1 | 25 | | _issuerBindingContext = other._issuerBindingContext.Clone(); |
| | | 26 | | } |
| | 31 | 27 | | } |
| | | 28 | | |
| | | 29 | | |
| | | 30 | | public SspiSecurityTokenParameters() |
| | 0 | 31 | | : this(defaultRequireCancellation) |
| | | 32 | | { |
| | | 33 | | // empty |
| | 0 | 34 | | } |
| | | 35 | | |
| | | 36 | | public SspiSecurityTokenParameters(bool requireCancellation) |
| | 2 | 37 | | : base() |
| | | 38 | | { |
| | 2 | 39 | | RequireCancellation = requireCancellation; |
| | 2 | 40 | | } |
| | | 41 | | |
| | 2 | 42 | | protected internal override bool HasAsymmetricKey { get { return false; } } |
| | | 43 | | |
| | 66 | 44 | | public bool RequireCancellation { get; set; } = defaultRequireCancellation; |
| | | 45 | | |
| | | 46 | | internal BindingContext IssuerBindingContext |
| | | 47 | | { |
| | | 48 | | get |
| | | 49 | | { |
| | 2 | 50 | | return _issuerBindingContext; |
| | | 51 | | } |
| | | 52 | | set |
| | | 53 | | { |
| | 1 | 54 | | if (value != null) |
| | | 55 | | { |
| | 1 | 56 | | value = value.Clone(); |
| | | 57 | | } |
| | 1 | 58 | | _issuerBindingContext = value; |
| | 1 | 59 | | } |
| | | 60 | | } |
| | | 61 | | |
| | 10 | 62 | | protected internal override bool SupportsClientAuthentication { get { return true; } } |
| | 0 | 63 | | protected internal override bool SupportsServerAuthentication { get { return true; } } |
| | 10 | 64 | | protected internal override bool SupportsClientWindowsIdentity { get { return true; } } |
| | | 65 | | |
| | | 66 | | protected override SecurityTokenParameters CloneCore() |
| | | 67 | | { |
| | 31 | 68 | | return new SspiSecurityTokenParameters(this); |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | protected internal override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityT |
| | | 72 | | { |
| | 0 | 73 | | if (token is GenericXmlSecurityToken) |
| | | 74 | | { |
| | 0 | 75 | | return CreateGenericXmlTokenKeyIdentifierClause(token, referenceStyle); |
| | | 76 | | } |
| | | 77 | | else |
| | | 78 | | { |
| | 0 | 79 | | return CreateKeyIdentifierClause<SecurityContextKeyIdentifierClause, LocalIdKeyIdentifierClause>(token, |
| | | 80 | | } |
| | | 81 | | } |
| | | 82 | | |
| | | 83 | | protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement) |
| | | 84 | | { |
| | 1 | 85 | | requirement.TokenType = ServiceModelSecurityTokenTypes.Spnego; |
| | 1 | 86 | | requirement.RequireCryptographicToken = true; |
| | 1 | 87 | | requirement.KeyType = SecurityKeyType.SymmetricKey; |
| | 1 | 88 | | requirement.Properties[ServiceModelSecurityTokenRequirement.SupportSecurityContextCancellationProperty] = Re |
| | 1 | 89 | | if (IssuerBindingContext != null) |
| | | 90 | | { |
| | 1 | 91 | | requirement.Properties[ServiceModelSecurityTokenRequirement.IssuerBindingContextProperty] = IssuerBindin |
| | | 92 | | } |
| | 1 | 93 | | requirement.Properties[ServiceModelSecurityTokenRequirement.IssuedSecurityTokenParametersProperty] = Clone() |
| | 1 | 94 | | } |
| | | 95 | | |
| | | 96 | | public override string ToString() |
| | | 97 | | { |
| | 0 | 98 | | StringBuilder sb = new StringBuilder(); |
| | 0 | 99 | | sb.AppendLine(base.ToString()); |
| | | 100 | | |
| | 0 | 101 | | sb.Append(string.Format(CultureInfo.InvariantCulture, "RequireCancellation: {0}", RequireCancellation.ToStri |
| | | 102 | | |
| | 0 | 103 | | return sb.ToString(); |
| | | 104 | | } |
| | | 105 | | } |
| | | 106 | | } |