/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* NTLM authentication implemented according to MS-NLMP, version 12.1
* @since 1.7
*/
class NTLM {
private static final boolean DEBUG =
final Version v;
final boolean writeLM;
final boolean writeNTLM;
switch (version) {
"Unknown version " + version);
}
try {
} catch (NoSuchPaddingException e) {
throw new AssertionError();
} catch (NoSuchAlgorithmException e) {
throw new AssertionError();
}
}
/**
* Prints out a formatted string, called in various places inside then NTLM
* "ntlm.debug" is set, <code>System.out.printf(format, args)</code> is
* called. This method is designed to be overridden by child classes to
* @param format a format string
* @param args the arguments referenced by <code>format</code>
* @see java.io.PrintStream#printf(java.lang.String, java.lang.Object[])
*/
if (DEBUG) {
}
}
/**
* Prints out the content of a byte array, called in various places inside
* property "ntlm.debug" is set, the hexdump of the array is printed into
* System.out. This method is designed to be overridden by child classes to
* @param bytes the byte array to print out
*/
if (DEBUG) {
try {
} catch (IOException ioe) {
// Impossible
}
}
}
/**
* Reading an NTLM packet
*/
static class Reader {
private final byte[] internal;
}
try {
} catch (ArrayIndexOutOfBoundsException ex) {
"Input message incorrect size");
}
}
try {
} catch (ArrayIndexOutOfBoundsException ex) {
"Input message incorrect size");
}
}
try {
} catch (ArrayIndexOutOfBoundsException ex) {
"Input message incorrect size");
}
}
try {
return Arrays.copyOfRange(
} catch (ArrayIndexOutOfBoundsException ex) {
"Input message incorrect size");
}
}
throws NTLMException {
try {
} catch (UnsupportedEncodingException ex) {
"Invalid input encoding");
}
}
}
/**
* Writing an NTLM packet
*/
static class Writer {
/**
* Starts writing a NTLM packet
* @param type NEGOTIATE || CHALLENGE || AUTHENTICATE
* @param len the base length, without security buffers
*/
assert len < 256;
internal = new byte[256];
}
}
}
}
} else {
}
}
}
try {
} catch (UnsupportedEncodingException ex) {
assert false;
}
}
byte[] getBytes() {
}
}
/* Convert a 7 byte array to an 8 byte array (for a des key with parity)
* input starts at offset off
*/
}
byte[] out = new byte[8];
return out;
}
byte[] pwb1 = new byte [14];
if (len > 14)
len = 14;
try {
byte[] result = new byte [21];
return result;
} catch (InvalidKeyException ive) {
// Will not happen, all key material are 8 bytes
assert false;
} catch (InvalidKeySpecException ikse) {
// Will not happen, we only feed DESKeySpec to DES factory
assert false;
} catch (IllegalBlockSizeException ibse) {
// Will not happen, we encrypt 8 bytes
assert false;
} catch (BadPaddingException bpe) {
// Will not happen, this is encryption
assert false;
}
return null; // will not happen, we returned already
}
byte[] result = new byte [21];
return result;
}
/* key is a 21 byte array. Split it into 3 7 byte chunks,
* Convert each to 8 byte DES keys, encrypt the text arg with
* each key and return the three results in a sequential []
*/
try {
byte[] result = new byte[24];
return result;
assert false;
} catch (BadPaddingException ex) {
assert false;
} catch (InvalidKeySpecException ex) {
assert false;
} catch (InvalidKeyException ex) {
assert false;
}
return null;
}
try {
} catch (InvalidKeyException ex) {
assert false;
} catch (RuntimeException e) {
assert false;
}
return null;
}
try {
return result;
} catch (UnsupportedEncodingException ex) {
assert false;
}
return null;
}
}
}
// Password in ASCII and UNICODE
try {
} catch (UnsupportedEncodingException ex) {
return null;
}
}
try {
} catch (UnsupportedEncodingException ex) {
return null;
}
}
}