| | | 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 CoreWCF.IdentityModel; |
| | | 6 | | using CoreWCF.IdentityModel.Selectors; |
| | | 7 | | using CoreWCF.IdentityModel.Tokens; |
| | | 8 | | using CoreWCF.Security.Tokens; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Security |
| | | 11 | | { |
| | | 12 | | internal class SessionDerivedKeySecurityTokenParameters : SecurityTokenParameters |
| | | 13 | | { |
| | | 14 | | private readonly bool _actAsInitiator; |
| | 0 | 15 | | protected SessionDerivedKeySecurityTokenParameters(SessionDerivedKeySecurityTokenParameters other) : base(other) |
| | | 16 | | { |
| | 0 | 17 | | _actAsInitiator = other._actAsInitiator; |
| | 0 | 18 | | } |
| | | 19 | | |
| | 0 | 20 | | public SessionDerivedKeySecurityTokenParameters(bool actAsInitiator) : base() |
| | | 21 | | { |
| | 0 | 22 | | _actAsInitiator = actAsInitiator; |
| | 0 | 23 | | InclusionMode = actAsInitiator ? SecurityTokenInclusionMode.AlwaysToRecipient : SecurityTokenInclusionMode.A |
| | 0 | 24 | | RequireDerivedKeys = false; |
| | 0 | 25 | | } |
| | | 26 | | |
| | 0 | 27 | | protected internal override bool SupportsClientAuthentication => false; |
| | 0 | 28 | | protected internal override bool SupportsServerAuthentication => false; |
| | 0 | 29 | | protected internal override bool SupportsClientWindowsIdentity => false; |
| | | 30 | | |
| | 0 | 31 | | protected internal override bool HasAsymmetricKey => false; |
| | | 32 | | |
| | | 33 | | protected override SecurityTokenParameters CloneCore() |
| | | 34 | | { |
| | 0 | 35 | | return new SessionDerivedKeySecurityTokenParameters(this); |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | protected internal override SecurityKeyIdentifierClause CreateKeyIdentifierClause(SecurityToken token, SecurityT |
| | | 39 | | { |
| | 0 | 40 | | if (referenceStyle == SecurityTokenReferenceStyle.Internal) |
| | | 41 | | { |
| | 0 | 42 | | return token.CreateKeyIdentifierClause<LocalIdKeyIdentifierClause>(); |
| | | 43 | | } |
| | | 44 | | else |
| | | 45 | | { |
| | 0 | 46 | | return null; |
| | | 47 | | } |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | protected internal override bool MatchesKeyIdentifierClause(SecurityToken token, SecurityKeyIdentifierClause key |
| | | 51 | | { |
| | 0 | 52 | | if (referenceStyle == SecurityTokenReferenceStyle.Internal) |
| | | 53 | | { |
| | 0 | 54 | | if (!(keyIdentifierClause is LocalIdKeyIdentifierClause localClause)) |
| | | 55 | | { |
| | 0 | 56 | | return false; |
| | | 57 | | } |
| | | 58 | | else |
| | | 59 | | { |
| | 0 | 60 | | return (localClause.LocalId == token.Id); |
| | | 61 | | } |
| | | 62 | | } |
| | | 63 | | else |
| | | 64 | | { |
| | 0 | 65 | | return false; |
| | | 66 | | } |
| | | 67 | | } |
| | | 68 | | |
| | | 69 | | protected internal override void InitializeSecurityTokenRequirement(SecurityTokenRequirement requirement) |
| | | 70 | | { |
| | 0 | 71 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException()); |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | } |