/// <summary>
 /// Initializes a new instance of the <see cref="Saml20ArtifactResolve"/> class.
 /// </summary>
 public Saml20ArtifactResolve()
 {
     _artifactResolve = new ArtifactResolve();
     _artifactResolve.Version = Saml20Constants.Version;
     _artifactResolve.ID = "id" + Guid.NewGuid().ToString("N");
     _artifactResolve.Issuer = new NameID();
     _artifactResolve.IssueInstant = DateTime.Now;
 }
        /// <summary>
        /// Handles responses to an artifact resolve message.
        /// </summary>
        /// <param name="artifactResolve">The artifact resolve message.</param>
        public void RespondToArtifactResolve(ArtifactResolve artifactResolve)
        {
            XmlDocument samlDoc = (XmlDocument)_context.Cache.Get(artifactResolve.Artifact);
            
            Saml20ArtifactResponse response = Saml20ArtifactResponse.GetDefault();
            response.StatusCode = Saml20Constants.StatusCodes.Success;
            response.InResponseTo = artifactResolve.ID;
            response.SamlElement = samlDoc.DocumentElement;

            XmlDocument responseDoc = response.GetXml();

            if (responseDoc.FirstChild is XmlDeclaration)
                responseDoc.RemoveChild(responseDoc.FirstChild);

            XmlSignatureUtils.SignDocument(responseDoc, response.ID);

            if(Trace.ShouldTrace(TraceEventType.Information))
            {
                Trace.TraceData(TraceEventType.Information, string.Format(Tracing.RespondToArtifactResolve, artifactResolve.Artifact, responseDoc.OuterXml));
            }
            SendResponseMessage(responseDoc.OuterXml);
        }
 /// <summary>
 /// Loads the current message as an artifact resolve.
 /// </summary>
 private void LoadArtifactResolve()
 {
     if(_artifactResolve == null)
     {
         _artifactResolve = Serialization.Deserialize<ArtifactResolve>(new XmlNodeReader(SamlMessage));
     }
 }