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,14 +83,14 @@ 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();
Class<?>[] params = m[i].getParameterTypes();
if (m[i].getName().equals(methodName) &&
signatureCorrect(params, args)) {
m_methodLookup.put( key, 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.
......@@ -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++) {
......@@ -199,12 +206,12 @@ public class LDAPAttribute implements Cloneable, Serializable {
* @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) {
......
......@@ -37,8 +37,6 @@
* ***** 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"
......@@ -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;
}
/**
......
......@@ -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;
}
......@@ -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();
}
......
......@@ -37,12 +37,14 @@
* ***** 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
* to reduce the number of search requests sent to the LDAP server.
......@@ -132,7 +134,7 @@ public class LDAPCache implements Serializable {
* 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
......@@ -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;
......@@ -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,7 +551,7 @@ 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) {
......@@ -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);
......@@ -615,9 +615,9 @@ public class LDAPCache implements Serializable {
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);
......@@ -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<>();
}
/**
......
......@@ -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[];
......@@ -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;
......@@ -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 );
......@@ -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;
}
/**
......@@ -366,7 +376,7 @@ class LDAPConnThread extends Thread {
* Cancel all outstanding requests
*/
if ( _requests != null ) {
Enumeration requests = _requests.elements();
Enumeration<LDAPMessageQueue> requests = _requests.elements();
while ( requests.hasMoreElements() ) {
LDAPMessageQueueImpl queue =
(LDAPMessageQueueImpl)requests.nextElement();
......@@ -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();
}
}
......@@ -411,9 +421,9 @@ class LDAPConnThread extends Thread {
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
......@@ -582,7 +592,7 @@ 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;
......@@ -592,9 +602,9 @@ class LDAPConnThread extends Thread {
// 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) );
}
......@@ -629,9 +639,9 @@ class LDAPConnThread extends Thread {
// If a search reference is received disable caching of
// this search request
v = (Vector)_messages.get(messageID);
v = _messages.get(messageID);
if ( v == null ) {
_messages.put( messageID, v = new Vector() );
_messages.put( messageID, v = new Vector<>() );
}
else {
v.removeAllElements();
......@@ -645,13 +655,13 @@ class LDAPConnThread extends Thread {
// 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));
}
......@@ -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 );
}
/**
......@@ -719,7 +729,7 @@ class LDAPConnThread extends Thread {
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
......@@ -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 );
}
......