common/src/main/java/HTTPClient/AuthorizationInfo.java
/**
     * Adds an authorization entry for the "NTLM" authorization scheme to
     * the list. If an entry already exists for the "NTLM" scheme and the
     * specified realm then it is overwritten.
     *
     * @param host    the host
     * @param port    the port
     * @param realm   the realm
     * @param user    the username
     * @param passwd  the password
     * @param context the context to associate this info with
     */
Adds an authorization entry for the "NTLM" authorization scheme to
the list. If an entry already exists for the "NTLM" scheme and the
specified realm then it is overwritten.


Adds an authorization entry for the " NTLM " authorization scheme to the list . If an entry already exists for the " NTLM " scheme and the specified realm then it is overwritten .
public static void addNTLMAuthorization(String host, int port,
					    String realm, String user,
					    String passwd, Object context)
    {
	byte[] lm_hpw = DefaultAuthHandler.calc_lm_hpw(passwd);
	byte[] nt_hpw = DefaultAuthHandler.calc_ntcr_hpw(passwd);
	String lhost = null;
	try
	    { lhost = System.getProperty("HTTPClient.defAuthHandler.NTLM.host"); }
	catch (SecurityException se)
	    { }
	if (lhost == null)
	    try
		{ lhost = InetAddress.getLocalHost().getHostName(); }
	    catch (Exception e)
		{ }
	if (lhost == null)
	    lhost = "localhost";	
	int dot = lhost.indexOf('.');
	if (dot != -1)
	    lhost = lhost.substring(0, dot);
	String domain = null;
	int slash;
	if ((slash = user.indexOf('\\')) != -1)
	    domain = user.substring(0, slash);
	else
	{
	    try
	    {
		domain =
		    System.getProperty("HTTPClient.defAuthHandler.NTLM.domain");
	    }
	    catch (SecurityException se)
		{ }
	    if (domain == null)
		domain = lhost;	
	}
	user = user.substring(slash+1);
	Object[] info = { user, lhost.toUpperCase().trim(),
			  domain.toUpperCase().trim(), lm_hpw, nt_hpw };
	addAuthorization(host, port, "NTLM", realm, null, null, info, context);
    }
public static void addNTLMAuthorization ( String host , int port , String realm , String user , String passwd , Object context ) { byte [ ] lm_hpw = DefaultAuthHandler . calc_lm_hpw ( passwd ) ; byte [ ] nt_hpw = DefaultAuthHandler . calc_ntcr_hpw ( passwd ) ; String lhost = null ; try { lhost = System . getProperty ( "HTTPClient.defAuthHandler.NTLM.host" ) ; } catch ( SecurityException se ) { } if ( lhost == null ) try { lhost = InetAddress . getLocalHost ( ) . getHostName ( ) ; } catch ( Exception e ) { } if ( lhost == null ) lhost = "localhost" ; int dot = lhost . indexOf ( '.' ) ; if ( dot != - 1 ) lhost = lhost . substring ( 0 , dot ) ; String domain = null ; int slash ; if ( ( slash = user . indexOf ( '\\' ) ) != - 1 ) domain = user . substring ( 0 , slash ) ; else { try { domain = System . getProperty ( "HTTPClient.defAuthHandler.NTLM.domain" ) ; } catch ( SecurityException se ) { } if ( domain == null ) domain = lhost ; } user = user . substring ( slash + 1 ) ; Object [ ] info = { user , lhost . toUpperCase ( ) . trim ( ) , domain . toUpperCase ( ) . trim ( ) , lm_hpw , nt_hpw } ; addAuthorization ( host , port , "NTLM" , realm , null , null , info , context ) ; }
Adds an authorization entry for the "NTLM" authorization scheme to
 the list.
Adds an authorization entry for the " NTLM " authorization scheme to the list .
// hash the password // get the local host name // ??? // get user and domain name // ??? // store info in extra_info field