Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Saml20ArtifactResolve"/> class.
 /// </summary>
 public Saml20ArtifactResolve()
 {
     _artifactResolve = new ArtifactResolve
                            {
                                Version = Saml20Constants.Version,
                                Id = "id" + Guid.NewGuid().ToString("N"),
                                Issuer = new NameId(),
                                IssueInstant = DateTime.Now
                            };
 }
Пример #2
0
        /// <summary>
        /// Handles responses to an artifact resolve message.
        /// </summary>
        /// <param name="artifactResolve">The artifact resolve message.</param>
        public void RespondToArtifactResolve(ArtifactResolve artifactResolve, XmlElement samlDoc)
        {
            var response = Saml20ArtifactResponse.GetDefault(config.ServiceProvider.Id);
            response.StatusCode = Saml20Constants.StatusCodes.Success;
            response.InResponseTo = artifactResolve.Id;
            response.SamlElement = samlDoc; //samlDoc.DocumentElement;

            var responseDoc = response.GetXml();
            if (responseDoc.FirstChild is XmlDeclaration)
            {
                responseDoc.RemoveChild(responseDoc.FirstChild);
            }

            XmlSignatureUtils.SignDocument(responseDoc, response.Id, config.ServiceProvider.SigningCertificate);

            Logger.DebugFormat(TraceMessages.ArtifactResolveResponseSent, 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));
     }
 }
        /// <summary>
        /// Handles responses to an artifact resolve message.
        /// </summary>
        /// <param name="artifactResolve">The artifact resolve message.</param>
        public void RespondToArtifactResolve(ArtifactResolve artifactResolve)
        {
            var samlDoc = (XmlDocument)Context.Cache.Get(artifactResolve.Artifact);

            var response = Saml20ArtifactResponse.GetDefault();
            response.StatusCode = Saml20Constants.StatusCodes.Success;
            response.InResponseTo = artifactResolve.Id;
            response.SamlElement = samlDoc.DocumentElement;

            var responseDoc = response.GetXml();
            if (responseDoc.FirstChild is XmlDeclaration)
            {
                responseDoc.RemoveChild(responseDoc.FirstChild);
            }

            XmlSignatureUtils.SignDocument(responseDoc, response.Id);

            Logger.DebugFormat(TraceMessages.ArtifactResolveResponseSent, artifactResolve.Artifact, responseDoc.OuterXml);

            SendResponseMessage(responseDoc.OuterXml);
        }