diff --git a/SOURCES/ldapjdk-ldap-url-sans-host-port.patch b/SOURCES/ldapjdk-ldap-url-sans-host-port.patch new file mode 100644 index 0000000..2ac56b3 --- /dev/null +++ b/SOURCES/ldapjdk-ldap-url-sans-host-port.patch @@ -0,0 +1,86 @@ +diff -r f9d7552c8188 java-sdk/ldapjdk/netscape/ldap/LDAPUrl.java +--- a/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPUrl.java Mon Aug 08 16:00:49 2016 -0600 ++++ b/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPUrl.java Fri Oct 07 11:57:01 2016 -0400 +@@ -136,10 +136,10 @@ + */ + private void parseUrl(String url) throws MalformedURLException { + StringTokenizer urlParser = new StringTokenizer (url, ":/?[]", true); +- StringTokenizer markParser = new StringTokenizer (url, ":/?[]", true); + String currentToken; + String str = null; + boolean usingIPv6 = false; ++ boolean usingDefaultHostPort = false; + + try { + currentToken = urlParser.nextToken(); +@@ -175,6 +175,7 @@ + if (currentToken.equals ("/")) { + m_hostName = null; + m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT; ++ usingDefaultHostPort = true; + } else if (currentToken.equals (":")) { + // port number without host name is not allowed + throw new MalformedURLException ("No hostname"); +@@ -194,37 +195,38 @@ + m_hostName = currentToken; + } + +- // Set the port +- if (urlParser.countTokens() == 0) { +- m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT; +- return; +- } +- currentToken = urlParser.nextToken (); // either ":" or "/" +- +- if (currentToken.equals (":")) { +- try { +- m_portNumber = Integer.parseInt (urlParser.nextToken()); +- } catch (NumberFormatException nf) { +- throw new MalformedURLException ("Port not a number"); +- } catch (NoSuchElementException ex) { +- throw new MalformedURLException ("No port number"); +- } +- ++ if (usingDefaultHostPort == false) { ++ // Set the port + if (urlParser.countTokens() == 0) { ++ m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT; + return; + } +- else if (! urlParser.nextToken().equals("/")) { ++ ++ // either ":","/", or the base DN if using "ldap:///" ++ currentToken = urlParser.nextToken (); ++ ++ if (currentToken.equals (":")) { ++ try { ++ m_portNumber = Integer.parseInt (urlParser.nextToken()); ++ } catch (NumberFormatException nf) { ++ throw new MalformedURLException ("Port not a number"); ++ } catch (NoSuchElementException ex) { ++ throw new MalformedURLException ("No port number"); ++ } ++ if (urlParser.countTokens() == 0) { ++ return; ++ } ++ else if (! urlParser.nextToken().equals("/")) { ++ throw new MalformedURLException (); ++ } ++ } else if (currentToken.equals ("/")) { ++ m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT; ++ } else { ++ // expecting ":" or "/" + throw new MalformedURLException (); + } +- +- } else if (currentToken.equals ("/")) { +- m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT; +- } else { +- // expecting ":" or "/" +- throw new MalformedURLException (); + } + +- + // DN + if (!urlParser.hasMoreTokens ()) { + return; diff --git a/SPECS/ldapjdk.spec b/SPECS/ldapjdk.spec index 1091ccf..c4eb8db 100644 --- a/SPECS/ldapjdk.spec +++ b/SPECS/ldapjdk.spec @@ -4,7 +4,7 @@ Name: ldapjdk Version: 4.18 -Release: 15%{?dist} +Release: 16%{?dist} Epoch: 0 Summary: The Mozilla LDAP Java SDK License: MPLv1.1 or GPLv2+ or LGPLv2+ @@ -20,6 +20,7 @@ Source1: http://pki.fedoraproject.org/pki/sources/%{name}/%{name}-%{version}.pom Patch0: %{name}-jarnamefix.patch Patch1: matching-rule-parsing-640750.patch Patch2: %{name}-support-IPv6.patch +Patch3: %{name}-ldap-url-sans-host-port.patch Requires: jpackage-utils >= 0:1.5 Requires: jss @@ -50,6 +51,7 @@ rm -f ./mozilla/directory/java-sdk/ldapjdk/lib/{jss32_stub,jsse,jnet,jaas,jndi}. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %build # cleanup CVS dirs @@ -99,6 +101,10 @@ cp -r mozilla/directory/java-sdk/dist/doc/* $RPM_BUILD_ROOT%{_javadocdir}/%{name %{_javadocdir}/%{name}/* %changelog +* Mon Oct 31 2016 Matthew Harmsen 0:4.18-16 +- Resolves: rhbz #1388500 - ldapjdk fails to parse ldap url with no host:port + (mreynolds) + * Tue Aug 9 2016 Matthew Harmsen 0:4.18-15 - Resolves: rhbz #1353564 - ldapjdk needs to support IPv6 (mreynolds)