Skip to content
Commits on Source (115)
......@@ -6,6 +6,8 @@
<classpathentry kind="src" path="java-sdk/ldapfilter"/>
<classpathentry kind="src" path="java-sdk/ldapjdk"/>
<classpathentry kind="src" path="java-sdk/ldapsp"/>
<classpathentry kind="src" path="java-sdk/tools"/>
<classpathentry kind="lib" path="/usr/lib/java/jss4.jar"/>
<classpathentry kind="lib" path="/usr/share/java/slf4j/slf4j-api.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
srpm:
dnf install -y git
./build.sh --with-timestamp --with-commit-id srpm
if [[ "${outdir}" != "" ]]; then \
mv ${HOME}/build/ldapjdk/SRPMS/* ${outdir}; \
fi
# BEGIN COPYRIGHT BLOCK
# (C) 2018 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
services:
- docker
env:
- FEDORA=29
- FEDORA=30
install:
- docker pull registry.fedoraproject.org/fedora:$FEDORA
- docker run
--name container
--hostname server.example.com
--tmpfs /tmp
--tmpfs /run
--volume /sys/fs/cgroup:/sys/fs/cgroup:ro
--volume $(pwd):/root/ldapjdk
--detach
-i
registry.fedoraproject.org/fedora:$FEDORA
"/usr/sbin/init"
- docker exec container /root/ldapjdk/travis/container-init.sh
- docker exec container dnf install -y dnf-plugins-core rpm-build
- docker exec container dnf copr -y enable @pki/master
- docker exec container dnf builddep -y --spec /root/ldapjdk/ldapjdk.spec
- docker exec container /root/ldapjdk/build.sh --with-timestamp --with-commit-id rpm
- docker exec container rpm -Uvh /root/build/ldapjdk/RPMS/*
- docker exec container dnf install -y 389-ds-base 389-ds-base-legacy-tools
script:
- docker exec container /root/ldapjdk/travis/ds-create.sh
- docker exec container /root/ldapjdk/travis/tools-test.sh
- docker exec container /root/ldapjdk/travis/ds-remove.sh
after_script:
- docker kill container
- docker rm container
ldapjdk (4.20.0+dfsg1-3) UNRELEASED; urgency=medium
ldapjdk (4.21.0+dfsg1-1) unstable; urgency=medium
* New upstream release.
* 01-java8-compatibility.patch: Refreshed.
* fix-slf4j-jar.diff: Use a correct path to slf4j-api.jar.
* control: Add libslf4j-java to build-depends and depends.
* classpath: Add slf4j-api.jar.
-- Timo Aaltonen <tjaalton@debian.org> Thu, 01 Aug 2019 15:22:49 +0300
ldapjdk (4.20.0+dfsg1-3) unstable; urgency=medium
[ Emmanuel Bourg ]
* Build depend on default-jdk instead of openjdk-8-jdk (Closes: #910698)
-- Emmanuel Bourg <ebourg@apache.org> Fri, 30 Nov 2018 11:09:37 +0100
-- Timo Aaltonen <tjaalton@debian.org> Mon, 03 Dec 2018 16:02:36 +0200
ldapjdk (4.20.0+dfsg1-2) unstable; urgency=medium
......
......@@ -11,6 +11,7 @@ Build-Depends-Indep:
default-jdk,
libjss-java (>= 4.5.0~),
liboro-java,
libslf4j-java,
Standards-Version: 4.1.2
Vcs-Git: https://salsa.debian.org/freeipa-team/ldapjdk.git
Vcs-Browser: https://salsa.debian.org/freeipa-team/ldapjdk
......@@ -19,6 +20,7 @@ Homepage: http://www.mozilla.org/directory/javasdk.html
Package: libldap-java
Architecture: all
Depends: libjss-java (>= 4.5.0~),
libslf4j-java,
${misc:Depends}
Description: Netscape Directory SDK for Java
The Netscape Directory SDK for Java includes the LDAP Java classes,
......
usr/share/java/ldapjdk.jar /usr/share/java/jss4.jar
usr/share/java/ldapjdk.jar /usr/share/java/jss4.jar /usr/share/java/slf4j-api.jar
......@@ -3,45 +3,45 @@ Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/java-sdk/build.xml
+++ b/java-sdk/build.xml
@@ -184,14 +184,17 @@
@@ -185,14 +185,17 @@
<target name="build-jdk" depends="init">
<!-- Compile the java jdk code from ${src} into ${dest} -->
<javac srcdir="${basedir}/ldapjdk/com" destdir="${jdk.dist}"
+ release="8"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
<javac srcdir="${basedir}/ldapjdk/netscape" destdir="${jdk.dist}"
+ release="8"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
<javac srcdir="${basedir}/tools" destdir="${jdk.dist}"
+ release="8"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
@@ -199,6 +202,7 @@
@@ -200,6 +203,7 @@
<target name="build-filter" depends="init,build-jdk">
<javac srcdir="${basedir}/ldapfilter" destdir="${filter.dist}"
+ release="8"
excludes="cvs/**"
classpath="${jdk.dist}:${jsselibs}"
classpath="${jdk.dist}:${jsselibs}:${slf4j.lib}"
/>
@@ -207,6 +211,7 @@
@@ -208,6 +212,7 @@
<target name="build-beans" depends="init">
<!-- Compile the java jdk bean code from ${src} into ${dest} -->
<javac srcdir="${basedir}/ldapbeans" destdir="${jdk.dist}"
+ release="8"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
@@ -215,6 +220,7 @@
@@ -216,6 +221,7 @@
<target name="build-jndi" depends="init,build-jdk">
<!-- Compile the java code from ${src} into ${dest} -->
<javac srcdir="${basedir}/ldapsp" destdir="${jndi.dist}"
+ release="8"
excludes="cvs/**"
classpath="${jsselibs}:${basedir}/ldapsp/lib/jndi.jar"
classpath="${jsselibs}:${basedir}/ldapsp/lib/jndi.jar:${slf4j.lib}"
/>
--- a/java-sdk/build.xml
+++ b/java-sdk/build.xml
@@ -64,7 +64,7 @@
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="jss.lib" value="/usr/lib/java/jss4.jar"/>
- <property name="slf4j.lib" value="/usr/share/java/slf4j/slf4j-api.jar" />
+ <property name="slf4j.lib" value="/usr/share/java/slf4j-api.jar" />
<!-- the following is to setup the correct info for sun jsse which
is jdk dependent -->
#placeholder
01-java8-compatibility.patch
fix-slf4j-jar.diff
......@@ -64,6 +64,7 @@
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="jss.lib" value="/usr/lib/java/jss4.jar"/>
<property name="slf4j.lib" value="/usr/share/java/slf4j/slf4j-api.jar" />
<!-- the following is to setup the correct info for sun jsse which
is jdk dependent -->
......@@ -185,22 +186,22 @@
<!-- Compile the java jdk code from ${src} into ${dest} -->
<javac srcdir="${basedir}/ldapjdk/com" destdir="${jdk.dist}"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
<javac srcdir="${basedir}/ldapjdk/netscape" destdir="${jdk.dist}"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
<javac srcdir="${basedir}/tools" destdir="${jdk.dist}"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
</target>
<target name="build-filter" depends="init,build-jdk">
<javac srcdir="${basedir}/ldapfilter" destdir="${filter.dist}"
excludes="cvs/**"
classpath="${jdk.dist}:${jsselibs}"
classpath="${jdk.dist}:${jsselibs}:${slf4j.lib}"
/>
</target>
......@@ -208,7 +209,7 @@
<!-- Compile the java jdk bean code from ${src} into ${dest} -->
<javac srcdir="${basedir}/ldapbeans" destdir="${jdk.dist}"
excludes="cvs/**"
classpath="${jsselibs}"
classpath="${jsselibs}:${slf4j.lib}"
/>
</target>
......@@ -216,7 +217,7 @@
<!-- Compile the java code from ${src} into ${dest} -->
<javac srcdir="${basedir}/ldapsp" destdir="${jndi.dist}"
excludes="cvs/**"
classpath="${jsselibs}:${basedir}/ldapsp/lib/jndi.jar"
classpath="${jsselibs}:${basedir}/ldapsp/lib/jndi.jar:${slf4j.lib}"
/>
</target>
......@@ -231,14 +232,14 @@
author="true"
version="true"
use="true"
classpath="${basedir}/ldapjdk:${jss.lib}:${basedir}/ldapjdk/lib/jss32_stub.jar:${basedir}/ldapbeans"
classpath="${basedir}/ldapjdk:${jss.lib}:${basedir}/ldapjdk/lib/jss32_stub.jar:${basedir}/ldapbeans:${slf4j.lib}"
additionalparam="-Xdoclint:none">
</javadoc>
<javadoc packagenames="com.netscape.jndi.ldap.controls.*"
sourcepath="${basedir}/ldapsp"
destdir="${doc.dist}/ldapsp"
classpath="${jndi.dist}:${basedir}/ldapsp:${basedir}/ldapsp/lib/jndi.jar"
classpath="${jndi.dist}:${basedir}/ldapsp:${basedir}/ldapsp/lib/jndi.jar:${slf4j.lib}"
author="true"
version="true"
use="true"
......
......@@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.lang.reflect.*;
import java.lang.reflect.Method;
import java.util.Hashtable;
/**
......@@ -52,7 +52,7 @@ class DynamicInvoker {
String[] argNames )
throws LDAPException {
try {
java.lang.reflect.Method m = getMethod( packageName,
Method m = getMethod( packageName,
methodName,
argNames );
if ( m != null ) {
......@@ -83,16 +83,16 @@ class DynamicInvoker {
}
}
String key = packageName + "." + methodName + "." + suffix;
if ( (method = (Method)(m_methodLookup.get(key))) != null ) {
if ((method = m_methodLookup.get(key)) != null) {
return method;
}
Class c = Class.forName( packageName );
Class<?> c = Class.forName( packageName );
Method[] m = c.getMethods();
for ( int i = 0; i < m.length; i++ ) {
Class[] params = m[i].getParameterTypes();
if ( m[i].getName().equals(methodName) &&
signatureCorrect( params, args ) ) {
Class<?>[] params = m[i].getParameterTypes();
if (m[i].getName().equals(methodName) &&
signatureCorrect(params, args)) {
m_methodLookup.put( key, m[i] );
return m[i];
}
......@@ -106,7 +106,7 @@ class DynamicInvoker {
}
}
static private boolean signatureCorrect( Class params[],
static private boolean signatureCorrect( Class<?> params[],
String args[] ) {
if ( args == null ) {
return true;
......@@ -127,5 +127,5 @@ class DynamicInvoker {
return true;
}
private static Hashtable m_methodLookup = new Hashtable();
private static Hashtable<String, Method> m_methodLookup = new Hashtable<>();
}
......@@ -37,9 +37,16 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.io.*;
import java.util.*;
import org.ietf.ldap.ber.stream.*;
import java.io.IOException;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.ietf.ldap.ber.stream.BERElement;
import org.ietf.ldap.ber.stream.BEROctetString;
import org.ietf.ldap.ber.stream.BERSequence;
import org.ietf.ldap.ber.stream.BERSet;
/**
* Represents the name and values of an attribute in an entry.
......@@ -49,7 +56,7 @@ import org.ietf.ldap.ber.stream.*;
*/
public class LDAPAttribute implements Cloneable, Serializable {
static final long serialVersionUID = -4594745735452202600L;
static final long serialVersionUID = -4594745735452202600L;
private String name = null;
private byte[] nameBuf = null;
/**
......@@ -68,7 +75,7 @@ public class LDAPAttribute implements Cloneable, Serializable {
values = new Object[attr.values.length];
for (int i = 0; i < attr.values.length; i++) {
values[i] = new byte[((byte[])attr.values[i]).length];
System.arraycopy((byte[])attr.values[i], 0, (byte[])values[i], 0,
System.arraycopy(attr.values[i], 0, values[i], 0,
((byte[])attr.values[i]).length);
}
}
......@@ -150,8 +157,8 @@ public class LDAPAttribute implements Cloneable, Serializable {
* Returns an enumerator for the string values of an attribute.
* @return enumerator for the string values.
*/
public Enumeration getStringValues() {
Vector v = new Vector();
public Enumeration<String> getStringValues() {
Vector<String> v = new Vector<>();
synchronized(this) {
try {
for (int i=0; i<values.length; i++) {
......@@ -167,15 +174,15 @@ public class LDAPAttribute implements Cloneable, Serializable {
}
return v.elements();
}
/**
* Returns the values of the attribute as an array of <CODE>String</CODE>
* Returns the values of the attribute as an array of <CODE>String</CODE>
* objects.
* @return array of attribute values. Each element in the array
* is a <CODE>String</CODE> object.
*/
public String[] getStringValueArray() {
String s[] = new String[values.length];
synchronized(this) {
try {
......@@ -192,19 +199,19 @@ public class LDAPAttribute implements Cloneable, Serializable {
}
return s;
}
/**
* Returns an enumerator for the values of the attribute in <CODE>byte[]</CODE>
* format.
* @return a set of attribute values. Each element in the enumeration
* is of type <CODE>byte[]</CODE>.
*/
public Enumeration getByteValues() {
Vector v = new Vector();
public Enumeration<byte[]> getByteValues() {
Vector<byte[]> v = new Vector<>();
synchronized(this) {
for (int i=0; i<values.length; i++) {
if ( values[i] != null ) {
v.addElement(values[i]);
v.addElement((byte[])values[i]);
} else {
v.addElement( new byte[0] );
}
......@@ -225,7 +232,7 @@ public class LDAPAttribute implements Cloneable, Serializable {
try {
for (int i=0; i < values.length; i++) {
b[i] = new byte[((byte[])(values[i])).length];
System.arraycopy((byte[])values[i], 0, (byte[])b[i], 0,
System.arraycopy(values[i], 0, b[i], 0,
((byte[])(values[i])).length);
}
} catch (Exception e) {
......@@ -233,9 +240,9 @@ public class LDAPAttribute implements Cloneable, Serializable {
}
}
return b;
}
/**
* Returns the name of the attribute.
* @return name of the attribute.
......@@ -518,7 +525,7 @@ public class LDAPAttribute implements Cloneable, Serializable {
*/
private String getParamString() {
StringBuffer sb = new StringBuffer();
if ( values.length > 0 ) {
for (int i = 0; i < values.length; i++) {
if (i != 0) {
......@@ -535,7 +542,7 @@ public class LDAPAttribute implements Cloneable, Serializable {
else {
sb.append(sval);
}
} catch (Exception e) {
if (val != null) {
sb.append("<binary value, length:");
......
......@@ -37,14 +37,12 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
/**
* The definition of an attribute type in the schema.
* <A HREF="http://www.ietf.org/rfc/rfc2252.txt"
* TARGET="_blank">RFC 2252, Lightweight Directory Access Protocol (v3):
* Attribute Syntax Definitions</A> covers the types of information
* to specify when defining an attribute type. According to the RFC,
* to specify when defining an attribute type. According to the RFC,
* the description of an attribute type can include the following:
* <P>
*
......@@ -156,16 +154,16 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
* for the attribute in dotted-decimal format; MAY be null
* @param ordering Object Identifier of the ordering matching rule
* for the attribute in dotted-decimal format; MAY be null
* @param substring Object Identifier of the substring matching rule
* @param substring Object Identifier of the substring matching rule
* for the attribute in dotted-decimal format; MAY be null
* @param collective true if this is a collective attribute.
* @param userMod true if the attribute is modifiable by users.
* @param usage One of the following:
* @param collective true if this is a collective attribute.
* @param userMod true if the attribute is modifiable by users.
* @param usage One of the following:
* <UL>
* <LI>USER_APPLICATIONS
* <LI>DIRECTORY_OPERATION
* <LI>DISTRIBUTED_OPERATION
* <LI>DSA_OPERATION
* <LI>DIRECTORY_OPERATION
* <LI>DISTRIBUTED_OPERATION
* <LI>DSA_OPERATION
* </UL>
*/
public LDAPAttributeSchema( String[] names,
......@@ -251,9 +249,9 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
}
/**
* Returns the Object Identifier of the equality matching rule in effect
* Returns the Object Identifier of the equality matching rule in effect
* for this attribute, or null if there is none
* @return the Object Identifier of the equality matching rule in effect
* @return the Object Identifier of the equality matching rule in effect
* for this attribute, or null if there is none
*/
public String getEqualityMatchingRule() {
......@@ -261,9 +259,9 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
}
/**
* Returns the Object Identifier of the order matching rule in effect
* Returns the Object Identifier of the order matching rule in effect
* for this attribute, or null if there is none
* @return the Object Identifier of the order matching rule in effect
* @return the Object Identifier of the order matching rule in effect
* for this attribute, or null if there is none
*/
public String getOrderMatchingRule() {
......@@ -271,9 +269,9 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
}
/**
* Returns the Object Identifier of the substring matching rule in effect
* Returns the Object Identifier of the substring matching rule in effect
* for this attribute, or null if there is none
* @return the Object Identifier of the substring matching rule in effect
* @return the Object Identifier of the substring matching rule in effect
* for this attribute, or null if there is none
*/
public String getSubstringMatchingRule() {
......@@ -315,9 +313,9 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
* @return the usage property of the object; one of the following:
* <UL>
* <LI>USER_APPLICATIONS
* <LI>DIRECTORY_OPERATION
* <LI>DISTRIBUTED_OPERATION
* <LI>DSA_OPERATION
* <LI>DIRECTORY_OPERATION
* <LI>DISTRIBUTED_OPERATION
* <LI>DSA_OPERATION
* </UL>
*/
public int getUsage() {
......@@ -385,8 +383,7 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
* @return <code>true</code> if collective
*/
public boolean isCollective() {
return (properties != null) ? properties.containsKey( COLLECTIVE ) :
false;
return properties != null ? properties.containsKey( COLLECTIVE ) : false;
}
/**
......@@ -396,8 +393,7 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
* <code>false</code> if multi-valued.
*/
public boolean isSingleValued() {
return (properties != null) ? properties.containsKey( SINGLE ) :
false;
return properties != null ? properties.containsKey( SINGLE ) : false;
}
/**
......@@ -406,9 +402,7 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
* @return <code>true</code> if modifiable by users
*/
public boolean isUserModifiable() {
return (properties != null) ?
!properties.containsKey( NO_USER_MODIFICATION ) :
true;
return properties != null ? !properties.containsKey( NO_USER_MODIFICATION ) : true;
}
/**
......@@ -439,22 +433,22 @@ public class LDAPAttributeSchema extends LDAPSchemaElement {
public static final String USAGE = "USAGE";
// Usage constants
/** An ordinary user attribute
/** An ordinary user attribute
*/
public static final int USER_APPLICATIONS = 0;
/** An operational attribute used for a directory operation or which
* holds a directory specific value
* holds a directory specific value
*/
public static final int DIRECTORY_OPERATION = 1;
/** An operational attribute used to hold server (DSA) information that
* is shared among servers holding replicas of the entry
* is shared among servers holding replicas of the entry
*/
public static final int DISTRIBUTED_OPERATION = 2;
/** An operational attribute used to hold server (DSA) information that
* is local to a server
* is local to a server
*/
public static final int DSA_OPERATION = 3;
......
......@@ -38,10 +38,11 @@
package org.ietf.ldap;
import java.io.Serializable;
import java.util.*;
import org.ietf.ldap.client.*;
import org.ietf.ldap.client.opers.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;
/**
* Represents a set of attributes (for example, the set of attributes
......@@ -50,9 +51,9 @@ import org.ietf.ldap.client.opers.*;
* @version 1.0
* @see org.ietf.ldap.LDAPAttribute
*/
public class LDAPAttributeSet implements Cloneable, Serializable, Set {
public class LDAPAttributeSet implements Cloneable, Serializable, Set<LDAPAttribute> {
static final long serialVersionUID = 5018474561697778100L;
HashMap _attrHash = null;
HashMap<String, LDAPAttribute> _attrHash = null;
LDAPAttribute[] _attrs = new LDAPAttribute[0];
/* If there are less attributes than this in the set, it's not worth
creating a Hashtable - faster and cheaper most likely to do string
......@@ -101,12 +102,12 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* @param attr attribute to add to this set
* @return true if this set changed as a result of the call
*/
public synchronized boolean add( Object attr ) {
public synchronized boolean add( LDAPAttribute attr ) {
if ( attr instanceof LDAPAttribute ) {
if ( contains( attr ) ) {
return false;
}
LDAPAttribute attrib = (LDAPAttribute)attr;
LDAPAttribute attrib = attr;
LDAPAttribute[] vals = new LDAPAttribute[_attrs.length+1];
for ( int i = 0; i < _attrs.length; i++ ) {
vals[i] = _attrs[i];
......@@ -129,14 +130,14 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* @param attrs attributes to add to this set
* @return true if any attribute was added
*/
public synchronized boolean addAll( Collection attrs ) {
public synchronized boolean addAll( Collection<? extends LDAPAttribute> attrs ) {
if ( attrs == null ) {
return false;
}
boolean present = true;
Iterator it = attrs.iterator();
Iterator<? extends LDAPAttribute> it = attrs.iterator();
while( it.hasNext() ) {
Object attr = it.next();
LDAPAttribute attr = it.next();
if ( !contains( attr ) ) {
present = true;
add( attr );
......@@ -192,9 +193,9 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* @param attrs attributes whose presence in this set is to be tested
* @return true if the attribute set contains the specified attributes
*/
public boolean containsAll( Collection attrs ) {
public boolean containsAll( Collection<?> attrs ) {
if ( _attrHash != null ) {
Iterator it = attrs.iterator();
Iterator<?> it = attrs.iterator();
while( it.hasNext() ) {
if ( !_attrHash.containsValue( it.next() ) ) {
return false;
......@@ -256,7 +257,7 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
*
* @return an iterator over the attributes in this attribute set
*/
public Iterator iterator() {
public Iterator<LDAPAttribute> iterator() {
return _attrHash.values().iterator();
}
......@@ -296,12 +297,12 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* @param attrs the attributes to remove
* @return true if any attribute was removed
*/
public boolean removeAll( Collection attrs ) {
public boolean removeAll( Collection<?> attrs ) {
if ( attrs == null ) {
return false;
}
boolean present = true;
Iterator it = attrs.iterator();
Iterator<?> it = attrs.iterator();
while( it.hasNext() ) {
Object attr = it.next();
if ( !contains( attr ) ) {
......@@ -320,21 +321,21 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* @return true if the attribute set was changed as a result of the
* operation
*/
public boolean retainAll( Collection attrs ) {
HashMap newmap = new HashMap();
Iterator it = attrs.iterator();
public boolean retainAll( Collection<?> attrs ) {
HashMap<String, LDAPAttribute> newmap = new HashMap<>();
Iterator<?> it = attrs.iterator();
while( it.hasNext() ) {
Object attr = it.next();
if ( attr instanceof LDAPAttribute ) {
newmap.put( ((LDAPAttribute)attr).getName().toLowerCase(),
attr );
(LDAPAttribute)attr );
}
}
if ( newmap.equals( _attrHash ) ) {
return false;
} else {
_attrHash = newmap;
_attrs = (LDAPAttribute[])_attrHash.values().toArray(
_attrs = _attrHash.values().toArray(
new LDAPAttribute[0] );
return true;
}
......@@ -404,7 +405,7 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* </PRE>
*
* @param subtype semi-colon delimited list of subtypes
* to find within attribute names.
* to find within attribute names.
* For example:
* <PRE>
* "lang-ja" // Only Japanese language subtypes
......@@ -428,12 +429,12 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
String[] searchTypes = new String[st.countTokens()];
int i = 0;
while( st.hasMoreTokens() ) {
searchTypes[i] = (String)st.nextToken();
searchTypes[i] = st.nextToken();
i++;
}
Iterator it = _attrHash.values().iterator();
Iterator<LDAPAttribute> it = _attrHash.values().iterator();
while( it.hasNext() ) {
LDAPAttribute attr = (LDAPAttribute)it.next();
LDAPAttribute attr = it.next();
if( attr.hasSubtypes( searchTypes ) )
attrs.add( new LDAPAttribute( attr ) );
}
......@@ -457,7 +458,7 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
if ( attrName == null ) {
return null;
} else if ( _attrHash != null ) {
return (LDAPAttribute)_attrHash.get( attrName.toLowerCase() );
return _attrHash.get( attrName.toLowerCase() );
} else {
for ( int i = 0; i < _attrs.length; i++ ) {
if ( attrName.equalsIgnoreCase(_attrs[i].getName()) ) {
......@@ -475,7 +476,7 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
if ( (_attrHash == null) &&
(force || (_attrs.length >= ATTR_COUNT_REQUIRES_HASH)) ) {
if ( _attrHash == null ) {
_attrHash = new HashMap();
_attrHash = new HashMap<>();
} else {
_attrHash.clear();
}
......@@ -499,7 +500,7 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
* they contain the specified <CODE>lang</CODE> subtype and if
* the set contains no attribute having only the <CODE>lang</CODE>
* subtype. (For example, <CODE>getAttribute( "cn", "lang-ja" )</CODE>
* returns <CODE>cn;lang-ja;phonetic</CODE> only if the
* returns <CODE>cn;lang-ja;phonetic</CODE> only if the
* <CODE>cn;lang-ja</CODE> attribute does not exist.)
* <P>
*
......@@ -626,7 +627,7 @@ public class LDAPAttributeSet implements Cloneable, Serializable, Set {
for( int i = 0; i < _attrs.length; i++ ) {
if (i != 0) {
sb.append(" ");
}
}
sb.append(_attrs[i].toString());
}
return sb.toString();
......
......@@ -37,14 +37,16 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import java.io.*;
import org.ietf.ldap.client.*;
import org.ietf.ldap.util.*;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import java.util.zip.CRC32;
import org.ietf.ldap.util.DN;
/**
* <CODE>LDAPCache</CODE> represents an in-memory cache that you can use
* <CODE>LDAPCache</CODE> represents an in-memory cache that you can use
* to reduce the number of search requests sent to the LDAP server.
* <P>
*
......@@ -102,11 +104,11 @@ import java.util.zip.CRC32;
* All clones of an <CODE>LDAPConnection</CODE> object share
* the same <CODE>LDAPCache</CODE> object.
* <P>
*
* Note that <CODE>LDAPCache</CODE> does not maintain consistency
*
* Note that <CODE>LDAPCache</CODE> does not maintain consistency
* with the directory, so that cached search results may no longer be
* valid after a directory update. If the same application is performing
* both cached searches and directory updates, then the
* valid after a directory update. If the same application is performing
* both cached searches and directory updates, then the
* application should flush the corresponding cache entries after an update.
* To do this use the <CODE>flushEntries</CODE> method.
* <P>
......@@ -124,16 +126,16 @@ import java.util.zip.CRC32;
*/
public class LDAPCache implements Serializable {
static final long serialVersionUID = 6275167993337814294L;
/**
* A hashtable of search results. The key is created from the search
* request parameters (see createKey() method). The value is a Vector
* where the first element is a Long integer representing the size
* of all entries, followed by the actual search result entries (of type
* LDAPEntry).
*/
private Hashtable m_cache;
*/
private Hashtable<Long, Vector<Object>> m_cache;
/**
* A list of cached entries ordered by time (augments m_cache). Each
* element in the list is a 2 element Vector where the element at index
......@@ -144,7 +146,7 @@ public class LDAPCache implements Serializable {
* exceeds the cache available space, the extra space is made by removing
* existing cached results in the order of their entry in the cache.
*/
private Vector m_orderedStruct;
private Vector<Vector<Long>> m_orderedStruct;
private long m_timeToLive;
private long m_maxSize;
......@@ -164,7 +166,7 @@ public class LDAPCache implements Serializable {
private long m_hits = 0;
private long m_flushes = 0;
// Debug can be activated by defining debug.cache property
// Debug can be activated by defining debug.cache property
private static boolean m_debug = false;
static {
try {
......@@ -175,7 +177,7 @@ public class LDAPCache implements Serializable {
;// In browser access to property might not be allowed
}
}
/**
* Constructs a new <CODE>LDAPCache</CODE> object, using the
* specified maximum size of the cache (in bytes) and the maximum
......@@ -299,11 +301,11 @@ public class LDAPCache implements Serializable {
DN dn2 = new DN(dn);
Enumeration e = m_cache.keys();
Enumeration<Long> e = m_cache.keys();
while(e.hasMoreElements()) {
Long key = (Long)e.nextElement();
Vector val = (Vector)m_cache.get(key);
Long key = e.nextElement();
Vector<Object> val = m_cache.get(key);
// LDAPEntries start at idx 1, at idx 0 is a Long
// (size of all LDAPEntries returned by search())
......@@ -330,13 +332,13 @@ public class LDAPCache implements Serializable {
if (j < size2) {
for (int k=0; k<m_orderedStruct.size(); k++) {
Vector v = (Vector)m_orderedStruct.elementAt(k);
if (key.equals((Long)v.elementAt(0))) {
Vector<Long> v = m_orderedStruct.elementAt(k);
if (key.equals(v.elementAt(0))) {
m_orderedStruct.removeElementAt(k);
break;
}
}
Vector entry = (Vector)m_cache.remove(key);
Vector<Object> entry = m_cache.remove(key);
m_remainingSize += ((Long)entry.firstElement()).longValue();
if (m_debug)
System.out.println("DEBUG: Successfully removed entry ->"+key);
......@@ -476,10 +478,8 @@ public class LDAPCache implements Serializable {
* @param key the key for the cache entry
* @return the cache entry.
*/
synchronized Object getEntry(Long key) {
Object obj = null;
obj = m_cache.get(key);
synchronized Vector<Object> getEntry(Long key) {
Vector<Object> obj = m_cache.get(key);
m_totalOpers++;
if (m_debug) {
......@@ -503,7 +503,7 @@ public class LDAPCache implements Serializable {
*/
synchronized void flushEntries()
{
Vector v = null;
Vector<Long> v = null;
boolean delete = false;
long currTime = System.currentTimeMillis();
......@@ -513,14 +513,14 @@ public class LDAPCache implements Serializable {
if (m_orderedStruct.size() <= 0)
break;
v = (Vector)m_orderedStruct.firstElement();
long diff = currTime-((Long)v.elementAt(1)).longValue();
v = m_orderedStruct.firstElement();
long diff = currTime-v.elementAt(1).longValue();
if (diff >= m_timeToLive) {
Long key = (Long)v.elementAt(0);
Long key = v.elementAt(0);
if (m_debug)
System.out.println("DEBUG: Timer flush entry whose key is "+key);
Vector entry = (Vector)m_cache.remove(key);
Vector<Object> entry = m_cache.remove(key);
m_remainingSize += ((Long)entry.firstElement()).longValue();
// always delete the first one
......@@ -551,13 +551,13 @@ public class LDAPCache implements Serializable {
if (m_cache.get(key) != null)
return false;
Vector v = (Vector)value;
Vector<Object> v = (Vector<Object>)value;
long size = ((Long)v.elementAt(0)).longValue();
if (size > m_maxSize) {
if (m_debug) {
System.out.println("Failed to add an entry to the cache since the new entry exceeds the cache size");
}
}
return false;
}
......@@ -565,9 +565,9 @@ public class LDAPCache implements Serializable {
// cache
if (size > m_remainingSize) {
while (true) {
Vector element = (Vector)m_orderedStruct.firstElement();
Long str = (Long)element.elementAt(0);
Vector val = (Vector)m_cache.remove(str);
Vector<Long> element = m_orderedStruct.firstElement();
Long str = element.elementAt(0);
Vector<Object> val = m_cache.remove(str);
if (m_debug)
System.out.println("DEBUG: The spare size of the cache is not big enough "+
"to hold the new entry, deleting the entry whose key -> "+str);
......@@ -582,7 +582,7 @@ public class LDAPCache implements Serializable {
m_remainingSize -= size;
m_cache.put(key, v);
Vector element = new Vector(2);
Vector<Long> element = new Vector<>(2);
element.addElement(key);
element.addElement(new Long(System.currentTimeMillis()));
m_orderedStruct.addElement(element);
......@@ -590,8 +590,8 @@ public class LDAPCache implements Serializable {
// Start TTL Timer if first entry is added
if (m_orderedStruct.size() == 1) {
scheduleTTLTimer();
}
}
if (m_debug)
{
System.out.println("DEBUG: Adding a new entry whose key -> "+key);
......@@ -611,13 +611,13 @@ public class LDAPCache implements Serializable {
return;
}
if (m_timer == null) {
if (m_timer == null) {
m_timer = new TTLTimer(this);
}
Vector v = (Vector)m_orderedStruct.firstElement();
Vector<Long> v = m_orderedStruct.firstElement();
long currTime = System.currentTimeMillis();
long creationTime = ((Long)v.elementAt(1)).longValue();
long creationTime = v.elementAt(1).longValue();
long timeout = creationTime + m_timeToLive - currTime;
if (timeout > 0) {
m_timer.start(timeout);
......@@ -626,9 +626,9 @@ public class LDAPCache implements Serializable {
flushEntries();
scheduleTTLTimer();
}
}
}
/**
* Gets the number of entries being cached.
* @return the number of entries being cached.
......@@ -690,12 +690,12 @@ public class LDAPCache implements Serializable {
*/
private void init(long ttl, long size)
{
m_cache = new Hashtable();
m_cache = new Hashtable<>();
m_timeToLive = ttl*1000;
m_maxSize = size;
m_remainingSize = size;
m_dns = null;
m_orderedStruct = new Vector();
m_orderedStruct = new Vector<>();
}
/**
......@@ -800,7 +800,7 @@ class TTLTimer implements Runnable{
m_timeout = timeout;
if (Thread.currentThread() != t) {
stop();
}
}
t = new Thread(this, "LDAPCache-TTLTimer");
t.setDaemon(true);
t.start();
......
......@@ -64,7 +64,7 @@ class LDAPCheckComm {
} else if (sec.toString().startsWith("netscape.security.AppletSecurity")) {
/* Running as applet. Is PrivilegeManager around? */
try {
Class c = Class.forName(classPackage);
Class<?> c = Class.forName(classPackage);
java.lang.reflect.Method[] m = c.getMethods();
for( int i = 0; i < m.length; i++ ) {
if ( m[i].getName().equals(name) ) {
......
......@@ -38,8 +38,10 @@
package org.ietf.ldap;
import java.io.Serializable;
import java.util.*;
import java.text.*;
import java.text.Collator;
import java.util.Comparator;
import java.util.Iterator;
import java.util.Locale;
/**
* Compares LDAP entries based on one or more attribute values.
......@@ -54,8 +56,8 @@ import java.text.*;
* @see LDAPSearchResults#sort
*/
public class LDAPCompareAttrNames
implements Comparator, Serializable {
public class LDAPCompareAttrNames<E>
implements Comparator<E>, Serializable {
static final long serialVersionUID = -2567450425231175944L;
private String _attrs[];
......@@ -103,8 +105,8 @@ public class LDAPCompareAttrNames
* <P>
*
* Use an array of strings to specify the set of attributes
* to use for sorting. If the values of the first attribute
* (the name specified in <CODE>attribute[0]</CODE>) are equal,
* to use for sorting. If the values of the first attribute
* (the name specified in <CODE>attribute[0]</CODE>) are equal,
* then the values of the next attribute are compared.
* <P>
*
......@@ -131,7 +133,7 @@ public class LDAPCompareAttrNames
* <P>
*
* Use an array of strings to specify the set of attributes
* to use for sorting. If the values of the first attribute
* to use for sorting. If the values of the first attribute
* (the name specified in <CODE>attribute[0]</CODE>)
* are equal, then the values of the next attribute are compared.
* <P>
......@@ -183,7 +185,7 @@ public class LDAPCompareAttrNames
public boolean equals( Object obj ) {
return super.equals( obj );
}
/**
* Gets the locale, if any, used for collation. If the locale is null,
* an ordinary string comparison is used for sorting.
......@@ -283,9 +285,9 @@ public class LDAPCompareAttrNames
*/
int attrGreater( LDAPEntry entry1, LDAPEntry entry2,
int attrPos ) {
Iterator attrSet1 =
Iterator<LDAPAttribute> attrSet1 =
entry1.getAttributeSet().iterator();
Iterator attrSet2 =
Iterator<LDAPAttribute> attrSet2 =
entry2.getAttributeSet().iterator();
String value1 = null;
......@@ -294,20 +296,20 @@ public class LDAPCompareAttrNames
boolean ascending = _ascending[attrPos];
while ( attrSet2.hasNext() ) {
LDAPAttribute currAttr = (LDAPAttribute)(attrSet2.next());
LDAPAttribute currAttr = attrSet2.next();
if ( !attrName.equalsIgnoreCase (currAttr.getName()) ) {
continue;
}
value2 = (String)(currAttr.getStringValues().nextElement());
value2 = currAttr.getStringValues().nextElement();
break;
}
while ( attrSet1.hasNext() ) {
LDAPAttribute currAttr = (LDAPAttribute)(attrSet1.next());
LDAPAttribute currAttr = attrSet1.next();
if ( !attrName.equalsIgnoreCase(currAttr.getName()) ) {
continue;
}
value1 = (String)(currAttr.getStringValues().nextElement());
value1 = currAttr.getStringValues().nextElement();
break;
}
......
......@@ -37,14 +37,24 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import org.ietf.ldap.client.*;
import org.ietf.ldap.client.opers.*;
import org.ietf.ldap.ber.stream.*;
import org.ietf.ldap.util.*;
import java.io.*;
import java.net.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import org.ietf.ldap.ber.stream.BERElement;
import org.ietf.ldap.client.JDAPBERTagDecoder;
import org.ietf.ldap.client.opers.JDAPAbandonRequest;
import org.ietf.ldap.client.opers.JDAPProtocolOp;
import org.ietf.ldap.client.opers.JDAPUnbindRequest;
/**
* Multiple LDAPConnection clones can share a single physical connection,
......@@ -79,9 +89,9 @@ class LDAPConnThread extends Thread {
transient private static int _highMsgId;
transient private InputStream _serverInput;
transient private OutputStream _serverOutput;
transient private Hashtable _requests;
transient private Hashtable _messages = null;
transient private Vector _registered;
transient private Hashtable<Integer, LDAPMessageQueue> _requests;
transient private Hashtable<Integer, Vector<Object>> _messages = null;
transient private Vector<LDAPConnection> _registered;
transient private boolean _disconnected = false;
transient private LDAPCache _cache = null;
transient private boolean _doRun = true;
......@@ -97,7 +107,7 @@ class LDAPConnThread extends Thread {
// trace msgs
static SimpleDateFormat _timeFormat =
new SimpleDateFormat( "HH:mm:ss.SSS" );
/**
* Constructs a connection thread that maintains connection to the
* LDAP server
......@@ -112,8 +122,8 @@ class LDAPConnThread extends Thread {
throws LDAPException {
super( "LDAPConnThread " + connMgr.getHost() +
":" + connMgr.getPort() );
_requests = new Hashtable ();
_registered = new Vector ();
_requests = new Hashtable<>();
_registered = new Vector<>();
_connMgr = connMgr;
_socket = connMgr.getSocket();
setCache( cache );
......@@ -122,7 +132,7 @@ class LDAPConnThread extends Thread {
// Allow the application to exit if only LDAPConnThread threads are
// running
setDaemon( true );
try {
_serverInput =
new BufferedInputStream( _socket.getInputStream() );
......@@ -146,7 +156,7 @@ class LDAPConnThread extends Thread {
sb.append( _connMgr.getLDAPUrl() );
logTraceMessage( sb );
}
start(); /* start the thread */
}
......@@ -175,16 +185,16 @@ class LDAPConnThread extends Thread {
} else if ( traceOutput instanceof LDAPTraceWriter ) {
_traceOutput = traceOutput;
}
}
}
}
void logTraceMessage( StringBuffer msg ) {
if ( _traceOutput == null ) {
return;
}
String timeStamp = _timeFormat.format( new Date() );
StringBuffer sb = new StringBuffer( timeStamp );
sb.append( " ldc=" );
sb.append( " ldc=" );
sb.append( _connMgr.getID() );
synchronized( _sendRequestLock ) {
......@@ -199,7 +209,7 @@ class LDAPConnThread extends Thread {
}
}
}
/**
* Set the cache to use for searches.
* @param cache The cache to use for searches; <CODE>null</CODE> for no
......@@ -207,7 +217,7 @@ class LDAPConnThread extends Thread {
*/
synchronized void setCache( LDAPCache cache ) {
_cache = cache;
_messages = (_cache != null) ? new Hashtable() : null;
_messages = (_cache != null) ? new Hashtable<>() : null;
}
/**
......@@ -220,7 +230,7 @@ class LDAPConnThread extends Thread {
synchronized( _sendRequestLock ) {
_highMsgId = (_highMsgId + 1) % MAXMSGID;
return _highMsgId;
}
}
}
/**
......@@ -237,7 +247,7 @@ class LDAPConnThread extends Thread {
throw new LDAPException ( "not connected to a server",
LDAPException.SERVER_DOWN );
}
LDAPMessage msg =
LDAPMessage msg =
new LDAPMessage( allocateId(), request, cons.getControls() );
LDAPMessageQueueImpl queue = (LDAPMessageQueueImpl)toNotify;
......@@ -249,7 +259,7 @@ class LDAPConnThread extends Thread {
queue );
/* Notify the backlog checker that there may be another
outstanding request */
resultRetrieved();
resultRetrieved();
}
queue.addRequest( msg.getMessageID(), conn, this,
cons.getTimeLimit() );
......@@ -259,7 +269,7 @@ class LDAPConnThread extends Thread {
try {
if ( _traceOutput != null ) {
logTraceMessage( msg.toTraceString() );
}
}
msg.write( _serverOutput );
_serverOutput.flush();
} catch ( IOException e ) {
......@@ -299,16 +309,16 @@ class LDAPConnThread extends Thread {
if ( !_disconnected ) {
LDAPSearchConstraints cons = conn.getSearchConstraints();
sendRequest( null, new JDAPUnbindRequest(), null, cons );
}
}
// must be set after the call to sendRequest
_doRun =false;
if ( (_thread != null) &&
(_thread != Thread.currentThread()) ) {
_thread.interrupt();
// Wait up to 1 sec for thread to accept disconnect
// notification. When the interrupt is accepted,
// _thread is set to null. See run() method.
......@@ -316,9 +326,9 @@ class LDAPConnThread extends Thread {
wait( 1000 );
}
catch ( InterruptedException e ) {
}
}
}
} catch( Exception e ) {
LDAPConnection.printDebug( e.toString() );
}
......@@ -353,7 +363,7 @@ class LDAPConnThread extends Thread {
} finally {
_socket = null;
}
_disconnected = true;
/**
......@@ -361,18 +371,18 @@ class LDAPConnThread extends Thread {
* terminated by the user
*/
_connMgr.disconnect();
/**
* Cancel all outstanding requests
*/
if ( _requests != null ) {
Enumeration requests = _requests.elements();
Enumeration<LDAPMessageQueue> requests = _requests.elements();
while ( requests.hasMoreElements() ) {
LDAPMessageQueueImpl queue =
(LDAPMessageQueueImpl)requests.nextElement();
queue.removeAllRequests( this );
}
}
}
/**
* Notify all the registered queues of this mishap.
......@@ -383,12 +393,12 @@ class LDAPConnThread extends Thread {
*/
if ( _registered != null ) {
Vector registerCopy = (Vector)_registered.clone();
Vector<LDAPConnection> registerCopy = (Vector<LDAPConnection>)_registered.clone();
Enumeration cancelled = registerCopy.elements();
Enumeration<LDAPConnection> cancelled = registerCopy.elements();
while ( cancelled.hasMoreElements() ) {
LDAPConnection c = (LDAPConnection)cancelled.nextElement();
LDAPConnection c = cancelled.nextElement();
c.deregisterConnection();
}
}
......@@ -410,10 +420,10 @@ class LDAPConnThread extends Thread {
if ( _requests.size() == 0 ) {
return;
}
Enumeration queues = _requests.elements();
Enumeration<LDAPMessageQueue> queues = _requests.elements();
while( queues.hasMoreElements() ) {
LDAPMessageQueue l = (LDAPMessageQueue)queues.nextElement();
LDAPMessageQueue l = queues.nextElement();
// If there are any threads waiting for a regular response
// message, we have to go read the next incoming message
......@@ -422,7 +432,7 @@ class LDAPConnThread extends Thread {
}
LDAPSearchQueue sl = (LDAPSearchQueue)l;
// should never happen, but just in case
if ( sl.getSearchConstraints() == null ) {
return;
......@@ -430,24 +440,24 @@ class LDAPConnThread extends Thread {
int slMaxBacklog = sl.getSearchConstraints().getMaxBacklog();
int slBatchSize = sl.getSearchConstraints().getBatchSize();
// Disabled backlog check ?
if ( slMaxBacklog == 0 ) {
return;
}
// Synch op with zero batch size ?
if ( !sl.isAsynchOp() && slBatchSize == 0 ) {
return;
}
// Max backlog not reached for at least one queue ?
// (if multiple requests are in progress)
if ( sl.getMessageCount() < slMaxBacklog ) {
return;
}
}
}
synchronized( this ) {
wait( 3000 );
}
......@@ -469,7 +479,7 @@ class LDAPConnThread extends Thread {
* Reads from the LDAP server input stream for incoming LDAP messages.
*/
public void run() {
// if there is a problem establishing a connection to the server,
// stop the thread right away...
if ( !_doRun ) {
......@@ -500,7 +510,7 @@ class LDAPConnThread extends Thread {
if ( _traceOutput != null ) {
logTraceMessage( msg.toTraceString() );
}
}
// pass in the ber element size to approximate the size of the
// cache entry, thereby avoiding serialization of the entry
......@@ -540,7 +550,7 @@ class LDAPConnThread extends Thread {
// For synch search operations, controls are also copied into
// LDAPSearchResults (see LDAPConnection.checkSearchMsg())
if ( ! l.isAsynchOp() ) {
/* Were there any controls for this client? */
LDAPControl[] con = msg.getControls();
if ( con != null ) {
......@@ -549,22 +559,22 @@ class LDAPConnThread extends Thread {
if ( ldc != null ) {
ldc.setResponseControls(
this, new LDAPResponseControl(ldc, msgid, con) );
}
}
}
}
if ( (_cache != null) && (l instanceof LDAPSearchQueue) ) {
cacheSearchResult( (LDAPSearchQueue)l, msg, size );
}
}
l.addMessage( msg );
if ( msg instanceof LDAPResponse ) {
_requests.remove( messageID );
if ( _requests.size() == 0 ) {
_backlogCheckCounter = BACKLOG_CHKCNT;
}
}
}
}
}
/**
......@@ -582,19 +592,19 @@ class LDAPConnThread extends Thread {
LDAPMessage msg, int size ) {
Integer messageID = new Integer( msg.getMessageID() );
Long key = l.getKey();
Vector v = null;
Vector<Object> v = null;
if ( (_cache == null) || (key == null) ) {
return;
}
if ( msg instanceof LDAPSearchResult ) {
// Get the vector containing the LDAPMessages for the specified
// messageID
v = (Vector)_messages.get( messageID );
v = _messages.get( messageID );
if ( v == null ) {
_messages.put( messageID, v = new Vector() );
_messages.put( messageID, v = new Vector<>() );
v.addElement( new Long(0) );
}
......@@ -602,7 +612,7 @@ class LDAPConnThread extends Thread {
if ( ((Long)v.firstElement()).longValue() == -1L ) {
return;
}
// add the size of the current LDAPMessage to the lump sum
// assume the size of LDAPMessage is more or less the same as
// the size of LDAPEntry. Eventually an LDAPEntry object gets
......@@ -616,8 +626,8 @@ class LDAPConnThread extends Thread {
v.removeAllElements();
v.addElement( new Long(-1L) );
return;
}
}
// update the lump sum located in the first element of the vector
v.setElementAt( new Long(entrySize), 0 );
......@@ -628,10 +638,10 @@ class LDAPConnThread extends Thread {
} else if ( msg instanceof LDAPSearchResultReference ) {
// If a search reference is received disable caching of
// this search request
v = (Vector)_messages.get(messageID);
// this search request
v = _messages.get(messageID);
if ( v == null ) {
_messages.put( messageID, v = new Vector() );
_messages.put( messageID, v = new Vector<>() );
}
else {
v.removeAllElements();
......@@ -643,15 +653,15 @@ class LDAPConnThread extends Thread {
// The search request has completed. Store the cache entry
// in the LDAPCache if the operation has succeded and caching
// is not disabled due to the entry size or referrals
boolean fail = ((LDAPResponse)msg).getResultCode() > 0;
v = (Vector)_messages.remove( messageID );
v = _messages.remove( messageID );
if ( !fail ) {
// If v is null, meaning there are no search results from the
// server
if ( v == null ) {
v = new Vector();
v = new Vector<>();
v.addElement(new Long(0));
}
......@@ -673,7 +683,7 @@ class LDAPConnThread extends Thread {
if ( !_doRun ) {
return;
}
LDAPMessageQueueImpl l =
(LDAPMessageQueueImpl)_requests.remove( new Integer(id) );
// Clean up cache if enabled
......@@ -701,7 +711,7 @@ class LDAPConnThread extends Thread {
LDAPException.OTHER ) );
return null;
}
return (LDAPMessageQueue)_requests.put( new Integer(id), toNotify );
return _requests.put( new Integer(id), toNotify );
}
/**
......@@ -717,9 +727,9 @@ class LDAPConnThread extends Thread {
_connMgr.invalidateConnection();
try {
// notify each queue that the server is down.
Enumeration requests = _requests.elements();
Enumeration<LDAPMessageQueue> requests = _requests.elements();
while ( requests.hasMoreElements() ) {
LDAPMessageQueueImpl queue =
(LDAPMessageQueueImpl)requests.nextElement();
......
......@@ -58,7 +58,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
private boolean referrals = false;
private int _time_limit = 0;
private LDAPControl[] _serverControls = null;
private Hashtable _properties = null;
private Hashtable<String, Object> _properties = null;
/**
* Constructs an <CODE>LDAPConstraints</CODE> object that specifies
......@@ -87,7 +87,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
* sequence when attempting to resolve a request
* @see org.ietf.ldap.LDAPConnection#setOption(int, java.lang.Object)
*/
public LDAPConstraints( int msLimit, boolean doReferrals,
public LDAPConstraints( int msLimit, boolean doReferrals,
LDAPReferralHandler handler,
int hop_limit ) {
_time_limit = msLimit;
......@@ -96,7 +96,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
_hop_limit = hop_limit;
_serverControls = null;
}
/**
* Returns the maximum number of milliseconds to wait for any operation
* under these constraints. If 0, there is no maximum time limit
......@@ -111,10 +111,10 @@ public class LDAPConstraints implements Cloneable, Serializable {
/**
* Specifies whether nor not referrals are followed automatically.
* Returns <CODE>true</CODE> if referrals are to be followed automatically,
* or <CODE>false</CODE> if referrals throw an
* or <CODE>false</CODE> if referrals throw an
* <CODE>LDAPReferralException</CODE>.
* @return <CODE>true</CODE> if referrals are followed automatically,
* <CODE>false</CODE> if referrals throw an
* @return <CODE>true</CODE> if referrals are followed automatically,
* <CODE>false</CODE> if referrals throw an
* <CODE>LDAPReferralException</CODE>.
*/
public boolean getReferralFollowing() {
......@@ -122,7 +122,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
}
/**
* Returns the object that provides the mechanism for authenticating to the
* Returns the object that provides the mechanism for authenticating to the
* server on referrals. This object must implement the
* <CODE>LDAPReferralHandler</CODE> interface.
* @return object to use to authenticate to the server on referrals
......@@ -153,7 +153,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
}
/**
* Gets a property of a constraints object which has been assigned with
* Gets a property of a constraints object which has been assigned with
* setProperty. Null is returned if the property is not defined.
*
* @param name Name of the property to retrieve
......@@ -172,7 +172,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
* an LDAPException with the result code <CODE>LDAPException.TIME_LIMIT
* </CODE> is thrown.
* @param msLimit Maximum number of milliseconds to wait for operation
* results (0 by default, which means that there is no maximum time
* results (0 by default, which means that there is no maximum time
* limit.)
* @see org.ietf.ldap.LDAPException#LDAP_TIMEOUT
*/
......@@ -184,22 +184,22 @@ public class LDAPConstraints implements Cloneable, Serializable {
/**
* Specifies whether or not referrals are followed automatically.
* Specify <CODE>true</CODE> if referrals are to be followed automatically,
* or <CODE>false</CODE> if referrals are to throw an
* <CODE>LDAPReferralException</CODE>.
* or <CODE>false</CODE> if referrals are to throw an
* <CODE>LDAPReferralException</CODE>.
* (By default, this is set to <CODE>false</CODE>.)
* <P>
* If you set this to <CODE>true</CODE>, you need to create an object of
* this class that implements either the <CODE>LDAPAuthHandler</CODE> or
* <CODE>LDAPBind</CODE> interface. The <CODE>LDAPAuthProvider</CODE> object
* If you set this to <CODE>true</CODE>, you need to create an object of
* this class that implements either the <CODE>LDAPAuthHandler</CODE> or
* <CODE>LDAPBind</CODE> interface. The <CODE>LDAPAuthProvider</CODE> object
* identifies the method for retrieving authentication information which
* will be used when connecting to other LDAP servers during referrals.
* will be used when connecting to other LDAP servers during referrals.
* This object should be passed to the <CODE>setReferralHandler</CODE> method.
* Alternatively, the <CODE>LDAPBind</CODE> object identifies an
* authentication mechanism to be used instead of the default
* authentication mechanism when following referrals. This
* Alternatively, the <CODE>LDAPBind</CODE> object identifies an
* authentication mechanism to be used instead of the default
* authentication mechanism when following referrals. This
* object should be passed to the <CODE>setBindHandler</CODE> method.
* @param doReferrals set to <CODE>true</CODE> if referrals should be
* followed automatically, or <CODE>False</CODE> if referrals should throw
* @param doReferrals set to <CODE>true</CODE> if referrals should be
* followed automatically, or <CODE>False</CODE> if referrals should throw
* an <CODE>LDAPReferralException</CODE>
* @see org.ietf.ldap.LDAPBindHandler
* @see org.ietf.ldap.LDAPAuthHandler
......@@ -213,8 +213,8 @@ public class LDAPConstraints implements Cloneable, Serializable {
* Specifies the object that provides the method for getting
* authentication information. This object must belong to a class
* that implements the <CODE>LDAPReferralHandler</CODE> interface.
* (By default, this is <CODE>null</CODE>.) This method sets the
* <CODE>LDAPReferralHandler</CODE> object to null for this constraint.
* (By default, this is <CODE>null</CODE>.) This method sets the
* <CODE>LDAPReferralHandler</CODE> object to null for this constraint.
* @param handler object to use to obtain information for
* authenticating to other LDAP servers during referrals
*/
......@@ -251,9 +251,9 @@ public class LDAPConstraints implements Cloneable, Serializable {
}
/**
* Sets a property of the constraints object.
* No property names have been defined at this time, but the mechanism
* is in place in order to support revisional as well as dynamic and
* Sets a property of the constraints object.
* No property names have been defined at this time, but the mechanism
* is in place in order to support revisional as well as dynamic and
* proprietary extensions to operation modifiers.
*
* @param name Name of the property to set
......@@ -261,7 +261,7 @@ public class LDAPConstraints implements Cloneable, Serializable {
*/
public void setProperty( String name, Object value ) throws LDAPException {
if ( _properties == null ) {
_properties = new Hashtable();
_properties = new Hashtable<>();
}
_properties.put( name, value );
}
......@@ -303,11 +303,11 @@ public class LDAPConstraints implements Cloneable, Serializable {
o.referrals = this.referrals;
o._referralHandler = this._referralHandler;
o._hop_limit = this._hop_limit;
if ( (this._serverControls != null) &&
if ( (this._serverControls != null) &&
(this._serverControls.length > 0) ) {
o._serverControls = new LDAPControl[this._serverControls.length];
for( int i = 0; i < this._serverControls.length; i++ )
o._serverControls[i] =
o._serverControls[i] =
(LDAPControl)this._serverControls[i].clone();
}
return o;
......