...
 
Commits (107)
......@@ -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
......@@ -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;
}
......
......@@ -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;
......
......@@ -37,14 +37,14 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import java.util.Vector;
/**
* The definition of a DIT content rule in the schema.
* <A HREF="http://www.ietf.org/rfc/rfc2252.txt"
* TARGET="_blank">RFC 2252, Lightweight Directory Access Protocol (v3):
* DIT Content Rule Description</A> covers the types of information
* to specify when defining a DIT content rule. According to the RFC,
* to specify when defining a DIT content rule. According to the RFC,
* the description of a DIT content rule can include the following:
* <P>
*
......@@ -201,33 +201,33 @@ public class LDAPDITContentRuleSchema extends LDAPSchemaElement {
Object o = properties.get( MAY );
if ( o != null ) {
if ( o instanceof Vector ) {
may = (Vector)o;
may = (Vector<String>)o;
} else {
may.addElement( o );
may.addElement((String)o);
}
}
o = properties.get( MUST );
if ( o != null ) {
if ( o instanceof Vector ) {
must = (Vector)o;
must = (Vector<String>)o;
} else {
must.addElement( o );
must.addElement((String)o);
}
}
o = properties.get( NOT );
if ( o != null ) {
if ( o instanceof Vector ) {
not = (Vector)o;
not = (Vector<String>)o;
} else {
not.addElement( o );
not.addElement((String)o);
}
}
o = properties.get( AUX );
if ( o != null ) {
if ( o instanceof Vector ) {
aux = (Vector)o;
aux = (Vector<String>)o;
} else {
aux.addElement( o );
aux.addElement((String)o);
}
}
}
......@@ -330,10 +330,10 @@ public class LDAPDITContentRuleSchema extends LDAPSchemaElement {
* @param vals values for list
* @return a String with a list of values.
*/
protected String vectorToList( Vector vals ) {
protected String vectorToList( Vector<String> vals ) {
String val = "( ";
for( int i = 0; i < vals.size(); i++ ) {
val += (String)vals.elementAt(i) + ' ';
val += vals.elementAt(i) + ' ';
if ( i < (vals.size() - 1) ) {
val += "$ ";
}
......@@ -372,8 +372,8 @@ public class LDAPDITContentRuleSchema extends LDAPSchemaElement {
NOT
};
private Vector must = new Vector();
private Vector may = new Vector();
private Vector aux = new Vector();
private Vector not = new Vector();
private Vector<String> must = new Vector<>();
private Vector<String> may = new Vector<>();
private Vector<String> aux = new Vector<>();
private Vector<String> not = new Vector<>();
}
......@@ -37,10 +37,11 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import org.ietf.ldap.client.*;
import org.ietf.ldap.client.opers.*;
import java.io.*;
import java.io.IOException;
import java.io.Serializable;
import java.util.Hashtable;
import java.util.Locale;
import java.util.PropertyResourceBundle;
/**
* Indicates that an error has occurred. An <CODE>LDAPException</CODE>
......@@ -599,7 +600,7 @@ public class LDAPException extends Exception
private String matchedDN = null;
private Throwable rootException = null;
private Locale m_locale = Locale.getDefault();
private static Hashtable cacheResource = new Hashtable();
private static Hashtable<String, PropertyResourceBundle> cacheResource = new Hashtable<>();
private static final String baseName = "org/ietf/ldap/errors/ErrorCodes";
/**
......@@ -1056,7 +1057,7 @@ public class LDAPException extends Exception
try {
String localeStr = locale.toString();
PropertyResourceBundle p =
(PropertyResourceBundle)cacheResource.get(localeStr);
cacheResource.get(localeStr);
if (p == null) {
p = LDAPResourceBundle.getBundle(baseName);
......
......@@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import java.util.Vector;
/**
* The definition of a matching rule in the schema.
......@@ -184,7 +184,7 @@ public class LDAPMatchingRuleSchema extends LDAPAttributeSchema {
if ( use != null ) {
parseValue( use );
}
Vector v = (Vector)properties.get( "APPLIES" );
Vector<String> v = (Vector<String>)properties.get( "APPLIES" );
if ( v != null ) {
_attributes = new String[v.size()];
v.copyInto( _attributes );
......@@ -313,6 +313,6 @@ public class LDAPMatchingRuleSchema extends LDAPAttributeSchema {
// Qualifiers tracked explicitly
static final String[] EXPLICIT = { OBSOLETE,
SYNTAX };
private String[] _attributes = null;
}
......@@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import java.util.Vector;
/**
* The definition of a matching rule use in the schema.
......@@ -154,7 +154,7 @@ public class LDAPMatchingRuleUseSchema extends LDAPAttributeSchema {
public LDAPMatchingRuleUseSchema( String use ) {
attrName = "matchingruleuse";
parseValue( use );
Vector v = (Vector)properties.get( "APPLIES" );
Vector<String> v = (Vector<String>)properties.get( "APPLIES" );
if ( v != null ) {
_attributes = new String[v.size()];
v.copyInto( _attributes );
......@@ -226,6 +226,6 @@ public class LDAPMatchingRuleUseSchema extends LDAPAttributeSchema {
// Qualifiers tracked explicitly
static final String[] EXPLICIT = { OBSOLETE };
private String[] _attributes = null;
}
......@@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
package org.ietf.ldap;
import java.util.*;
import java.util.Vector;
/**
* The definition of a name form in the schema.
......@@ -75,7 +75,7 @@ import java.util.*;
* <CODE>LDAPSchemaElement</CODE>. Optional and custom qualifiers are
* accessed with <CODE>getQualifier</CODE> and <CODE>getQualifierNames</CODE>
* from <CODE>LDAPSchemaElement</CODE>.
* <P>
*
* To add or remove this name form definition from the
......@@ -166,7 +166,7 @@ public class LDAPNameFormSchema extends LDAPSchemaElement {
Object o = properties.get( "MAY" );
if ( o != null ) {
if ( o instanceof Vector ) {
may = (Vector)o;
may = (Vector<String>)o;
} else {
may.addElement( o );
}
......@@ -174,7 +174,7 @@ public class LDAPNameFormSchema extends LDAPSchemaElement {
o = properties.get( "MUST" );
if ( o != null ) {
if ( o instanceof Vector ) {
must = (Vector)o;