Skip to content
Snippets Groups Projects
Commit e8940ede authored by Adrian Damian's avatar Adrian Damian
Browse files

Fixed problem with non-canonized DNs in ac search

parent 457dbfbe
No related branches found
No related tags found
No related merge requests found
......@@ -68,16 +68,16 @@
*/
package ca.nrc.cadc.ac.server;
import ca.nrc.cadc.ac.IdentityType;
import java.security.Principal;
import java.util.List;
import org.apache.log4j.Logger;
import ca.nrc.cadc.ac.Role;
import ca.nrc.cadc.auth.AuthenticationUtil;
import ca.nrc.cadc.uws.Parameter;
import ca.nrc.cadc.uws.ParameterUtil;
import java.security.Principal;
import java.util.List;
import org.apache.log4j.Logger;
/**
* Request Validator. This class extracts and validates the ID, TYPE, ROLE
* and GURI parameters.
......
......@@ -407,11 +407,9 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO
throw new IllegalArgumentException(
"Unsupported principal type " + user.getUserID().getClass());
}
String name = getUserName(searchField, user);
searchField = "(" + searchField + "=" +
name + ")";
user.getUserID().getName() + ")";
SearchResultEntry searchResult = null;
try
......@@ -430,32 +428,11 @@ public class LdapUserDAO<T extends Principal> extends LdapDAO
if (searchResult == null)
{
String msg = "User not found " + name;
String msg = "User not found " + user.getUserID().getName();
logger.debug(msg);
throw new UserNotFoundException(msg);
}
return searchResult.getAttributeValueAsDN("entrydn");
}
/**
* If the principal is of type x500, canonize the name for the
* search.
*
* @param searchField
* @param user
* @return
*/
private String getUserName(String searchField, User<? extends Principal> user)
{
if (searchField != null)
{
if (searchField.equals("distinguishedname"))
{
return AuthenticationUtil.canonizeDistinguishedName(user.getUserID().getName());
}
return user.getUserID().getName();
}
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment