Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RetsSdk/Models/ConnectionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ConnectionOptions
public string Password { get; set; }
public AuthenticationType Type { get; set; }
public string UserAgent { get; set; }
public string UserAgentPassward { get; set; }
public string UserAgentPassword { get; set; }
public SupportedRetsVersion RetsServerVersion { get; set; } = SupportedRetsVersion.Version_1_7_2;
public string LoginUrl { get; set; }
public TimeSpan Timeout { get; set; }
Expand Down
10 changes: 8 additions & 2 deletions RetsSdk/Models/SessionResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace CrestApps.RetsSdk.Models
{
public class SessionResource
{
public string BaseUri { get; set; }
public string SessionId { get; set; }
public string Cookie { get; set; }

Expand All @@ -19,19 +20,24 @@ public SessionResource()

public void AddCapability(Capability name, string url)
{
if (url.StartsWith("/"))
{
url = BaseUri + url;
}

var uri = new Uri(url);

if (Capabilities.ContainsKey(name) || !uri.IsWellFormedOriginalString())
{
return;
}

Capabilities.TryAdd(name, uri);
}

public Uri GetCapability(Capability name)
{
if(!Capabilities.ContainsKey(name))
if (!Capabilities.ContainsKey(name))
{
throw new MissingCapabilityException();
}
Expand Down
5 changes: 3 additions & 2 deletions RetsSdk/Services/RetsSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected SessionResource GetRetsResource(string[] parts, string cookie)
{
var resource = new SessionResource()
{
BaseUri = LoginUri.AbsoluteUri.Substring(0, LoginUri.AbsoluteUri.Length - LoginUri.PathAndQuery.Length),
SessionId = MakeRetsSessionId(cookie),
Cookie = cookie,
};
Expand All @@ -102,12 +103,12 @@ private string MakeRetsSessionId(string cookie)
{
string sessionId = ExtractSessionId(cookie);

if(string.IsNullOrWhiteSpace(sessionId))
if (string.IsNullOrWhiteSpace(sessionId))
{
return null;
}

string agentData = Str.Md5(Options.UserAgent + ":" + Options.UserAgentPassward);
string agentData = Str.Md5(Options.UserAgent + ":" + Options.UserAgentPassword);

return $"{agentData}::{sessionId}:{Options.Version.AsHeader()}";
}
Expand Down