|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mina.proxy.handlers.http.ntlm.NTLMUtilities
public class NTLMUtilities
NTLMUtilities.java - NTLM functions used for authentication and unit testing.
| Field Summary |
|---|
| Constructor Summary | |
|---|---|
NTLMUtilities()
|
|
| Method Summary | |
|---|---|
static byte[] |
createType1Message(String workStation,
String domain,
Integer customFlags,
byte[] osVersion)
see http://davenport.sourceforge.net/ntlm.html#theType1Message |
static byte[] |
createType3Message(String user,
String password,
byte[] challenge,
String target,
String workstation,
Integer serverFlags,
byte[] osVersion)
|
static byte[] |
extractChallengeFromType2Message(byte[] msg)
Extracts the NTLM challenge from the type 2 message as an 8 byte array. |
static int |
extractFlagsFromType2Message(byte[] msg)
Extracts the NTLM flags from the type 2 message. |
static byte[] |
extractTargetInfoFromType2Message(byte[] msg,
Integer msgFlags)
Extracts the target information block from the type 2 message. |
static String |
extractTargetNameFromType2Message(byte[] msg,
Integer msgFlags)
Extracts the target name from the type 2 message. |
static byte[] |
getOsVersion()
Tries to return a valid OS version on Windows systems. |
static void |
printTargetInformationBlockFromType2Message(byte[] msg,
Integer msgFlags,
PrintWriter out)
Prints to the PrintWriter the target information block extracted
from the type 2 message. |
static byte[] |
readSecurityBufferTarget(byte[] msg,
int securityBufferOffset)
Reads the byte array described by the security buffer stored at the securityBufferOffset offset. |
static void |
writeOSVersion(byte majorVersion,
byte minorVersion,
short buildNumber,
byte[] b,
int offset)
Writes the Windows OS version passed in as three byte values (majorVersion.minorVersion.buildNumber) to the given byte array at offset. |
static byte[] |
writeSecurityBuffer(short length,
int bufferOffset)
|
static void |
writeSecurityBuffer(short length,
short allocated,
int bufferOffset,
byte[] b,
int offset)
Writes a security buffer to the given array b at offset
offset. |
static int |
writeSecurityBufferAndUpdatePointer(ByteArrayOutputStream baos,
short len,
int pointer)
Writes a security buffer and returns the pointer of the position where to write the next security buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NTLMUtilities()
| Method Detail |
|---|
public static final byte[] writeSecurityBuffer(short length,
int bufferOffset)
writeSecurityBuffer(short, short, int, byte[], int)
public static final void writeSecurityBuffer(short length,
short allocated,
int bufferOffset,
byte[] b,
int offset)
b at offset
offset. A security buffer defines a pointer to an area
in the data that defines some data with a variable length. This allows
to have a semi-fixed length header thus making a little bit easier
the decoding process in the NTLM protocol.
length - the length of the security bufferallocated - the allocated space for the security buffer (should be
greater or equal to lengthbufferOffset - the offset from the main array where the currently
defined security buffer will be writtenb - the buffer in which we write the security bufferoffset - the offset at which to write to the b buffer
public static final void writeOSVersion(byte majorVersion,
byte minorVersion,
short buildNumber,
byte[] b,
int offset)
offset.
majorVersion - the major version numberminorVersion - the minor version numberbuildNumber - the build numberb - the target byte arrayoffset - the offset at which to write in the arraypublic static final byte[] getOsVersion()
public static final byte[] createType1Message(String workStation,
String domain,
Integer customFlags,
byte[] osVersion)
workStation - the workstation namedomain - the domain namecustomFlags - custom flags, if null then
NTLMConstants.DEFAULT_CONSTANTS is usedosVersion - the os version of the client, if null then
NTLMConstants.DEFAULT_OS_VERSION is used
public static final int writeSecurityBufferAndUpdatePointer(ByteArrayOutputStream baos,
short len,
int pointer)
throws IOException
baos - the stream where the security buffer is writtenlen - the length of the security bufferpointer - the position where the security buffer can be written
IOException - if writing to the ByteArrayOutputStream failspublic static final byte[] extractChallengeFromType2Message(byte[] msg)
msg - the type 2 message byte array
public static final int extractFlagsFromType2Message(byte[] msg)
msg - the type 2 message byte array
public static final byte[] readSecurityBufferTarget(byte[] msg,
int securityBufferOffset)
securityBufferOffset offset.
msg - the message where to read the security buffer and it's valuesecurityBufferOffset - the offset at which to read the security buffer
public static final String extractTargetNameFromType2Message(byte[] msg,
Integer msgFlags)
throws UnsupportedEncodingException
msg - the type 2 message byte arraymsgFlags - the flags if null then flags are extracted from the
type 2 message
UnsupportedEncodingException - if unable to use the
needed UTF-16LE or ASCII charsets
public static final byte[] extractTargetInfoFromType2Message(byte[] msg,
Integer msgFlags)
msg - the type 2 message byte arraymsgFlags - the flags if null then flags are extracted from the
type 2 message
public static final void printTargetInformationBlockFromType2Message(byte[] msg,
Integer msgFlags,
PrintWriter out)
throws UnsupportedEncodingException
PrintWriter the target information block extracted
from the type 2 message.
msg - the type 2 messagemsgFlags - the flags if null then flags are extracted from the
type 2 messageout - the output target for the information
UnsupportedEncodingException - if unable to use the
needed UTF-16LE or ASCII charsets
public static final byte[] createType3Message(String user,
String password,
byte[] challenge,
String target,
String workstation,
Integer serverFlags,
byte[] osVersion)
user - the user namepassword - the user passwordchallenge - the challenge responsetarget - the target nameworkstation - the client workstation's nameserverFlags - the flags set by the clientosVersion - the os version of the client
http://davenport.sourceforge.net/ntlm.html#theType3Message
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||