3261N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Implements the CRAM-MD5 SASL client-side mechanism. 0N/A * CRAM-MD5 has no initial response. It receives bytes from 0N/A * the server as a challenge, which it hashes by using MD5 and the password. 0N/A * It concatenates the authentication ID with this result and returns it 0N/A * as the response to the challenge. At that point, the exchange is complete. 0N/A * @author Vincent Ryan 0N/A * @author Rosanna Lee 0N/A * Creates a SASL mechanism with client credentials that it needs 0N/A * to participate in CRAM-MD5 authentication exchange with the server. 0N/A * @param authID A non-null string representing the principal 0N/A * being authenticated. 0N/A * @param pw A non-null String or byte[] 0N/A * containing the password. If it is an array, it is first cloned. 0N/A "CRAM-MD5: authentication ID and password must be specified");
0N/A this.
pw =
pw;
// caller should have already cloned 0N/A * CRAM-MD5 has no initial response. 0N/A * Processes the challenge data. 0N/A * The server sends a challenge data using which the client must 0N/A * compute an MD5-digest with its password as the key. 0N/A * @param challengeData A non-null byte array containing the challenge 0N/A * data from the server. 0N/A * @return A non-null byte array containing the response to be sent to 0N/A * @throws SaslException If platform does not have MD5 support 0N/A * @throw IllegalStateException if this method is invoked more than once. 0N/A // See if we've been here before 0N/A "CRAM-MD5 authentication already completed");
0N/A "CRAM-MD5 authentication previously aborted due to error");
0N/A // generate a keyed-MD5 digest from the user's password and challenge. 0N/A // clear it when we no longer need it 0N/A // response is username + " " + digest