/** Constructor to use when message contents are known */ NTLMMessage(final String messageBody, final int expectedType) throws NtlmEngineException { messageContents = Base64.getDecoder().decode(messageBody); // Look for NTLM message if (messageContents.length < SIGNATURE.length) { throw new NtlmEngineException("NTLM message decoding error - packet too short"); } int i = 0; while (i < SIGNATURE.length) { if (messageContents[i] != SIGNATURE[i]) { throw new NtlmEngineException("NTLM message expected - instead got unrecognized bytes"); } i++; } // Check to be sure there's a type 2 message indicator next final int type = readULong(SIGNATURE.length); if (type != expectedType) { throw new NtlmEngineException("NTLM type " + Integer.toString(expectedType) + " message expected - instead got type " + Integer.toString(type)); } currentOutputPosition = messageContents.length; }
/** Constructor to use when message contents are known */ NTLMMessage(final String messageBody, final int expectedType) throws NtlmEngineException { messageContents = Base64.decode(messageBody); // Look for NTLM message if (messageContents.length < SIGNATURE.length) { throw new NtlmEngineException("NTLM message decoding error - packet too short"); } int i = 0; while (i < SIGNATURE.length) { if (messageContents[i] != SIGNATURE[i]) { throw new NtlmEngineException("NTLM message expected - instead got unrecognized bytes"); } i++; } // Check to be sure there's a type 2 message indicator next final int type = readULong(SIGNATURE.length); if (type != expectedType) { throw new NtlmEngineException("NTLM type " + Integer.toString(expectedType) + " message expected - instead got type " + Integer.toString(type)); } currentOutputPosition = messageContents.length; }
/** Read a ulong from a position within the message buffer */ protected int readULong(final int position) throws NtlmEngineException { return NtlmEngine.readULong(messageContents, position); }
/** Read a ulong from a position within the message buffer */ protected final int readULong(final int position) throws NtlmEngineException { return NtlmEngine.readULong(messageContents, position); }