| | | 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.Collections.ObjectModel; |
| | | 6 | | using System.Security.Cryptography; |
| | | 7 | | using CoreWCF.Security; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.IdentityModel.Tokens |
| | | 10 | | { |
| | | 11 | | internal class RsaSecurityToken : SecurityToken |
| | | 12 | | { |
| | | 13 | | private readonly string _id; |
| | | 14 | | private readonly DateTime _effectiveTime; |
| | | 15 | | |
| | | 16 | | public RsaSecurityToken(RSA rsa) |
| | 0 | 17 | | : this(rsa, SecurityUniqueId.Create().Value) |
| | | 18 | | { |
| | 0 | 19 | | } |
| | | 20 | | |
| | 0 | 21 | | public RsaSecurityToken(RSA rsa, string id) |
| | | 22 | | { |
| | 0 | 23 | | Rsa = rsa ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(rsa)); |
| | 0 | 24 | | _id = id ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(id)); |
| | 0 | 25 | | _effectiveTime = DateTime.UtcNow; |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | public override string Id |
| | | 29 | | { |
| | 0 | 30 | | get { return _id; } |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | public override DateTime ValidFrom |
| | | 34 | | { |
| | 0 | 35 | | get { return _effectiveTime; } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | public override DateTime ValidTo |
| | | 39 | | { |
| | | 40 | | // Never expire |
| | 0 | 41 | | get { return SecurityUtils.MaxUtcDateTime; } |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | public override ReadOnlyCollection<SecurityKey> SecurityKeys |
| | | 45 | | { |
| | | 46 | | get |
| | | 47 | | { |
| | 0 | 48 | | throw new PlatformNotSupportedException("RsaSecurityKey"); |
| | | 49 | | } |
| | | 50 | | } |
| | | 51 | | |
| | 0 | 52 | | public RSA Rsa { get; } |
| | | 53 | | } |
| | | 54 | | } |