/// <summary>Initializes a new instance of the <see cref="T:System.IdentityModel.Tokens.GenericXmlSecurityToken" /> class. </summary> /// <param name="tokenXml">An <see cref="T:System.Xml.XmlElement" /> that represents the XML that is associated with the security token. Sets the <see cref="P:System.IdentityModel.Tokens.GenericXmlSecurityToken.TokenXml" /> property.</param> /// <param name="proofToken">A <see cref="T:System.IdentityModel.Tokens.SecurityToken" /> that represents the proof token for the security token. Sets the <see cref="P:System.IdentityModel.Tokens.GenericXmlSecurityToken.ProofToken" /> property.</param> /// <param name="effectiveTime">A <see cref="T:System.DateTime" /> that represents the first instant in time at which this security token is valid. Sets the <see cref="P:System.IdentityModel.Tokens.GenericXmlSecurityToken.ValidFrom" /> property.</param> /// <param name="expirationTime">A <see cref="T:System.DateTime" /> that represents the last instant in time at which this security token is valid. Sets the <see cref="P:System.IdentityModel.Tokens.GenericXmlSecurityToken.ValidFrom" /> property.</param> /// <param name="internalTokenReference">A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> that represents a reference to this security token when it is included in a SOAP message in which it is referenced. Sets the <see cref="P:System.IdentityModel.Tokens.GenericXmlSecurityToken.InternalTokenReference" /> property.</param> /// <param name="externalTokenReference">A <see cref="T:System.IdentityModel.Tokens.SecurityKeyIdentifierClause" /> that represents a reference to this security token when it is not included in a SOAP message in which it is referenced. Sets the <see cref="P:System.IdentityModel.Tokens.GenericXmlSecurityToken.ValidFrom" /> property.</param> /// <param name="authorizationPolicies">A <see cref="T:System.Collections.ObjectModel.ReadOnlyCollection`1" /> of type <see cref="T:System.IdentityModel.Policy.IAuthorizationPolicy" /> that contains the set authorization policies for this security token.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="tokenXml" /> is null.-or-<paramref name="proofToken" /> is null.</exception> public GenericXmlSecurityToken(XmlElement tokenXml, SecurityToken proofToken, DateTime effectiveTime, DateTime expirationTime, SecurityKeyIdentifierClause internalTokenReference, SecurityKeyIdentifierClause externalTokenReference, ReadOnlyCollection <IAuthorizationPolicy> authorizationPolicies) { if (tokenXml == null) { throw new ArgumentNullException("tokenXml"); } this.id = GenericXmlSecurityToken.GetId(tokenXml); this.tokenXml = tokenXml; this.proofToken = proofToken; this.effectiveTime = effectiveTime.ToUniversalTime(); this.expirationTime = expirationTime.ToUniversalTime(); this.internalTokenReference = internalTokenReference; this.externalTokenReference = externalTokenReference; this.authorizationPolicies = authorizationPolicies ?? EmptyReadOnlyCollection <IAuthorizationPolicy> .Instance; }
/// <summary> /// Creates an instance of this object using a <see cref="SecurityToken"/> object. /// </summary> /// <param name="securityToken">The security token this object represents.</param> /// <remarks> /// <see cref="GetIdentities"/> is not supported by this object if this constructor is used unless /// <see cref="ValidateToken"/> is overriden. /// If the securityToken passed in is a <see cref="GenericXmlSecurityToken"/> then SecurityTokenXml will /// be set to the value found in <see cref="GenericXmlSecurityToken"/> /// </remarks> public SecurityTokenElement(SecurityToken securityToken) { if (securityToken == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("securityToken"); } GenericXmlSecurityToken xmlToken = securityToken as GenericXmlSecurityToken; if (xmlToken != null) { _securityTokenXml = xmlToken.TokenXml; } _securityToken = securityToken; }