Tabnine Logo
NTLM
Code IndexAdd Tabnine to your IDE (free)

How to use
NTLM
in
org.apache.commons.httpclient.auth

Best Java code snippets using org.apache.commons.httpclient.auth.NTLM (Showing top 20 results out of 315)

origin: commons-httpclient/commons-httpclient

      + credentials.getClass().getName());
NTLM ntlm = new NTLM();
ntlm.setCredentialCharset(method.getParams().getCredentialCharset());
String response = null;
if (this.state == INITIATED || this.state == FAILED) {
  response = ntlm.getType1Message(
    ntcredentials.getHost(), 
    ntcredentials.getDomain());
  this.state = TYPE1_MSG_GENERATED;
} else {
  response = ntlm.getType3Message(
    ntcredentials.getUserName(), 
    ntcredentials.getPassword(),
    ntcredentials.getHost(), 
    ntcredentials.getDomain(),
    ntlm.parseType2Message(this.ntlmchallenge));
  this.state = TYPE3_MSG_GENERATED;
origin: commons-httpclient/commons-httpclient

prepareResponse(finalLength);
addBytes(protocol);
addByte((byte) 0);
addByte((byte) 1);
addByte((byte) 0);
addByte((byte) 0);
addByte((byte) 0);
addByte((byte) 6);
addByte((byte) 82);
addByte((byte) 0);
addByte((byte) 0);
byte[] domLen = convertShort(iDomLen);
addByte(domLen[0]);
addByte(domLen[1]);
addByte(domLen[0]);
addByte(domLen[1]);
byte[] domOff = convertShort(hostBytes.length + 32);
addByte(domOff[0]);
addByte(domOff[1]);
addByte((byte) 0);
addByte((byte) 0);
byte[] hostLen = convertShort(hostBytes.length);
origin: commons-httpclient/commons-httpclient

lmHpw1 = encrypt(lmPw1, magic);
byte[] lmHpw2 = encrypt(lmPw2, magic);
calcResp(lmHpw, nonce, lmResp);
origin: commons-httpclient/commons-httpclient

/**
 * Returns the response for the given message.
 *
 * @param message the message that was received from the server.
 * @param username the username to authenticate with.
 * @param password the password to authenticate with.
 * @param host The host.
 * @param domain the NT domain to authenticate in.
 * @return The response.
 * @throws HttpException If the messages cannot be retrieved.
 */
public final String getResponseFor(String message,
    String username, String password, String host, String domain)
    throws AuthenticationException {
      
  final String response;
  if (message == null || message.trim().equals("")) {
    response = getType1Message(host, domain);
  } else {
    response = getType3Message(username, password, host, domain,
        parseType2Message(message));
  }
  return response;
}
origin: commons-httpclient/commons-httpclient

NTLM ntlm = new NTLM();
ntlm.setCredentialCharset(charset);
String s = ntlm.getResponseFor(
  challenge,
  credentials.getUserName(), 
origin: commons-httpclient/commons-httpclient

/**
 * Create a NTLM authorization string for the given
 * challenge and NT credentials.
 *
 * @param challenge The challenge.
 * @param credentials {@link NTCredentials}
 *
 * @return a ntlm authorization string
 * @throws AuthenticationException is thrown if authentication fails
 * 
 * @deprecated Use non-static {@link #authenticate(Credentials, HttpMethod)}
 */
public static String authenticate(
 final NTCredentials credentials, final String challenge) 
 throws AuthenticationException {
  LOG.trace("enter NTLMScheme.authenticate(NTCredentials, String)");
  if (credentials == null) {
    throw new IllegalArgumentException("Credentials may not be null");
  }
  
  NTLM ntlm = new NTLM();
  String s = ntlm.getResponseFor(challenge,
  credentials.getUserName(), credentials.getPassword(),
  credentials.getHost(), credentials.getDomain());
  return "NTLM " + s;
}
origin: commons-httpclient/commons-httpclient

/**
 * Encrypt the data.
 * @param key The key.
 * @param bytes The data
 * @return byte[] The encrypted data
 * @throws HttpException If {@link Cipher.doFinal(byte[])} fails
 */
private byte[] encrypt(byte[] key, byte[] bytes)
  throws AuthenticationException {
  Cipher ecipher = getCipher(key);
  try {
    byte[] enc = ecipher.doFinal(bytes);
    return enc;
  } catch (IllegalBlockSizeException e) {
    throw new AuthenticationException("Invalid block size for DES encryption.", e);
  } catch (BadPaddingException e) {
    throw new AuthenticationException("Data not padded correctly for DES encryption.", e);
  }
}
origin: commons-httpclient/commons-httpclient

  keys3[i] = keys[i + 14];
byte[] results1 = encrypt(keys1, plaintext);
byte[] results2 = encrypt(keys2, plaintext);
byte[] results3 = encrypt(keys3, plaintext);
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Returns the response for the given message.
 *
 * @param message the message that was received from the server.
 * @param username the username to authenticate with.
 * @param password the password to authenticate with.
 * @param host The host.
 * @param domain the NT domain to authenticate in.
 * @return The response.
 * @throws HttpException If the messages cannot be retrieved.
 */
public final String getResponseFor(String message,
    String username, String password, String host, String domain)
    throws AuthenticationException {
      
  final String response;
  if (message == null || message.trim().equals("")) {
    response = getType1Message(host, domain);
  } else {
    response = getType3Message(username, password, host, domain,
        parseType2Message(message));
  }
  return response;
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

NTLM ntlm = new NTLM();
ntlm.setCredentialCharset(charset);
String s = ntlm.getResponseFor(
  challenge,
  credentials.getUserName(), 
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Create a NTLM authorization string for the given
 * challenge and NT credentials.
 *
 * @param challenge The challenge.
 * @param credentials {@link NTCredentials}
 *
 * @return a ntlm authorization string
 * @throws AuthenticationException is thrown if authentication fails
 * 
 * @deprecated Use non-static {@link #authenticate(Credentials, HttpMethod)}
 */
public static String authenticate(
 final NTCredentials credentials, final String challenge) 
 throws AuthenticationException {
  LOG.trace("enter NTLMScheme.authenticate(NTCredentials, String)");
  if (credentials == null) {
    throw new IllegalArgumentException("Credentials may not be null");
  }
  
  NTLM ntlm = new NTLM();
  String s = ntlm.getResponseFor(challenge,
  credentials.getUserName(), credentials.getPassword(),
  credentials.getHost(), credentials.getDomain());
  return "NTLM " + s;
}
origin: org.apache.commons/httpclient

/**
 * Encrypt the data.
 * @param key The key.
 * @param bytes The data
 * @return byte[] The encrypted data
 * @throws HttpException If {@link Cipher.doFinal(byte[])} fails
 */
private byte[] encrypt(byte[] key, byte[] bytes)
  throws AuthenticationException {
  Cipher ecipher = getCipher(key);
  try {
    byte[] enc = ecipher.doFinal(bytes);
    return enc;
  } catch (IllegalBlockSizeException e) {
    throw new AuthenticationException("Invalid block size for DES encryption.", e);
  } catch (BadPaddingException e) {
    throw new AuthenticationException("Data not padded correctly for DES encryption.", e);
  }
}
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

  keys3[i] = keys[i + 14];
byte[] results1 = encrypt(keys1, plaintext);
byte[] results2 = encrypt(keys2, plaintext);
byte[] results3 = encrypt(keys3, plaintext);
origin: commons-httpclient/commons-httpclient

int finalLength = 64 + ntRespLen + lmRespLen + domainLen 
  + userLen + hostLen;
prepareResponse(finalLength);
byte[] ntlmssp = EncodingUtil.getBytes("NTLMSSP", DEFAULT_CHARSET);
addBytes(ntlmssp);
addByte((byte) 0);
addByte((byte) 3);
addByte((byte) 0);
addByte((byte) 0);
addByte((byte) 0);
addBytes(convertShort(24));
addBytes(convertShort(24));
addBytes(convertShort(finalLength - 24));
addByte((byte) 0);
addByte((byte) 0);
addBytes(convertShort(0));
addBytes(convertShort(0));
addBytes(convertShort(finalLength));
addByte((byte) 0);
addByte((byte) 0);
addBytes(convertShort(domainLen));
addBytes(convertShort(domainLen));
addBytes(convertShort(64));
origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

      + credentials.getClass().getName());
NTLM ntlm = new NTLM();
ntlm.setCredentialCharset(method.getParams().getCredentialCharset());
String response = null;
if (this.state == INITIATED || this.state == FAILED) {
  response = ntlm.getType1Message(
    ntcredentials.getHost(), 
    ntcredentials.getDomain());
  this.state = TYPE1_MSG_GENERATED;
} else {
  response = ntlm.getType3Message(
    ntcredentials.getUserName(), 
    ntcredentials.getPassword(),
    ntcredentials.getHost(), 
    ntcredentials.getDomain(),
    ntlm.parseType2Message(this.ntlmchallenge));
  this.state = TYPE3_MSG_GENERATED;
origin: org.wso2.commons-httpclient/commons-httpclient

/**
 * Returns the response for the given message.
 *
 * @param message the message that was received from the server.
 * @param username the username to authenticate with.
 * @param password the password to authenticate with.
 * @param host The host.
 * @param domain the NT domain to authenticate in.
 * @return The response.
 * @throws HttpException If the messages cannot be retrieved.
 */
public final String getResponseFor(String message,
    String username, String password, String host, String domain)
    throws AuthenticationException {
      
  final String response;
  if (message == null || message.trim().equals("")) {
    response = getType1Message(host, domain);
  } else {
    response = getType3Message(username, password, host, domain,
        parseType2Message(message));
  }
  return response;
}
origin: org.wso2.commons-httpclient/commons-httpclient

NTLM ntlm = new NTLM();
ntlm.setCredentialCharset(charset);
String s = ntlm.getResponseFor(
  challenge,
  credentials.getUserName(), 
origin: org.apache.commons/httpclient

/**
 * Create a NTLM authorization string for the given
 * challenge and NT credentials.
 *
 * @param challenge The challenge.
 * @param credentials {@link NTCredentials}
 *
 * @return a ntlm authorization string
 * @throws AuthenticationException is thrown if authentication fails
 * 
 * @deprecated Use non-static {@link #authenticate(Credentials, HttpMethod)}
 */
public static String authenticate(
 final NTCredentials credentials, final String challenge) 
 throws AuthenticationException {
  LOG.trace("enter NTLMScheme.authenticate(NTCredentials, String)");
  if (credentials == null) {
    throw new IllegalArgumentException("Credentials may not be null");
  }
  
  NTLM ntlm = new NTLM();
  String s = ntlm.getResponseFor(challenge,
  credentials.getUserName(), credentials.getPassword(),
  credentials.getHost(), credentials.getDomain());
  return "NTLM " + s;
}
origin: org.apache.commons/httpclient

lmHpw1 = encrypt(lmPw1, magic);
byte[] lmHpw2 = encrypt(lmPw2, magic);
calcResp(lmHpw, nonce, lmResp);
origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Encrypt the data.
 * @param key The key.
 * @param bytes The data
 * @return byte[] The encrypted data
 * @throws HttpException If {@link Cipher.doFinal(byte[])} fails
 */
private byte[] encrypt(byte[] key, byte[] bytes)
  throws AuthenticationException {
  Cipher ecipher = getCipher(key);
  try {
    byte[] enc = ecipher.doFinal(bytes);
    return enc;
  } catch (IllegalBlockSizeException e) {
    throw new AuthenticationException("Invalid block size for DES encryption.", e);
  } catch (BadPaddingException e) {
    throw new AuthenticationException("Data not padded correctly for DES encryption.", e);
  }
}
org.apache.commons.httpclient.authNTLM

Javadoc

Provides an implementation of the NTLM authentication protocol.

This class provides methods for generating authentication challenge responses for the NTLM authentication protocol. The NTLM protocol is a proprietary Microsoft protocol and as such no RFC exists for it. This class is based upon the reverse engineering efforts of a wide range of people.

Please note that an implementation of JCE must be correctly installed and configured when using NTLM support.

This class should not be used externally to HttpClient as it's API is specifically designed to work with HttpClient's use case, in particular it's connection management.

Most used methods

  • <init>
  • addByte
    Adds the given byte to the response.
  • addBytes
    Adds the given bytes to the response.
  • calcResp
    Takes a 21 byte array and treats it as 3 56-bit DES keys. The 8 byte plaintext is encrypted with eac
  • convertShort
    Converts a given number to a two byte array in little endian order.
  • encrypt
    Encrypt the data.
  • getCipher
    Return the cipher for the specified key.
  • getResponse
    Returns the response that has been generated after shrinking the array if required and base64 encode
  • getResponseFor
    Returns the response for the given message.
  • getType1Message
    Creates the first message (type 1 message) in the NTLM authentication sequence. This message include
  • getType3Message
    Creates the type 3 message using the given server nonce. The type 3 message includes all the informa
  • hashPassword
    Creates the LANManager and NT response for the given password using the given nonce.
  • getType3Message,
  • hashPassword,
  • parseType2Message,
  • prepareResponse,
  • setCredentialCharset,
  • setupKey

Popular in Java

  • Making http requests using okhttp
  • requestLocationUpdates (LocationManager)
  • putExtra (Intent)
  • setContentView (Activity)
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • JLabel (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now