2728N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 2728N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2728N/A * This code is free software; you can redistribute it and/or modify it 2728N/A * under the terms of the GNU General Public License version 2 only, as 2728N/A * published by the Free Software Foundation. Oracle designates this 2728N/A * particular file as subject to the "Classpath" exception as provided 2728N/A * by Oracle in the LICENSE file that accompanied this code. 2728N/A * This code is distributed in the hope that it will be useful, but WITHOUT 2728N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2728N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2728N/A * version 2 for more details (a copy is included in the LICENSE file that 2728N/A * You should have received a copy of the GNU General Public License version 2728N/A * 2 along with this work; if not, write to the Free Software Foundation, 2728N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2728N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2728N/A * or visit www.oracle.com if you need additional information or have any 2728N/A * The NTLM server, not multi-thread enabled.<p> 2728N/A * Server server = new Server(null, "REALM") { 2728N/A * public char[] getPassword(String ntdomain, String username) { 2728N/A * case "dummy": return "t0pSeCr3t".toCharArray(); 2728N/A * case "guest": return "".toCharArray(); 2728N/A * // Receive client request as type1 2728N/A * byte[] type2 = server.type2(type1, nonce); 2728N/A * // Send type2 to client and receive type3 2728N/A * Creates a Server instance. 2728N/A * @param version the NTLM version to use, which can be: 2728N/A * <li>NTLM: Original NTLM v1 2728N/A * <li>NTLM2: NTLM v1 with Client Challenge 2728N/A * If null, all versions will be supported. Please note that unless NTLM2 2728N/A * is selected, authentication succeeds if one of LM (or LMv2) or 2728N/A * NTLM (or NTLMv2) is verified. 2728N/A * @param domain the domain, must not be null 4357N/A * @throws NTLMException if {@code domain} is null. 2728N/A * Generates the Type 2 message 2728N/A * @param type1 the Type1 message received, must not be null 2728N/A * @param nonce the random 8-byte array to be used in message generation, 2728N/A * @return the message generated 4357N/A * @throws NTLMException if the incoming message is invalid, or 2728N/A * Verifies the Type3 message received from client and returns 2728N/A * various negotiated information. 2728N/A * @param type3 the incoming Type3 message from client, must not be null 2728N/A * @param nonce the same nonce provided in {@link #type2}, must not be null 2728N/A * @return username and hostname of the client in a byte array 4357N/A * @throws NTLMException if the incoming message is invalid, or 4357N/A "type1 or nonce cannot be null");
2728N/A /*if (incomingDomain != null && !incomingDomain.equals(domain)) { 2728N/A throw new NTLMException(NTLMException.DOMAIN_UNMATCH, 2728N/A "Wrong domain: " + incomingDomain + 2728N/A " vs " + domain); // Needed? 2728N/A "None of LM and NTLM verified");
2728N/A * Retrieves the password for a given user. This method should be 2728N/A * overridden in a concrete class. 2728N/A * @param domain can be null 2728N/A * @param username must not be null 2728N/A * @return the password for the user, or null if unknown