Search code examples
javasharepointopencmisapache-chemistry

CmisUnauthorizedException - connecting to sharepoint


I am using CMIS to connect with SharePoint. I am getting Unauthorized exception while creating session in SharePoint, So I couldn't upload the document in SharePoint. I am using NTML authentication to connect with SharePoint, but it's not authenticating the user, I am using default NTML implantation from CMIS CmisBindingFactory.NTLM_AUTHENTICATION_PROVIDER _ is it supporting NTLM authentication? if not how to implement NTML authentication in CMIS?

Please find the below code which I have tried.

SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
    Map<String, String> parameter = new HashMap<>();
    parameter.put(SessionParameter.ATOMPUB_URL,
        url);
    
    parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
    // activate the OpenCMIS NTLM authentication provider.
    parameter.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS,
        CmisBindingFactory.NTLM_AUTHENTICATION_PROVIDER);
    // Session locale.
    parameter.put(SessionParameter.LOCALE_ISO3166_COUNTRY, "");
    parameter.put(SessionParameter.LOCALE_ISO639_LANGUAGE, "en");
    parameter.put(SessionParameter.LOCALE_VARIANT, "US");
    parameter.put(SessionParameter.USER, userName);
    parameter.put(SessionParameter.PASSWORD, password);

Session session = sessionFactory.createSession();


Solution

  • OpenCMIS has no reliable NTLM support. Do not use it!

    See https://svn.apache.org/repos/asf/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/NTLMAuthenticationProvider.java