/*
* 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.
*/
/**
* Represents identity information about an anonymous LDAP connection.
* This base class contains the following information:
* - protocol version number
* - server's hostname (case-insensitive)
* - server's port number
* - prototype type (plain or ssl)
* - controls to be sent with the LDAP bind request
*
* All other identity classes must be a subclass of ClientId.
* Identity subclasses would add more distinguishing information, depending
* on the type of authentication that the connection is to have.
*
* The equals() and hashCode() methods of this class and its subclasses are
* important because they are used to determine whether two requests for
* the same connection are identical, and thus whether the same connection
* may be shared. This is especially important for authenticated connections
* because a mistake would result in a serious security violation.
*
* @author Rosanna Lee
*/
class ClientId {
final private int version;
final private int port;
final private int myHash;
final private int ctlHash;
private boolean isDefaultSockFactory = false;
final public static boolean debug = false;
//
// Needed for custom socket factory pooling
//
this.socketFactory = socketFactory;
if ((socketFactory != null) &&
try {
} catch (Exception e) {
// LdapPoolManager and Connection classes.
if (debug) {
e.printStackTrace();
}
}
} else {
isDefaultSockFactory = true;
}
// The SocketFactory field is not used in the myHash
// computation as there is no right way to compute the hash code
// for this field. There is no harm in skipping it from the hash
// computation
}
return false;
}
&& (equalsSockFactory(other));
}
public int hashCode() {
return myHash;
}
if (c == null) {
return 0;
}
int code = 0;
for (int i = 0; i < c.length; i++) {
}
return code;
}
if (a == b) {
return true; // both null or same
}
return false; // one is non-null
}
return false;
}
for (int i = 0; i < a.length; i++) {
|| a[i].isCritical() != b[i].isCritical()
b[i].getEncodedValue())) {
return false;
}
}
return true;
}
return true;
}
else if (!other.isDefaultSockFactory) {
return invokeComparator(other, this);
} else {
return invokeComparator(this, other);
}
}
// delegate the comparison work to the SocketFactory class
// as there is no enough information here, to do the comparison
try {
} catch(Exception e) {
if (debug) {
e.printStackTrace();
}
// Failed to invoke the comparator; flag unequality
return false;
}
return true;
}
return false;
}
return "";
}
}
}
}
}