Fix permission attributes - no error should occur in case they are empty
This commit is contained in:
parent
08c323f989
commit
05322c296d
|
@ -222,10 +222,17 @@ public class LdapClient {
|
||||||
if (!CN.equals(getGroupNameAttribute())) {
|
if (!CN.equals(getGroupNameAttribute())) {
|
||||||
orFilter.or(new WhitespaceWildcardsFilter(CN, name));
|
orFilter.or(new WhitespaceWildcardsFilter(CN, name));
|
||||||
}
|
}
|
||||||
final AndFilter andFilter2 = new AndFilter();
|
|
||||||
andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute()));
|
|
||||||
andFilter.and(orFilter);
|
andFilter.and(orFilter);
|
||||||
andFilter2.and(andFilter);
|
final AndFilter andFilter2;
|
||||||
|
if (!getUserPermissionsAttribute().isEmpty()) {
|
||||||
|
andFilter2 = new AndFilter();
|
||||||
|
andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute()));
|
||||||
|
andFilter2.and(andFilter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
andFilter2 = andFilter;
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.debug("Using filter '{}' for LDAP query.", andFilter);
|
LOGGER.debug("Using filter '{}' for LDAP query.", andFilter);
|
||||||
|
|
||||||
|
@ -261,6 +268,9 @@ public class LdapClient {
|
||||||
|
|
||||||
public List<AccessIdRepresentationModel> searchPermissionsByName(final String name)
|
public List<AccessIdRepresentationModel> searchPermissionsByName(final String name)
|
||||||
throws InvalidArgumentException {
|
throws InvalidArgumentException {
|
||||||
|
if (getUserPermissionsAttribute().isEmpty() || getPermissionSearchFilterName().isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
isInitOrFail();
|
isInitOrFail();
|
||||||
testMinSearchForLength(name);
|
testMinSearchForLength(name);
|
||||||
|
|
||||||
|
@ -323,10 +333,16 @@ public class LdapClient {
|
||||||
orFilter.or(new EqualsFilter(getGroupsOfUserName(), accessId));
|
orFilter.or(new EqualsFilter(getGroupsOfUserName(), accessId));
|
||||||
}
|
}
|
||||||
orFilter.or(new EqualsFilter(getGroupsOfUserName(), dn));
|
orFilter.or(new EqualsFilter(getGroupsOfUserName(), dn));
|
||||||
final AndFilter andFilter2 = new AndFilter();
|
|
||||||
andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute()));
|
|
||||||
andFilter.and(orFilter);
|
andFilter.and(orFilter);
|
||||||
andFilter2.and(andFilter);
|
final AndFilter andFilter2;
|
||||||
|
if (!getUserPermissionsAttribute().isEmpty()) {
|
||||||
|
andFilter2 = new AndFilter();
|
||||||
|
andFilter2.and(new NotPresentFilter(getUserPermissionsAttribute()));
|
||||||
|
andFilter2.and(andFilter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
andFilter2 = andFilter;
|
||||||
|
}
|
||||||
|
|
||||||
String[] userAttributesToReturn = {getUserIdAttribute(), getGroupNameAttribute()};
|
String[] userAttributesToReturn = {getUserIdAttribute(), getGroupNameAttribute()};
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
@ -346,6 +362,9 @@ public class LdapClient {
|
||||||
|
|
||||||
public List<AccessIdRepresentationModel> searchPermissionsAccessIdHas(final String accessId)
|
public List<AccessIdRepresentationModel> searchPermissionsAccessIdHas(final String accessId)
|
||||||
throws InvalidArgumentException, InvalidNameException {
|
throws InvalidArgumentException, InvalidNameException {
|
||||||
|
if (getUserPermissionsAttribute().isEmpty() || getPermissionSearchFilterName().isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
isInitOrFail();
|
isInitOrFail();
|
||||||
testMinSearchForLength(accessId);
|
testMinSearchForLength(accessId);
|
||||||
|
|
||||||
|
@ -449,6 +468,9 @@ public class LdapClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> searchDnForPermissionAccessId(String accessId) {
|
private List<String> searchDnForPermissionAccessId(String accessId) {
|
||||||
|
if (getUserPermissionsAttribute().isEmpty() || getPermissionSearchFilterName().isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
final AndFilter andFilter = new AndFilter();
|
final AndFilter andFilter = new AndFilter();
|
||||||
andFilter.and(
|
andFilter.and(
|
||||||
new EqualsFilter(getPermissionSearchFilterName(), getPermissionSearchFilterValue()));
|
new EqualsFilter(getPermissionSearchFilterName(), getPermissionSearchFilterValue()));
|
||||||
|
@ -967,7 +989,8 @@ public class LdapClient {
|
||||||
String firstName = context.getStringAttribute(getUserFirstnameAttribute());
|
String firstName = context.getStringAttribute(getUserFirstnameAttribute());
|
||||||
String lastName = context.getStringAttribute(getUserLastnameAttribute());
|
String lastName = context.getStringAttribute(getUserLastnameAttribute());
|
||||||
accessId.setName(String.format("%s, %s", lastName, firstName));
|
accessId.setName(String.format("%s, %s", lastName, firstName));
|
||||||
} else if (context.getStringAttribute(getUserPermissionsAttribute()) == null) {
|
} else if (getUserPermissionsAttribute().isEmpty() ||
|
||||||
|
context.getStringAttribute(getUserPermissionsAttribute()) == null) {
|
||||||
if (useDnForGroups()) {
|
if (useDnForGroups()) {
|
||||||
accessId.setAccessId(getDnFromContext(context)); // fully qualified dn
|
accessId.setAccessId(getDnFromContext(context)); // fully qualified dn
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue