Added getter methods for JDAPFilter classes. default tip
authorEndi S. Dewata <edewata@redhat.com>
Mon, 02 Oct 2017 17:44:02 +0200
changeset 51 460afcc31771
parent 50 c07685b0f90a
push id34
push userrichm@stanfordalumni.org
push dateWed, 11 Oct 2017 19:46:16 +0000
bugs1376300
Added getter methods for JDAPFilter classes. Some JDAPFilter classes have been modified to provide getter methods to access the elements of parsed LDAP filters. Eclipse project files have been added to simplify development using Eclipse. The LDAPUrl has been modified to fix complie error in Eclipse. Some unused import statements have been removed as well. https://bugzilla.mozilla.org/show_bug.cgi?id=1376300
.classpath
.hgignore
.project
java-sdk/ietfldap/org/ietf/ldap/LDAPUrl.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPAVA.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPBERTagDecoder.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilter.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterAVA.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterAnd.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterApproxMatch.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterEqualityMatch.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterExtensible.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterGreaterOrEqual.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterLessOrEqual.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterNot.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterOr.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterPresent.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterSet.java
java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterSubString.java
new file mode 100644
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry excluding="tools/" kind="src" path="java-sdk/ietfldap"/>
+	<classpathentry kind="src" path="java-sdk/ldapbeans"/>
+	<classpathentry kind="src" path="java-sdk/ldapfilter"/>
+	<classpathentry kind="src" path="java-sdk/ldapjdk"/>
+	<classpathentry kind="src" path="java-sdk/ldapsp"/>
+	<classpathentry kind="lib" path="/usr/lib/java/jss4.jar"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- a/.hgignore
+++ b/.hgignore
@@ -13,8 +13,12 @@ config\.cache$
 config\.log$
 config\.status$
 config\autoconf.mk$
 config\nsinstall$
 .fast-update$
 
 sdkver.h
 dirver.h
+
+# Ignore Eclipse build directory
+syntax: glob
+bin/**
new file mode 100644
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ldap-sdks</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
--- a/java-sdk/ietfldap/org/ietf/ldap/LDAPUrl.java
+++ b/java-sdk/ietfldap/org/ietf/ldap/LDAPUrl.java
@@ -378,17 +378,17 @@ public class LDAPUrl implements java.io.
             }
 
             if (_factory != null) {
                 return _factory;
             }
 
             try {
                 // then try Sun JSSESocketFactory
-                _factory = new JSSESocketFactory(null);
+                _factory = new JSSESocketFactory((String[])null);
             }
             catch (Throwable e) {
             }
         }
 
         return _factory;
     }
 
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPAVA.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPAVA.java
@@ -32,18 +32,16 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
-import java.io.*;
 import netscape.ldap.ber.stream.*;
 
 /**
  * This class implements the attribute value assertion.
  * This object is used with filters.
  * <pre>
  * AttributeValueAssertion ::= SEQUENCE {
  *   attributType AttributeType,
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPBERTagDecoder.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPBERTagDecoder.java
@@ -32,17 +32,16 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
 import java.io.*;
 
 /**
  * This class is to help BER libraries to make decision
  * on how to decode an implicit object.
  */
 public class JDAPBERTagDecoder extends BERTagDecoder {
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilter.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilter.java
@@ -34,17 +34,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
 import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the filter.
  * <pre>
  *   Filter ::= CHOICE {
  *     and [0] SET OF Filter,
  *     or [1] SET OF Filter,
  *     not [2] Filter,
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterAVA.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterAVA.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the attribute value assertion filter.
  *
  * @version 1.0
  */
 public abstract class JDAPFilterAVA extends JDAPFilter {
     /**
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterAnd.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterAnd.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the filter And.
  * <pre>
  *   and [0] SET OF Filter
  * </pre>
  *
  * @version 1.0
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterApproxMatch.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterApproxMatch.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the approximate match filter.
  * <pre>
  * approxMatch [8] AttributeValueAssertion
  * </pre>
  *
  * @version 1.0
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterEqualityMatch.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterEqualityMatch.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the equality match filter.
  * See RFC 1777.
  * <pre>
  * equalityMatch [3] AttributeValueAssertion
  * </pre>
  *
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterExtensible.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterExtensible.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the extended match filter.
  * <pre>
  * extensibleMatch [9] AttributeValueAssertion
  * </pre>
  *
  * @version 1.0
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterGreaterOrEqual.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterGreaterOrEqual.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the greater or equal filter.
  * See RFC 1777.
  * <pre>
  * greaterOrEqual [5] AttributeValueAssertion
  * </pre>
  *
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterLessOrEqual.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterLessOrEqual.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the less or equal filter.
  * <pre>
  * lessOrEqual [6] AttributeValueAssertion
  * </pre>
  *
  * @version 1.0
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterNot.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterNot.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the filter not.
  * See RFC 1777.
  * <pre>
  *   not [2] Filter
  * </pre>
  *
@@ -61,25 +59,33 @@ public class JDAPFilterNot extends JDAPF
      * Constructs the filter.
      */
     public JDAPFilterNot(JDAPFilter filter) {
         super();
         m_filter = filter;
     }
 
     /**
+     * Gets original filter.
+     * @return original filter
+     */
+    public JDAPFilter getFilter() {
+    	return m_filter;
+    }
+
+    /**
      * Gets ber representation of the filter.
      * @return ber representation
      */
     public BERElement getBERElement() {
         BERTag element = new BERTag(BERTag.CONSTRUCTED|BERTag.CONTEXT|2,
           m_filter.getBERElement(), false /* true */);
         return element;
     }
 
     /**
-     * Gets string reprensetation of the filter.
+     * Gets string representation of the filter.
      * @return string representation
      */
     public String toString() {
         return "JDAPFilterNot {" + m_filter.toString() + "}";
     }
 }
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterOr.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterOr.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the filter And.
  * See RFC 1777.
  * <pre>
  *   or [1] SET OF Filter
  * </pre>
  *
@@ -54,15 +52,15 @@ public class JDAPFilterOr extends JDAPFi
     /**
      * Constructs the filter.
      */
     public JDAPFilterOr() {
         super(BERTag.CONSTRUCTED|BERTag.CONTEXT|1);
     }
 
     /**
-     * Gets string reprensetation of the filter.
+     * Gets string representation of the filter.
      * @return string representation
      */
     public String toString() {
         return "JDAPFilterOr {" + super.getParamString() + "}";
     }
 }
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterPresent.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterPresent.java
@@ -32,19 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
-import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the filter present.
  * See RFC 1777.
  * <pre>
  *   present [7] AttributeType
  * </pre>
  *
@@ -61,16 +59,24 @@ public class JDAPFilterPresent extends J
      * @param type attribute type
      */
     public JDAPFilterPresent(String type) {
         super();
         m_type = type;
     }
 
     /**
+     * Gets attribute type.
+     * @return attribute type
+     */
+    public String getType() {
+    	return m_type;
+    }
+
+    /**
      * Gets ber representation of the filter.
      * @return ber representation
      */
     public BERElement getBERElement() {
         BEROctetString s = new BEROctetString(m_type);
         BERTag element = new BERTag(BERTag.CONTEXT|7, s, true);
         return element;
     }
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterSet.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterSet.java
@@ -46,28 +46,36 @@ import java.io.*;
  *
  * @version 1.0
  */
 public abstract class JDAPFilterSet extends JDAPFilter {
     /**
      * Internal variables
      */
     private int m_tag;
-    private Vector m_set = new Vector();
+    private Vector<JDAPFilter> m_set = new Vector<>();
 
     /**
      * Constructs the filter set.
      * @param tag tag
      */
     public JDAPFilterSet(int tag) {
         super();
         m_tag = tag;
     }
 
     /**
+     * Gets the filter set.
+     * @return filter set
+     */
+     public Collection<JDAPFilter> getFilters() {
+    	 return m_set;
+     }
+
+    /**
      * Adds filter into the filter set.
      * @param filter adding filter
      */
     public void addElement(JDAPFilter filter) {
         m_set.addElement(filter);
     }
 
     /**
--- a/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterSubString.java
+++ b/java-sdk/ldapjdk/netscape/ldap/client/JDAPFilterSubString.java
@@ -34,69 +34,107 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 package netscape.ldap.client;
 
 import java.util.*;
 import netscape.ldap.ber.stream.*;
-import java.io.*;
 
 /**
  * This class implements the filter substring.
- * See RFC 1777.
+ * See RFC 1777 and 2254.
  * <pre>
  * [4] SEQUENCE {
  *   type AttributeType,
  *   SEQUENCE OF CHOICE {
  *     initial [0] LDAPString,
  *     any [1] LDAPString,
  *     final [2] LDAPString
  *   }
- *     }
+ * }
+ *
+ * substring  = attr "=" [initial] any [final]
+ * initial    = value
+ * any        = "*" *(value "*")
+ * final      = value
  * </pre>
  *
  * @version 1.0
  */
 public class JDAPFilterSubString extends JDAPFilter {
     /**
      * Internal variables
      */
     private String m_type = null;
-    private Vector m_initial = new Vector();
-    private Vector m_any = new Vector();
-    private Vector m_final = new Vector();
+    private Vector<String> m_initial = new Vector<>();
+    private Vector<String> m_any = new Vector<>();
+    private Vector<String> m_final = new Vector<>();
 
     /**
      * Constructs the filter.
      * @param type attribute type
      */
     public JDAPFilterSubString(String type) {
         super();
         m_type = type;
     }
 
     /**
+     * Get attribute type.
+     * @return attribute type
+     */
+    public String getType() {
+    	return m_type;
+    }
+
+    /**
+     * Get initial substring.
+     * @return initial substring.
+     */
+    public String getInitialSubstring() {
+    	// RFC 2254: there is only one optional initial substring
+    	return m_initial.isEmpty() ? null : m_initial.get(0);
+    }
+
+    /**
      * Adds initial substring.
      * @param s initial substring
      */
     public void addInitial(String s) {
         m_initial.addElement(s);
     }
 
     /**
+     * Get any substrings.
+     * @return any substrings.
+     */
+    public Collection<String> getAnySubstrings() {
+    	return m_any;
+    }
+
+    /**
      * Adds any substring.
      * @param s any substring
      */
     public void addAny(String s) {
         m_any.addElement(s);
     }
 
     /**
+     * Get final substring.
+     * @return final substring.
+     */
+    public String getFinalSubstring() {
+    	// RFC 2254: there is only one optional final substring
+    	return m_final.isEmpty() ? null : m_final.get(0);
+    }
+
+    /**
      * Adds final substring.
      * @param s final substring
      */
     public void addFinal(String s) {
         m_final.addElement(s);
     }
 
     /**