| | | 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 | | |
| | | 7 | | namespace CoreWCF.IdentityModel.Tokens |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Implementation of IAuthorizationPolicy that contains endpoint specific |
| | | 11 | | /// AuthorizationPolicy. |
| | | 12 | | /// </summary> |
| | | 13 | | internal class EndpointAuthorizationPolicy : IAuthorizationPolicy |
| | | 14 | | { |
| | 0 | 15 | | private readonly string _id = IdentityModelUniqueId.CreateUniqueId(); |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Creates an instance of <see cref="EndpointAuthorizationPolicy"/> |
| | | 19 | | /// </summary> |
| | | 20 | | /// <param name="endpointId">Identifier of the Endpoint to which the token should be restricted.</param> |
| | 0 | 21 | | public EndpointAuthorizationPolicy( string endpointId ) |
| | | 22 | | { |
| | 0 | 23 | | EndpointId = endpointId ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(endpointI |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets the EndpointId for the AuthorizationPolicy |
| | | 28 | | /// </summary> |
| | 0 | 29 | | public string EndpointId { get; } |
| | | 30 | | |
| | | 31 | | #region IAuthorizationPolicy Members |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Check if the claims in the EvaluationContext. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="evaluationContext">The current evaluationContext</param> |
| | | 37 | | /// <param name="state">Any custom state.</param> |
| | | 38 | | /// <returns>Returns true by default.</returns> |
| | 0 | 39 | | bool IAuthorizationPolicy.Evaluate(EvaluationContext evaluationContext, ref object state) => true; |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets the Issuer ClaimSet. Returns null by default. |
| | | 43 | | /// </summary> |
| | 0 | 44 | | ClaimSet IAuthorizationPolicy.Issuer => null; |
| | | 45 | | |
| | | 46 | | #endregion |
| | | 47 | | |
| | | 48 | | #region IAuthorizationComponent Members |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Gets the Id. |
| | | 52 | | /// </summary> |
| | 0 | 53 | | string IAuthorizationComponent.Id => _id; |
| | | 54 | | #endregion |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | } |