Skip to content

Commit

Permalink
Unauthorized callback
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanBaulch committed Mar 8, 2017
1 parent 427a45c commit 6da9e89
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Saleslogix.SData.Client/Framework/IAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ namespace Saleslogix.SData.Client.Framework
public interface IAuthenticator
{
void Authenticate(WebRequest request);
UnauthorizedAction Unauthorized(WebResponse response);
}

public enum UnauthorizedAction
{
Throw,
Retry
}
}
6 changes: 6 additions & 0 deletions Saleslogix.SData.Client/Framework/SDataRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public virtual SDataResponse GetResponse()
attempts--;
continue;
}
if (ex.Status == WebExceptionStatus.ProtocolError &&
((HttpWebResponse) ex.Response).StatusCode == HttpStatusCode.Unauthorized &&
Authenticator != null && Authenticator.Unauthorized(ex.Response) == UnauthorizedAction.Retry)
{
continue;
}
throw new SDataException(ex);
}

Expand Down
2 changes: 1 addition & 1 deletion Saleslogix.SData.Client/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// by using the '*' as shown below:

[assembly: AssemblyVersion("2.0")]
[assembly: AssemblyFileVersion("2.0.1.1562")]
[assembly: AssemblyFileVersion("2.0.2.1563")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: AssemblyInformationalVersion("2.0")]
[assembly: InternalsVisibleTo("Saleslogix.SData.Client.Test, PublicKey=" +
Expand Down

0 comments on commit 6da9e89

Please sign in to comment.