FileDocCategorySizeDatePackage
NtlmMessage.javaAPI DocJCIFS 1.3.17 API4546Tue Oct 18 15:26:24 BST 2011jcifs.ntlmssp

NtlmMessage

public abstract class NtlmMessage extends Object implements NtlmFlags
Abstract superclass for all NTLMSSP messages.

Fields Summary
protected static final byte[]
NTLMSSP_SIGNATURE
The NTLMSSP "preamble".
private static final String
OEM_ENCODING
protected static final String
UNI_ENCODING
private int
flags
Constructors Summary
Methods Summary
public booleangetFlag(int flag)
Returns the status of the specified flag.

param
flag The flag to test (i.e., NTLMSSP_NEGOTIATE_OEM).
return
A boolean indicating whether the flag is set.

        return (getFlags() & flag) != 0;
    
public intgetFlags()
Returns the flags currently in use for this message.

return
An int containing the flags in use for this message.


                             
       
        return flags;
    
static java.lang.StringgetOEMEncoding()

        return OEM_ENCODING;
    
static byte[]readSecurityBuffer(byte[] src, int index)

        int length = readUShort(src, index);
        int offset = readULong(src, index + 4);
        byte[] buffer = new byte[length];
        System.arraycopy(src, offset, buffer, 0, length);
        return buffer;
    
static intreadULong(byte[] src, int index)

        return (src[index] & 0xff) |
                ((src[index + 1] & 0xff) << 8) |
                ((src[index + 2] & 0xff) << 16) |
                ((src[index + 3] & 0xff) << 24);
    
static intreadUShort(byte[] src, int index)

        return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
    
public voidsetFlag(int flag, boolean value)
Sets or clears the specified flag.

param
flag The flag to set/clear (i.e., NTLMSSP_NEGOTIATE_OEM).
param
value Indicates whether to set (true) or clear (false) the specified flag.

        setFlags(value ? (getFlags() | flag) :
                (getFlags() & (0xffffffff ^ flag)));
    
public voidsetFlags(int flags)
Sets the flags for this message.

param
flags The flags for this message.

        this.flags = flags;
    
public abstract byte[]toByteArray()
Returns the raw byte representation of this message.

return
A byte[] containing the raw message material.

static voidwriteSecurityBuffer(byte[] dest, int offset, int bodyOffset, byte[] src)

        int length = (src != null) ? src.length : 0;
        if (length == 0) return;
        writeUShort(dest, offset, length);
        writeUShort(dest, offset + 2, length);
        writeULong(dest, offset + 4, bodyOffset);
        System.arraycopy(src, 0, dest, bodyOffset, length);
    
static voidwriteULong(byte[] dest, int offset, int ulong)

        dest[offset] = (byte) (ulong & 0xff);
        dest[offset + 1] = (byte) (ulong >> 8 & 0xff);
        dest[offset + 2] = (byte) (ulong >> 16 & 0xff);
        dest[offset + 3] = (byte) (ulong >> 24 & 0xff);
    
static voidwriteUShort(byte[] dest, int offset, int ushort)

        dest[offset] = (byte) (ushort & 0xff);
        dest[offset + 1] = (byte) (ushort >> 8 & 0xff);