chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lu, Wentao" <>
Subject RE: How to add a http header on DotCMIS
Date Wed, 20 Jan 2016 18:34:42 GMT
Thanks Florian.
I implemented a test provider but got a runtime errors "Could not load authentication provider:
Value cannot be null. Parameter name: type"   

at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at DotCMIS.Binding.Impl.CmisBinding..ctor(IDictionary`2 sessionParameters, AbstractAuthenticationProvider

Code Snip as below:

namespace ConsoleApplication1
    class Program
       static void Main(string[] args)
	parameters["MyAuth"] = "MyAuth:" + credentials;
	parameters[SessionParameter.AuthenticationProviderClass] = "ConsoleApplication1.MyAuthenticationProvider";
	SessionFactory factory = SessionFactory.NewInstance();
	ISession session = factory.CreateSession(parameters);

    public class MyAuthenticationProvider : StandardAuthenticationProvider
        public MyAuthenticationProvider()
            Cookies = new CookieContainer();

        protected override void HttpAuthenticate(HttpWebRequest request)
            string user = GetUser();
            string password = GetPassword();
            string MyAuth = Session.GetValue("MyAuth").ToString();

            request.AllowWriteStreamBuffering = false;
            request.CookieContainer = Cookies;
            if (user != null || password != null)
                if (request.Headers.GetValues("Authorization") == null)
                    request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes((user
?? "") + ":" + (password ?? ""))));
                    request.Headers.Add("MyAuth", MyAuth);

Could you help to check anything wrong?  Sorry I am not .NET developer.


-----Original Message-----
From: Florian Müller [] 
Sent: 2016, January 20 12:21 AM
Cc: Lu, Wentao
Subject: Re: How to add a http header on DotCMIS

Hi Wentao,

There no such session parameter in DotCMIS.
You have to implement your own authentication provider to set HTTP headers.
The simplest way is to derive your own authentication provider from StandardAuthenticationProvider
and override the HttpAuthenticate method.

- Florian

> Hi,
> We have a .NET client need to consume CMIS.  In java, we can use 
> SessionParameters.HEADER to add more http headers in the request. How 
> can we do the same on DotCMIS? It seems does not have such parameter 
> on DotCMIS library.
> Thanks
> Wentao
> ________________________________
> This email and its attachments are intended solely for the personal 
> use of the individual or entity named above. Any use of this 
> communication by an unintended recipient is strictly prohibited. If 
> you have received this email in error, any publication, use, 
> reproduction, disclosure or dissemination of its contents is strictly 
> prohibited. Please immediately delete this message and its attachments 
> from your computer and servers. We would also appreciate if you would 
> contact us by a collect call or return email to notify us of this 
> error. Thank you for your cooperation.
> -BCHydroDisclaimerID5.2.8.1541

View raw message