Skip to content

Commit

Permalink
fix(deps): update person directory to v1.8.16 (#2280)
Browse files Browse the repository at this point in the history
* fix(deps): update person directory to v1.8.16

* fix(deps): update person directory to v1.8.16

* Refactored code to match person-directory changes.

* fix(deps): update person directory to v1.8.16

* Refactored code to match person-directory changes.

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Bill Smith <[email protected]>
  • Loading branch information
renovate[bot] and Naenyn authored Sep 10, 2024
1 parent 5dc1323 commit a7b86aa
Show file tree
Hide file tree
Showing 23 changed files with 51 additions and 44 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ luceneVersion=8.11.2
nodejsVersion=20.15.1
oauthVersion=20100527
orgJsonVersion=20240303
personDirectoryVersion=1.8.11
personDirectoryVersion=1.8.16
plutoVersion=2.1.0-M3
resourceServerVersion=1.3.1
slf4jVersion=1.7.36
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Set<String> getQueryAttributes(ExternalContext externalContext) {
// Otherwise provide all available attributes from the IPersonAttributeDao
else {
final Set<String> availableAttributes =
this.personAttributeDao.getAvailableQueryAttributes();
this.personAttributeDao.getAvailableQueryAttributes(null);
queryAttributes = new TreeSet<>(availableAttributes);
}

Expand Down Expand Up @@ -164,7 +164,8 @@ public Set<String> getDisplayAttributes(ExternalContext externalContext) {
}
// Otherwise provide all available attributes from the IPersonAttributes
else {
displayAttributes = new TreeSet<>(personAttributeDao.getPossibleUserAttributeNames());
displayAttributes =
new TreeSet<>(personAttributeDao.getPossibleUserAttributeNames(null));
}

// Remove any excluded attributes
Expand All @@ -186,7 +187,7 @@ public IPersonAttributes getSelf(ExternalContext externalContext) {
final PortletRequest portletRequest = (PortletRequest) externalContext.getNativeRequest();
final String username = portletRequest.getRemoteUser();

return this.personAttributeDao.getPerson(username);
return this.personAttributeDao.getPerson(username, null);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -226,7 +227,7 @@ public List<IPersonAttributes> searchForPeople(
}

// get the set of people matching the search query
final Set<IPersonAttributes> people = this.personAttributeDao.getPeople(inUseQuery);
final Set<IPersonAttributes> people = this.personAttributeDao.getPeople(inUseQuery, null);
if (people == null) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -389,7 +390,7 @@ public IPersonAttributes findPerson(final IPerson searcher, final String usernam
final Set<String> permittedAttributes = getPermittedAttributes(principal);

// get the set of people matching the search query
final IPersonAttributes person = this.personAttributeDao.getPerson(username);
final IPersonAttributes person = this.personAttributeDao.getPerson(username, null);

if (person == null) {
logger.info("No user found with username matching " + username);
Expand Down Expand Up @@ -421,7 +422,7 @@ protected IAuthorizationPrincipal getPrincipalForUser(final IPerson person) {
* @return
*/
protected Set<String> getPermittedAttributes(final IAuthorizationPrincipal principal) {
final Set<String> attributeNames = personAttributeDao.getPossibleUserAttributeNames();
final Set<String> attributeNames = personAttributeDao.getPossibleUserAttributeNames(null);
return getPermittedAttributes(principal, attributeNames);
}

Expand Down Expand Up @@ -464,7 +465,7 @@ protected Set<String> getPermittedOwnAttributes(
// The permttedOwnAttributes collection includes all the generallyPermittedAttributes
final Set<String> result = new HashSet<>(generallyPermittedAttributes);

for (String attr : personAttributeDao.getPossibleUserAttributeNames()) {
for (String attr : personAttributeDao.getPossibleUserAttributeNames(null)) {
if (principal.hasPermission(
IPermission.PORTAL_USERS, IPermission.VIEW_OWN_USER_ATTRIBUTE_ACTIVITY, attr)) {
result.add(attr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public Set<String> getSwappableAttributes(ExternalContext externalContext) {
} else {
// If no prefs try the 'possibleUserAttributeNames' from the IPersonAttributeDao
final Set<String> possibleAttributes =
this.portalRootPersonAttributeDao.getPossibleUserAttributeNames();
this.portalRootPersonAttributeDao.getPossibleUserAttributeNames(null);
if (possibleAttributes != null) {
swappableAttributes = new TreeSet<String>(possibleAttributes);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public Set<String> getSwappableAttributes(ExternalContext externalContext) {
public IPersonAttributes getOriginalUserAttributes(String uid) {
final IPersonAttributeDao delegatePersonAttributeDao =
this.portalRootPersonAttributeDao.getDelegatePersonAttributeDao();
return delegatePersonAttributeDao.getPerson(uid);
return delegatePersonAttributeDao.getPerson(uid, null);
}

/* (non-Javadoc)
Expand All @@ -146,7 +146,7 @@ public void populateSwapRequest(
ExternalContext externalContext, AttributeSwapRequest attributeSwapRequest) {
final Principal currentUser = externalContext.getCurrentUser();
final String uid = currentUser.getName();
final IPersonAttributes person = this.portalRootPersonAttributeDao.getPerson(uid);
final IPersonAttributes person = this.portalRootPersonAttributeDao.getPerson(uid, null);

final Map<String, Attribute> currentAttributes =
attributeSwapRequest.getCurrentAttributes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void init() {

// Must make the superclass use our collection of attribute names
IPersonAttributeDao personAttributeDao = mock(IPersonAttributeDao.class);
when(personAttributeDao.getPossibleUserAttributeNames()).thenReturn(ALL_ATTRIBUTES);
when(personAttributeDao.getPossibleUserAttributeNames(null)).thenReturn(ALL_ATTRIBUTES);
setPersonAttributeDao(personAttributeDao);

principal = mock(IAuthorizationPrincipal.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ protected Set<String> getGroupsForUser(IPerson person) {

protected Map<String, List<String>> getAttributesForUser(IPerson person) {
final IPersonAttributes personAttributes =
this.personAttributeDao.getPerson(person.getUserName());
this.personAttributeDao.getPerson(person.getUserName(), null);

final Map<String, List<String>> attributes = new LinkedHashMap<String, List<String>>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public LrsActor getLrsActor(String userName) {

final String email;
final String name;
final IPersonAttributes person = personAttributeDao.getPerson(userName);
final IPersonAttributes person = personAttributeDao.getPerson(userName, null);
if (person == null) {
email = userName;
name = userName + "@example.com";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Class<IPerson> getType() {
*/
private String primGetName(String key) {
String name = key;
final IPersonAttributes personAttributes = this.paDao.getPerson(name);
final IPersonAttributes personAttributes = this.paDao.getPerson(name, null);
if (personAttributes != null) {
Object displayName = personAttributes.getAttributeValue("displayName");
String displayNameStr = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public EntityIdentifier[] searchForEntities(String query, SearchMethod method)

final String usernameAttribute = this.usernameAttributeProvider.getUsernameAttribute();
final Map<String, Object> queryMap = Collections.singletonMap(usernameAttribute, query);
final Set<IPersonAttributes> results = this.personAttributeDao.getPeople(queryMap);
final Set<IPersonAttributes> results = this.personAttributeDao.getPeople(queryMap, null);
// create an array of EntityIdentifiers from the search results
final List<EntityIdentifier> entityIdentifiers = new ArrayList<>(results.size());
for (final IPersonAttributes personAttributes : results) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public boolean contains(IEntityGroup group, IGroupMember member) {
try {
final IPersonAttributeDao pa =
PersonAttributeDaoLocator.getPersonAttributeDao();
final IPersonAttributes personAttributes = pa.getPerson(member.getKey());
final IPersonAttributes personAttributes = pa.getPerson(member.getKey(), null);

if (personAttributes != null) {
final RestrictedPerson rp = PersonFactory.createRestrictedPerson();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public Iterator findParentGroups(IGroupMember gm) throws GroupsException {
private Object[] getPersonGroupMemberKeys(IGroupMember gm) {
Object[] keys = null;
EntityIdentifier ei = gm.getUnderlyingEntityIdentifier();
IPersonAttributes attr = personAttributeDao.getPerson(ei.getKey());
IPersonAttributes attr = personAttributeDao.getPerson(ei.getKey(), null);
if (attr != null && attr.getAttributes() != null && !attr.getAttributes().isEmpty()) {
IPerson p = PersonFactory.createPerson();
p.setAttributes(attr.getAttributes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apereo.portal.security.IPersonManager;
import org.apereo.portal.security.IdentitySwapperManager;
import org.apereo.portal.url.IPortalRequestUtils;
import org.apereo.services.persondir.IPersonAttributeDaoFilter;
import org.apereo.services.persondir.IPersonAttributes;
import org.apereo.services.persondir.support.AbstractDefaultAttributePersonAttributeDao;
import org.apereo.services.persondir.support.CaseInsensitiveNamedPersonImpl;
Expand All @@ -49,15 +50,15 @@ public class ImpersonationStatusPersonAttributeDao
* attributes in queries.
*/
@Override
public Set<String> getAvailableQueryAttributes() {
public Set<String> getAvailableQueryAttributes(IPersonAttributeDaoFilter filter) {
final IUsernameAttributeProvider usernameAttributeProvider =
super.getUsernameAttributeProvider();
return Collections.singleton(usernameAttributeProvider.getUsernameAttribute());
}

@Override
public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
Map<String, List<Object>> query) {
Map<String, List<Object>> query, IPersonAttributeDaoFilter filter) {

Set<IPersonAttributes> result = null; // default (per spec?)

Expand Down Expand Up @@ -100,7 +101,7 @@ public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
* may be available.
*/
@Override
public Set<String> getPossibleUserAttributeNames() {
public Set<String> getPossibleUserAttributeNames(IPersonAttributeDaoFilter filter) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apereo.services.persondir.IPersonAttributeDaoFilter;
import org.apereo.services.persondir.IPersonAttributes;
import org.apereo.services.persondir.support.AbstractDefaultAttributePersonAttributeDao;
import org.apereo.services.persondir.support.AttributeNamedPersonImpl;
Expand Down Expand Up @@ -128,7 +129,7 @@ public void setUnmappedUsernameAttribute(String userNameAttribute) {
* @return Set
*/
@Override
public Set<String> getPossibleUserAttributeNames() {
public Set<String> getPossibleUserAttributeNames(IPersonAttributeDaoFilter filter) {
final Set<String> names = new HashSet<String>();
names.addAll(this.possibleUserAttributes);
names.addAll(localAccountDao.getCurrentAttributeNames());
Expand All @@ -144,7 +145,7 @@ public Set<String> getPossibleUserAttributeNames() {
* @return Set
*/
@Override
public Set<String> getAvailableQueryAttributes() {
public Set<String> getAvailableQueryAttributes(IPersonAttributeDaoFilter filter) {
if (this.queryAttributeMapping == null) {
return Collections.emptySet();
}
Expand All @@ -157,7 +158,7 @@ public Set<String> getAvailableQueryAttributes() {
*/
@Override
public final Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
Map<String, List<Object>> query) {
Map<String, List<Object>> query, IPersonAttributeDaoFilter filter) {
Validate.notNull(query, "query may not be null.");

// Generate the query to pass to the subclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.commons.lang.Validate;
import org.apache.commons.lang3.StringUtils;
import org.apereo.services.persondir.IPersonAttributeDao;
import org.apereo.services.persondir.IPersonAttributeDaoFilter;
import org.apereo.services.persondir.IPersonAttributes;
import org.apereo.services.persondir.support.AbstractFlatteningPersonAttributeDao;
import org.apereo.services.persondir.support.IUsernameAttributeProvider;
Expand Down Expand Up @@ -108,9 +109,9 @@ public void removeUserAttributeOverride(String uid) {
* is unknown
*/
@Override
public IPersonAttributes getPerson(String uid) {
public IPersonAttributes getPerson(String uid, IPersonAttributeDaoFilter filter) {

final IPersonAttributes result = delegatePersonAttributeDao.getPerson(uid);
final IPersonAttributes result = delegatePersonAttributeDao.getPerson(uid, null);
if (result == null) {
// Nothing we can do with that
return null;
Expand All @@ -125,9 +126,9 @@ public IPersonAttributes getPerson(String uid) {
*/
@Override
public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
Map<String, List<Object>> query) {
Map<String, List<Object>> query, IPersonAttributeDaoFilter filter) {
final Set<IPersonAttributes> people =
delegatePersonAttributeDao.getPeopleWithMultivaluedAttributes(query);
delegatePersonAttributeDao.getPeopleWithMultivaluedAttributes(query, filter);
if (people == null) {
return null;
}
Expand All @@ -147,13 +148,13 @@ public Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
}

@Override
public Set<String> getPossibleUserAttributeNames() {
return delegatePersonAttributeDao.getPossibleUserAttributeNames();
public Set<String> getPossibleUserAttributeNames(IPersonAttributeDaoFilter filter) {
return delegatePersonAttributeDao.getPossibleUserAttributeNames(filter);
}

@Override
public Set<String> getAvailableQueryAttributes() {
return delegatePersonAttributeDao.getAvailableQueryAttributes();
public Set<String> getAvailableQueryAttributes(IPersonAttributeDaoFilter filter) {
return delegatePersonAttributeDao.getAvailableQueryAttributes(filter);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void setup() throws Exception {
@Test
public void testGetAvailableQueryAttributes() {
Set<String> attributes =
impersonationStatusPersonAttributeDao.getAvailableQueryAttributes();
impersonationStatusPersonAttributeDao.getAvailableQueryAttributes(null);
assertNotNull(attributes);
String attribute = attributes.iterator().next();
assertEquals(attribute, "attrs");
Expand All @@ -84,7 +84,8 @@ public void testGetAvailableQueryAttributes() {
@Test
public void testGetPeopleWithMultivaluedAttributes() {
Set<IPersonAttributes> attributes =
impersonationStatusPersonAttributeDao.getPeopleWithMultivaluedAttributes(query);
impersonationStatusPersonAttributeDao.getPeopleWithMultivaluedAttributes(
query, null);
assertNotNull(attributes);
IPersonAttributes personAttributes = attributes.iterator().next();
String uname = personAttributes.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ protected Map<String, String> getUserInfo(
String remoteUser, HttpServletRequest httpServletRequest, IPortletWindow portletWindow)
throws PortletContainerException {
// Get the list of user attributes the portal knows about the user
final IPersonAttributes personAttributes = this.personAttributeDao.getPerson(remoteUser);
final IPersonAttributes personAttributes =
this.personAttributeDao.getPerson(remoteUser, null);
if (personAttributes == null) {
return Collections.emptyMap();
}
Expand All @@ -139,7 +140,7 @@ protected Map<String, String> getUserInfo(
* Using the Map of portal user attributes and a List of expected attributes generate the
* USER_INFO map for the portlet
*
* @param portalUserAttributes All the attributes the portal knows about the user
* @param personAttributes All the attributes the portal knows about the user
* @param expectedUserAttributes The attributes the portlet expects to get
* @return The Map to use for the USER_INFO attribute
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public Object getAttribute(
*/
protected Map<String, List<Object>> getMultiValuedUserInfoMap(
String remoteUser, List<? extends UserAttribute> expectedUserAttributes) {
final IPersonAttributes personAttributes = this.personAttributeDao.getPerson(remoteUser);
final IPersonAttributes personAttributes =
this.personAttributeDao.getPerson(remoteUser, null);
if (personAttributes == null) {
return Collections.emptyMap();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected String getSkinName(HttpServletRequest request) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IPerson person = userInstance.getPerson();
final IPersonAttributes personAttrs =
this.personAttributeDao.getPerson(person.getUserName());
this.personAttributeDao.getPerson(person.getUserName(), null);
if (personAttrs == null) {
logger.debug(
"No user attributes found for {} no skin override will be done",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testControl() {
when(portletDefinition.getPortletDefinitionId()).thenReturn(portletDefinitionId);

IPersonAttributeDao personAttributeDao = mock(IPersonAttributeDao.class);
when(personAttributeDao.getPerson("username")).thenReturn(personAttributes);
when(personAttributeDao.getPerson("username", null)).thenReturn(personAttributes);

IPortletWindowRegistry portletWindowRegistry = mock(IPortletWindowRegistry.class);
when(portletWindowRegistry.convertPortletWindow(httpServletRequest, plutoPortletWindow))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public String createUserInfo(
.setExpiration(expires)
.setIssuedAt(now);

final IPersonAttributes person = personAttributeDao.getPerson(username);
final IPersonAttributes person = personAttributeDao.getPerson(username, null);

// Attribute mappings
mappings.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public IPerson getPerson(String username) {
final IPerson result = new PersonImpl();
result.setAttribute(IPerson.USERNAME, username);
result.setID(userIdentityStore.getPortalUserId(username));
result.setAttributes(personAttributeDao.getPerson(username).getAttributes());
result.setAttributes(personAttributeDao.getPerson(username, null).getAttributes());
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public IPermissionTarget getTarget(String key) {
@Override
public Collection<IPermissionTarget> searchTargets(String term) {
term = term.toLowerCase();
final Set<String> attributes = personAttributeDao.getAvailableQueryAttributes();
final Set<String> attributes = personAttributeDao.getAvailableQueryAttributes(null);
final List<IPermissionTarget> matches = new ArrayList<IPermissionTarget>();
for (String attribute : attributes) {
if (attribute.toLowerCase().contains(term)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ else if (addInfo instanceof Map) {
}

final IPersonAttributes personAttributes =
this.personAttributeDao.getPerson(username);
this.personAttributeDao.getPerson(username, null);

if (log.isDebugEnabled()) {
log.debug(
Expand Down
Loading

0 comments on commit a7b86aa

Please sign in to comment.