NTML authentication

Using the internal HTTP client connector

At this time, the access to services secured with NTML is supported via the internal HTTP client based on the support of NTLM authenticated introduced in Java 5. So, add the core module (org.restlet.jar) to your application.

The required step is to setup your custom Authenticator instance wich will be referenced each the client connector will issue a request. According to the JDK5 javadocs, just proceed as follow:

// Create your own authenticator
Authenticator a = new Authenticator() {
    public PasswordAuthentication getPasswordAuthentication() {
        return (new PasswordAuthentication("<your account>", "<your password>".toCharArray()));
    }
};
// Sets the default Authenticator
Authenticator.setDefault(a);

Authenticate with NTML all requests performed via the internal HTTP client connector.

No additional steps are required so far.

This does not apply to the Android extension. In this case, the support of NTLM authentication leverages the Apache “HttpClient” extension.

Using the Apache HTTP Client extension

This library does not provide a direct support of the the NTLM authentication scheme (see here). However, it explains how to leverage the Samba JCIFS library as an NTML Engine. Basically, the following steps are required:

  • Add the the “org.restlet.ext.httpclient.jar” to your project.
  • Add the JCIFS archive to your project.
  • Set up a dedicated client helper that will handle the NTML requests using the Apache HTTP Client and JCIFS libraries.

Here is a sample implementation of such client helper. It extends the one provided by the Apache HTTP Client extension that must be added to your project.

Make the Engine register this client helper:

Here is a sample code that manually adds this client helper:

Engine.getInstance().getRegisteredClients().add(0, new MyNtlmHttpClientHelper(new Client(Protocol.HTTP)));