CMIS-531: added NTLM authentication
git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1338087 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMIS/Properties/AssemblyInfo.cs b/DotCMIS/Properties/AssemblyInfo.cs
index fe8a43a..537a906 100644
--- a/DotCMIS/Properties/AssemblyInfo.cs
+++ b/DotCMIS/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.4.0.0")]
+[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/DotCMIS/binding/binding-intf.cs b/DotCMIS/binding/binding-intf.cs
index fc27ce9..eba36ac 100644
--- a/DotCMIS/binding/binding-intf.cs
+++ b/DotCMIS/binding/binding-intf.cs
@@ -86,9 +86,10 @@
string password = GetPassword();
// AtomPub authentictaion
- WebRequest request = connection as WebRequest;
+ HttpWebRequest request = connection as HttpWebRequest;
if (request != null)
{
+ request.AllowWriteStreamBuffering = false;
if (user != null || password != null)
{
if (request.Headers.GetValues("Authorization") == null)
@@ -183,6 +184,28 @@
}
}
+ public class NtlmAuthenticationProvider : AbstractAuthenticationProvider
+ {
+ private CookieContainer Cookies { get; set; }
+
+ public NtlmAuthenticationProvider()
+ {
+ Cookies = new CookieContainer();
+ }
+
+ public override void Authenticate(object connection)
+ {
+ HttpWebRequest hwr = connection as HttpWebRequest;
+
+ if (hwr != null)
+ {
+ hwr.Credentials = CredentialCache.DefaultNetworkCredentials;
+ hwr.CookieContainer = Cookies;
+ hwr.AllowWriteStreamBuffering = true;
+ }
+ }
+ }
+
public class CmisBindingFactory
{
// Default CMIS AtomPub binding SPI implementation
diff --git a/DotCMIS/binding/http.cs b/DotCMIS/binding/http.cs
index 4b3ce28..2e78527 100644
--- a/DotCMIS/binding/http.cs
+++ b/DotCMIS/binding/http.cs
@@ -132,7 +132,6 @@
if (writer != null)
{
conn.SendChunked = true;
- conn.AllowWriteStreamBuffering = false;
Stream requestStream = conn.GetRequestStream();
writer(requestStream);
requestStream.Close();
@@ -163,7 +162,7 @@
internal class Response
{
- private WebResponse response;
+ private readonly WebResponse response;
public HttpStatusCode StatusCode { get; private set; }
public string Message { get; private set; }