vendredi 16 décembre 2011

How to use Maven behing a proxy with authentication


Maven doesn't work with NTLM authentication. It means that you can try to use the settings.xml file as long as you want, you'll not go threw your proxy.

There is a simple fix to use Maven behind a NTLM authentication proxy : install a relay proxy that will take care of authentication on your machine.

First, download NTLMAPS from Sourceforge.
You need Python to run it.

Configure NTLMAPS startup batch :

@echo off
"PATH_TO_PYTHON/python.exe" "PATH_TO_NTLMAPS/main.py"


In NTLMAPS configuration file server.cfg, set values as below :

Dans la section [GENERAL] :
LISTEN_PORT:5865 #leave default port or set an authorised port
PARENT_PROXY:ADRESS_PROXY => #proxy adress
PARENT_PROXY_PORT:PORT_PROXY => #proxy port

Dans la section [NTLM_AUTH] :

NT_DOMAIN:DOMAIN_NT #your domain
USER:USER_NT  #your user
PASSWORD:PASSWORD_NT #your password

Start NTLMAPS with runserver.bat.
Finally configure Maven to use the relay proxy. In your settings.xml :

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">


...

<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol> => your protocol
<host>localhost</host>
<port>5865</port> => port in server.cfg
</proxy>
</proxies>


...
</settings>

And enjoy.

0 commentaires:

Enregistrer un commentaire