Author: markt Date: Tue Apr 28 13:42:08 2009 New Revision: 769402 URL: http://svn.apache.org/viewvc?rev=769402&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42579 Handle both relative and absolute search results Patch provided by Brandon DuRette
Modified: tomcat/tc6.0.x/trunk/ (props changed) tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/realm/JNDIRealm.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc6.0.x/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Tue Apr 28 13:42:08 2009 @@ -1 +1 @@ -/tomcat/trunk:601180,606992,612607,630314,640888,652744,653247,673796,673820,683982,684001,684081,684234,684269-684270,685177,687503,687645,689402,690781,691392,691805,692748,693378,694992,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,701355,709294,709811,709816,710063,710066,710125,710205,711126,711600,712461,712467,718360,719119,719124,719602,719626,719628,720046,720069,721040,723404,723738,726052,727303,728032,728768,728947,729057,729567,729569,729571,729681,729809,729815,729934,730250,730590,731651,732859,732863,734734,740675,740684,742677,742697,742714,744160,744238,746321,746384,747834,747863,748344,750258,750291,750921,751286-751287,751295,757774,758596,758616,758664,759074,761601,762868,762929,762936-762937,763166,763183,763193,763302,763599,763681,768335 +/tomcat/trunk:601180,606992,612607,630314,640888,652744,653247,673796,673820,683982,684001,684081,684234,684269-684270,685177,687503,687645,689402,690781,691392,691805,692748,693378,694992,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,701355,709294,709811,709816,710063,710066,710125,710205,711126,711600,712461,712467,718360,719119,719124,719602,719626,719628,720046,720069,721040,723404,723738,726052,727303,728032,728768,728947,729057,729567,729569,729571,729681,729809,729815,729934,730250,730590,731651,732859,732863,734734,740675,740684,742677,742697,742714,744160,744238,746321,746384,747834,747863,748344,750258,750291,750921,751286-751287,751295,757774,758596,758616,758664,759074,761601,762868,762929,762936-762937,763166,763183,763193,763302,763599,763681,763706,768335 Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=769402&r1=769401&r2=769402&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Tue Apr 28 13:42:08 2009 @@ -146,13 +146,6 @@ +1: markt, rjung -1: -* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42579 - Handle both relative and absolute search results - Patch provided by Brandon DuRette - http://svn.apache.org/viewvc?rev=763706&view=rev - +1: markt, remm, rjung - -1: - * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42390 Correct JSP compilation error with nested tagfile tags with variables with "AT_BEGIN" scope Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/realm/JNDIRealm.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/realm/JNDIRealm.java?rev=769402&r1=769401&r2=769402&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/realm/JNDIRealm.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/realm/JNDIRealm.java Tue Apr 28 13:42:08 2009 @@ -18,6 +18,8 @@ package org.apache.catalina.realm; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.security.Principal; import java.text.MessageFormat; import java.util.ArrayList; @@ -1821,6 +1823,62 @@ } + /** + * Returns the distinguished name of a search result. + * + * @param context Our DirContext + * @param base The base DN + * @param result The search result + * @return String containing the distinguished name + */ + protected String getDistinguishedName(DirContext context, String base, + SearchResult result) throws NamingException { + // Get the entry's distinguished name. For relative results, this means + // we need to composite a name with the base name, the context name, and + // the result name. For non-relative names, use the returned name. + if (result.isRelative()) { + if (containerLog.isTraceEnabled()) { + containerLog.trace(" search returned relative name: " + + result.getName()); + } + NameParser parser = context.getNameParser(""); + Name contextName = parser.parse(context.getNameInNamespace()); + Name baseName = parser.parse(base); + + // Bugzilla 32269 + Name entryName = + parser.parse(new CompositeName(result.getName()).get(0)); + + Name name = contextName.addAll(baseName); + name = name.addAll(entryName); + return name.toString(); + } else { + String absoluteName = result.getName(); + if (containerLog.isTraceEnabled()) + containerLog.trace(" search returned absolute name: " + + result.getName()); + try { + // Normalize the name by running it through the name parser. + NameParser parser = context.getNameParser(""); + URI userNameUri = new URI(absoluteName); + String pathComponent = userNameUri.getPath(); + // Should not ever have an empty path component, since that is /{DN} + if (pathComponent.length() < 1 ) { + throw new InvalidNameException( + "Search returned unparseable absolute name: " + + absoluteName ); + } + Name name = parser.parse(pathComponent.substring(1)); + return name.toString(); + } catch ( URISyntaxException e ) { + throw new InvalidNameException( + "Search returned unparseable absolute name: " + + absoluteName ); + } + } + } + + } // ------------------------------------------------------ Private Classes Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=769402&r1=769401&r2=769402&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Tue Apr 28 13:42:08 2009 @@ -36,6 +36,10 @@ <subsection name="Catalina"> <changelog> <fix> + <bug>42579</bug>: Handle both relative and absolute search results in + the JNDIRealm. Patch provided by Brandon DuRette. (markt) + </fix> + <fix> <bug>46816</bug>: Align session manager mbean descriptor with implementation. (markt) </fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org