Skip to content

Commit

Permalink
Fix code refactoring recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersAbel committed Mar 26, 2020
1 parent 4a629eb commit 97eaf4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
25 changes: 2 additions & 23 deletions Sustainsys.Saml2/SAML2P/Saml2RequestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,10 @@ namespace Sustainsys.Saml2.Saml2P
/// </summary>
public abstract class Saml2RequestBase : ISaml2Message
{
private Saml2Id id = new Saml2Id("id" + Guid.NewGuid().ToString("N"));

/// <summary>
/// The id of the request.
/// </summary>
public Saml2Id Id
{
get
{
return id;
}
protected set
{
id = value;
}
}
public Saml2Id Id { get; protected set; } = new Saml2Id("id" + Guid.NewGuid().ToString("N"));

/// <summary>
/// Version of the SAML request. Always returns "2.0"
Expand All @@ -47,19 +35,10 @@ public string Version
}
}

private readonly string issueInstant =
DateTime.UtcNow.ToSaml2DateTimeString();

/// <summary>
/// The instant that the request was issued (well actually, created).
/// </summary>
public string IssueInstant
{
get
{
return issueInstant;
}
}
public string IssueInstant { get; } = DateTime.UtcNow.ToSaml2DateTimeString();

/// <summary>
/// SAML message name for requests - hard coded to SAMLRequest.
Expand Down
6 changes: 2 additions & 4 deletions Sustainsys.Saml2/WebSSO/Saml2PostBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public override UnbindResult Unbind(HttpRequestData request, IOptions options)
throw new ArgumentNullException(nameof(request));
}

string encodedMessage;
if (!request.Form.TryGetValue("SAMLResponse", out encodedMessage))
if (!request.Form.TryGetValue("SAMLResponse", out string encodedMessage))
{
encodedMessage = request.Form["SAMLRequest"];
}
Expand All @@ -41,8 +40,7 @@ public override UnbindResult Unbind(HttpRequestData request, IOptions options)

options?.SPOptions.Logger.WriteVerbose("Http POST binding extracted message\n" + xmlDoc.OuterXml);

string relayState = null;
request.Form.TryGetValue("RelayState", out relayState);
request.Form.TryGetValue("RelayState", out string relayState);

return new UnbindResult(xmlDoc.DocumentElement, relayState, TrustLevel.None);
}
Expand Down

0 comments on commit 97eaf4c

Please sign in to comment.