| | | 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.IdentityModel.Claims; |
| | | 5 | | using CoreWCF.IdentityModel.Policy; |
| | | 6 | | using SysClaim = CoreWCF.IdentityModel.Claims.Claim; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.IdentityModel.Tokens |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// This class serves as a dummy AuthorizationPolicy on an issued token so that when |
| | | 12 | | /// WCF renews a token it can match the identity of the issuer with the renewer. This is |
| | | 13 | | /// required as in the IDFX layer we throw the WCF generated AuthorizationPolicy ( UnconditionalPolicy ) |
| | | 14 | | /// </summary> |
| | | 15 | | internal class SctAuthorizationPolicy : IAuthorizationPolicy |
| | | 16 | | { |
| | | 17 | | private readonly ClaimSet _issuer; |
| | 0 | 18 | | private readonly string _id = SecurityUniqueId.Create().Value; |
| | | 19 | | |
| | 0 | 20 | | internal SctAuthorizationPolicy( SysClaim claim ) |
| | | 21 | | { |
| | 0 | 22 | | _issuer = new DefaultClaimSet( claim ); |
| | 0 | 23 | | } |
| | | 24 | | |
| | | 25 | | #region IAuthorizationPolicy Members |
| | | 26 | | |
| | | 27 | | bool IAuthorizationPolicy.Evaluate( EvaluationContext evaluationContext, ref object state ) |
| | | 28 | | { |
| | 0 | 29 | | if ( evaluationContext == null ) |
| | | 30 | | { |
| | 0 | 31 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(evaluationContext)); |
| | | 32 | | } |
| | 0 | 33 | | evaluationContext.AddClaimSet( this, _issuer ); |
| | 0 | 34 | | return true; |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | ClaimSet IAuthorizationPolicy.Issuer |
| | | 38 | | { |
| | | 39 | | get |
| | | 40 | | { |
| | 0 | 41 | | return _issuer; |
| | | 42 | | } |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | #endregion |
| | | 46 | | |
| | | 47 | | #region IAuthorizationComponent Members |
| | | 48 | | |
| | | 49 | | string IAuthorizationComponent.Id |
| | | 50 | | { |
| | | 51 | | get |
| | | 52 | | { |
| | 0 | 53 | | return _id; |
| | | 54 | | } |
| | | 55 | | } |
| | | 56 | | #endregion |
| | | 57 | | } |
| | | 58 | | } |