| | | 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.Tokens; |
| | | 5 | | using System.Xml; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.IdentityModel.Protocols.WSTrust |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// This class defines the requested security token which is usually opaque to |
| | | 11 | | /// the token requestor. |
| | | 12 | | /// </summary> |
| | | 13 | | public class RequestedSecurityToken |
| | | 14 | | { |
| | | 15 | | private XmlElement _tokenAsXml; |
| | | 16 | | private SecurityToken _requestedToken; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Creates an instance of RequestedSecurityToken using the issued token. This is usually used |
| | | 20 | | /// on the token issuer end. |
| | | 21 | | /// </summary> |
| | | 22 | | /// <param name="token">The Security token requested.</param> |
| | 0 | 23 | | public RequestedSecurityToken(SecurityToken token) |
| | | 24 | | { |
| | 0 | 25 | | if (token == null) |
| | | 26 | | { |
| | 0 | 27 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(token)); |
| | | 28 | | } |
| | | 29 | | |
| | 0 | 30 | | _requestedToken = token; |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Creates an instance of RequestedSecurityToken using the token xml. This is usually used on the |
| | | 35 | | /// token receiving end. |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="tokenAsXml">XML representation of the token.</param> |
| | 0 | 38 | | public RequestedSecurityToken(XmlElement tokenAsXml) |
| | | 39 | | { |
| | 0 | 40 | | if (tokenAsXml == null) |
| | | 41 | | { |
| | 0 | 42 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(tokenAsXml)); |
| | | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | _tokenAsXml = tokenAsXml; |
| | 0 | 46 | | } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Returns the XML representation of the token when the RequestedSecurityToken was constructed |
| | | 50 | | /// using the token xml. This property getter could return null if the RequestedSecurityToken was constructed |
| | | 51 | | /// using a security token. |
| | | 52 | | /// </summary> |
| | | 53 | | public virtual XmlElement SecurityTokenXml |
| | | 54 | | { |
| | | 55 | | get |
| | | 56 | | { |
| | 0 | 57 | | return _tokenAsXml; |
| | | 58 | | } |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Gets the issued security token when the RequestedSecurityToken was constructed using the token |
| | | 63 | | /// itself. This property getter could return null if the RequestedSecurityToken was constructed using the |
| | | 64 | | /// token xml. |
| | | 65 | | /// </summary> |
| | | 66 | | public SecurityToken SecurityToken |
| | | 67 | | { |
| | | 68 | | get |
| | | 69 | | { |
| | 0 | 70 | | return _requestedToken; |
| | | 71 | | } |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | } |