Skip to content

Commit da73b1f

Browse files
committed
Add option for custom http client handler.
Set saml2ArtifactResolve Destination and Issuer.
1 parent 3fc6884 commit da73b1f

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/ITfoxtec.Identity.Saml2/Bindings/Saml2SoapEnvelope.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,27 @@ public virtual async Task ResolveAsync(
6060
#else
6161
HttpClient httpClient,
6262
# endif
63-
Saml2ArtifactResolve saml2ArtifactResolve, Saml2Request saml2Request, CancellationToken? cancellationToken = null)
64-
{
63+
Saml2ArtifactResolve saml2ArtifactResolve, Saml2Request saml2Request, CancellationToken? cancellationToken = null
6564
#if NET || NETCORE
66-
var httpClient = httpClientFactory.CreateClient();
65+
, string httpClientName = null)
66+
{
67+
var httpClient = string.IsNullOrEmpty(httpClientName) ? httpClientFactory.CreateClient() : httpClientFactory.CreateClient(httpClientName);
68+
#else
69+
)
70+
{
6771
#endif
68-
69-
XmlDocument = saml2ArtifactResolve.ToXml();
70-
7172
if (saml2ArtifactResolve.Config.ArtifactResolutionService is null || saml2ArtifactResolve.Config.ArtifactResolutionService.Location is null)
7273
{
7374
throw new Saml2ConfigurationException("The ArtifactResolutionService is required to be configured.");
7475
}
7576
var artifactDestination = saml2ArtifactResolve.Config.ArtifactResolutionService.Location;
77+
saml2ArtifactResolve.Destination = artifactDestination;
78+
saml2ArtifactResolve.Issuer = saml2ArtifactResolve.Config.Issuer;
79+
XmlDocument = saml2ArtifactResolve.ToXml();
7680

7781
var content = new StringContent(ToSoapXml().OuterXml, Encoding.UTF8, "text/xml");
7882
content.Headers.Add("SOAPAction", "\"http://www.oasis-open.org/committees/security\"");
83+
7984
using (var response = cancellationToken.HasValue ? await httpClient.PostAsync(artifactDestination, content, cancellationToken.Value) : await httpClient.PostAsync(artifactDestination, content))
8085
{
8186
switch (response.StatusCode)

0 commit comments

Comments
 (0)