TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Swift_Transport_Esmtp_Auth_NTLMAuthenticator Class Reference
Inheritance diagram for Swift_Transport_Esmtp_Auth_NTLMAuthenticator:
Swift_Transport_Esmtp_Authenticator

Public Member Functions

 getAuthKeyword ()
 
 authenticate (Swift_Transport_SmtpAgent $agent, $username, $password)
 

Public Attributes

const NTLMSIG = "NTLMSSP\x00"
 
const DESCONST = 'KGS!@#$%'
 

Protected Member Functions

 si2bin ($si, $bits=32)
 
 sendMessage1 (Swift_Transport_SmtpAgent $agent)
 
 parseMessage2 ($response)
 
 readSubBlock ($block)
 
 sendMessage3 ($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2=true)
 
 createMessage1 ()
 
 createMessage3 ($domain, $username, $workstation, $lmResponse, $ntlmResponse)
 
 createBlob ($timestamp, $client, $targetInfo)
 
 getDomainAndUsername ($name)
 
 createLMPassword ($password, $challenge)
 
 createNTLMPassword ($password, $challenge)
 
 getCorrectTimestamp ($time)
 
 createLMv2Password ($password, $username, $domain, $challenge, $client)
 
 createNTLMv2Hash ($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client)
 
 createDesKey ($key)
 
 createSecurityBuffer ($value, $offset, $is16=false)
 
 readSecurityBuffer ($value)
 
 castToByte ($v)
 
 uRShift ($a, $b)
 
 createByte ($input, $bytes=4, $isHex=true)
 
 getRandomBytes ($length)
 
 desEncrypt ($value, $key)
 
 md5Encrypt ($key, $msg)
 
 md4Encrypt ($input)
 
 convertTo16bit ($input)
 
 hex2bin ($hex)
 
 debug ($message)
 

Detailed Description

Handles NTLM authentication.

Author
Ward Peeters ward@.nosp@m.codi.nosp@m.ng-te.nosp@m.ch.c.nosp@m.om

Definition at line 18 of file NTLMAuthenticator.php.

Member Function Documentation

authenticate ( Swift_Transport_SmtpAgent  $agent,
  $username,
  $password 
)

Try to authenticate the user with $username and $password.

Parameters
Swift_Transport_SmtpAgent$agent
string$username
string$password
Returns
bool

Implements Swift_Transport_Esmtp_Authenticator.

Definition at line 42 of file NTLMAuthenticator.php.

References $response, Swift_Transport_SmtpAgent\executeCommand(), getCorrectTimestamp(), getRandomBytes(), sendMessage1(), and sendMessage3().

castToByte (   $v)
protected

Cast to byte java equivalent to (byte).

Parameters
int$v
Returns
int

Definition at line 506 of file NTLMAuthenticator.php.

Referenced by createDesKey().

convertTo16bit (   $input)
protected

Convert UTF-8 to UTF-16.

Parameters
string$input
Returns
string

Definition at line 629 of file NTLMAuthenticator.php.

Referenced by createLMv2Password(), createNTLMv2Hash(), and md4Encrypt().

createBlob (   $timestamp,
  $client,
  $targetInfo 
)
protected
Parameters
string$timestampEpoch timestamp in microseconds
string$clientRandom bytes
string$targetInfo
Returns
string

Definition at line 277 of file NTLMAuthenticator.php.

References createByte().

Referenced by createNTLMv2Hash().

createByte (   $input,
  $bytes = 4,
  $isHex = true 
)
protected

Right padding with 0 to certain length.

Parameters
string$input
int$bytesLength of bytes
bool$isHexDid we provided hex value
Returns
string

Definition at line 538 of file NTLMAuthenticator.php.

References hex2bin().

Referenced by createBlob(), createLMPassword(), createLMv2Password(), createNTLMPassword(), createSecurityBuffer(), and readSubBlock().

createDesKey (   $key)
protected

Definition at line 436 of file NTLMAuthenticator.php.

References castToByte(), hex2bin(), and uRShift().

Referenced by createLMPassword(), and createNTLMPassword().

createLMPassword (   $password,
  $challenge 
)
protected

Create LMv1 response.

Parameters
string$password
string$challenge
Returns
string

Definition at line 316 of file NTLMAuthenticator.php.

References createByte(), createDesKey(), and desEncrypt().

Referenced by sendMessage3().

createLMv2Password (   $password,
  $username,
  $domain,
  $challenge,
  $client 
)
protected

Create LMv2 response.

Parameters
string$password
string$username
string$domain
string$challengeNTLM Challenge
string$clientRandom string
Returns
string

Definition at line 394 of file NTLMAuthenticator.php.

References convertTo16bit(), createByte(), md4Encrypt(), and md5Encrypt().

Referenced by sendMessage3().

createMessage1 ( )
protected

Create our message 1.

Returns
string

Definition at line 223 of file NTLMAuthenticator.php.

Referenced by sendMessage1().

createMessage3 (   $domain,
  $username,
  $workstation,
  $lmResponse,
  $ntlmResponse 
)
protected

Create our message 3.

Parameters
string$domain
string$username
string$workstation
string$lmResponse
string$ntlmResponse
Returns
string

Definition at line 241 of file NTLMAuthenticator.php.

References createSecurityBuffer(), and readSecurityBuffer().

Referenced by sendMessage3().

createNTLMPassword (   $password,
  $challenge 
)
protected

Create NTLMv1 response.

Parameters
string$password
string$challenge
Returns
string

Definition at line 345 of file NTLMAuthenticator.php.

References createByte(), createDesKey(), desEncrypt(), and md4Encrypt().

Referenced by sendMessage3().

createNTLMv2Hash (   $password,
  $username,
  $domain,
  $challenge,
  $targetInfo,
  $timestamp,
  $client 
)
protected

Create NTLMv2 response.

Parameters
string$password
string$username
string$domain
string$challengeHex values
string$targetInfoHex values
string$timestamp
string$clientRandom bytes
Returns
string
See Also
http://davenport.sourceforge.net/ntlm.html#theNtlmResponse

Definition at line 423 of file NTLMAuthenticator.php.

References convertTo16bit(), createBlob(), md4Encrypt(), and md5Encrypt().

Referenced by sendMessage3().

createSecurityBuffer (   $value,
  $offset,
  $is16 = false 
)
protected

HELPER FUNCTIONS Create our security buffer depending on length and offset.

Parameters
string$valueValue we want to put in
int$offsetstart of value
bool$is16Do we 16bit string or not?
Returns
string

Definition at line 475 of file NTLMAuthenticator.php.

References createByte().

Referenced by createMessage3().

debug (   $message)
protected
Parameters
string$message

Definition at line 653 of file NTLMAuthenticator.php.

References elseif, hex2bin(), parseMessage2(), and readSecurityBuffer().

desEncrypt (   $value,
  $key 
)
protected

ENCRYPTION ALGORITHMS DES Encryption.

Parameters
string$value
string$key
Returns
string

Definition at line 576 of file NTLMAuthenticator.php.

Referenced by createLMPassword(), and createNTLMPassword().

getAuthKeyword ( )

Get the name of the AUTH mechanism this Authenticator handles.

Returns
string

Implements Swift_Transport_Esmtp_Authenticator.

Definition at line 28 of file NTLMAuthenticator.php.

Referenced by sendMessage1().

getCorrectTimestamp (   $time)
protected

Convert a normal timestamp to a tenth of a microtime epoch time.

Parameters
string$time
Returns
string

Definition at line 365 of file NTLMAuthenticator.php.

References si2bin().

Referenced by authenticate().

getDomainAndUsername (   $name)
protected

Definition at line 297 of file NTLMAuthenticator.php.

Referenced by sendMessage3().

getRandomBytes (   $length)
protected

Create random bytes.

Parameters
$length
Returns
string

Definition at line 556 of file NTLMAuthenticator.php.

Referenced by authenticate().

hex2bin (   $hex)
protected

Hex2bin replacement for < PHP 5.4.

Parameters
string$hex
Returns
string Binary

Definition at line 641 of file NTLMAuthenticator.php.

Referenced by createByte(), createDesKey(), debug(), md4Encrypt(), parseMessage2(), and readSubBlock().

md4Encrypt (   $input)
protected

MD4 Encryption.

Parameters
string$input
Returns
string
See Also
http://php.net/manual/en/ref.hash.php

Definition at line 615 of file NTLMAuthenticator.php.

References convertTo16bit(), and hex2bin().

Referenced by createLMv2Password(), createNTLMPassword(), and createNTLMv2Hash().

md5Encrypt (   $key,
  $msg 
)
protected

MD5 Encryption.

Parameters
string$keyEncryption key
string$msgMessage to encrypt
Returns
string

Definition at line 592 of file NTLMAuthenticator.php.

Referenced by createLMv2Password(), and createNTLMv2Hash().

parseMessage2 (   $response)
protected

Fetch all details of our response (message 2).

Parameters
string$response
Returns
array our response parsed

Definition at line 123 of file NTLMAuthenticator.php.

References $response, hex2bin(), and readSubBlock().

Referenced by debug(), and sendMessage3().

readSecurityBuffer (   $value)
protected

Read our security buffer to fetch length and offset of our value.

Parameters
string$valueSecuritybuffer in hex
Returns
array array with length and offset

Definition at line 491 of file NTLMAuthenticator.php.

Referenced by createMessage3(), and debug().

readSubBlock (   $block)
protected

Read the blob information in from message2.

Parameters
$block
Returns
array

Definition at line 157 of file NTLMAuthenticator.php.

References createByte(), and hex2bin().

Referenced by parseMessage2().

sendMessage1 ( Swift_Transport_SmtpAgent  $agent)
protected

Send our auth message and returns the response.

Parameters
Swift_Transport_SmtpAgent$agent
Returns
string SMTP Response

Definition at line 109 of file NTLMAuthenticator.php.

References createMessage1(), Swift_Transport_SmtpAgent\executeCommand(), and getAuthKeyword().

Referenced by authenticate().

sendMessage3 (   $response,
  $username,
  $password,
  $timestamp,
  $client,
Swift_Transport_SmtpAgent  $agent,
  $v2 = true 
)
protected

Send our final message with all our data.

Parameters
string$responseMessage 1 response (message 2)
string$username
string$password
string$timestamp
string$client
Swift_Transport_SmtpAgent$agent
bool$v2Use version2 of the protocol
Returns
string

Definition at line 195 of file NTLMAuthenticator.php.

References $response, createLMPassword(), createLMv2Password(), createMessage3(), createNTLMPassword(), createNTLMv2Hash(), Swift_Transport_SmtpAgent\executeCommand(), getDomainAndUsername(), and parseMessage2().

Referenced by authenticate().

si2bin (   $si,
  $bits = 32 
)
protected

Definition at line 76 of file NTLMAuthenticator.php.

Referenced by getCorrectTimestamp().

uRShift (   $a,
  $b 
)
protected

Java unsigned right bitwise $a >>> $b.

Parameters
int$a
int$b
Returns
int

Definition at line 520 of file NTLMAuthenticator.php.

Referenced by createDesKey().

Member Data Documentation

const DESCONST = 'KGS!@#$%'

Definition at line 21 of file NTLMAuthenticator.php.

const NTLMSIG = "NTLMSSP\x00"

Definition at line 20 of file NTLMAuthenticator.php.