/// <summary> /// Resolves an artifact. /// </summary> /// <returns>A stream containing the artifact response from the IdP</returns> public Stream ResolveArtifact(string artifact, string artifactResolveEndpoint, string serviceProviderId, X509Certificate2 cert) { if (artifactResolveEndpoint == null) { throw new InvalidOperationException("Received artifact from unknown IDP."); } var resolve = new Saml2ArtifactResolve { Issuer = serviceProviderId, Artifact = artifact }; var doc = resolve.GetXml(); if (doc.FirstChild is XmlDeclaration) { doc.RemoveChild(doc.FirstChild); } XmlSignatureUtils.SignDocument(doc, resolve.ID, cert); var artifactResolveString = doc.OuterXml; return(GetResponse(artifactResolveEndpoint, artifactResolveString)); }
/// <summary> /// Resolves an artifact. /// </summary> /// <param name="providerName"></param> /// <returns>A stream containing the artifact response from the IdP</returns> public Stream ResolveArtifact(string providerName) { var artifactResolveEndpoint = _configurationProvider.GetIdentityProviderConfiguration(providerName).ArtifactResolveService; if (artifactResolveEndpoint == null) { throw new InvalidOperationException("Received artifact from unknown IDP."); } var serviceProviderId = _configurationProvider.ServiceProviderConfiguration.EntityId; var artifact = GetArtifact(); var resolve = new Saml2ArtifactResolve { Issuer = serviceProviderId, Artifact = artifact }; var doc = resolve.GetXml(); if (doc.FirstChild is XmlDeclaration) { doc.RemoveChild(doc.FirstChild); } var cert = _configurationProvider.ServiceProviderSigningCertificate(); XmlSignatureUtils.SignDocument(doc, resolve.ID, cert); var artifactResolveString = doc.OuterXml; return(GetResponse(artifactResolveEndpoint, artifactResolveString)); }