]>
git.argeo.org Git - gpl/argeo-slc.git/blob - UserFilter.java
7a7bfbf56007543d34d4c26b9917e5eb0863aea6
1 package org
.argeo
.cms
.e4
.users
.providers
;
3 import static org
.argeo
.eclipse
.ui
.EclipseUiUtils
.notEmpty
;
5 import org
.argeo
.api
.cms
.CmsConstants
;
6 import org
.argeo
.cms
.auth
.UserAdminUtils
;
7 import org
.argeo
.util
.naming
.LdapAttrs
;
8 import org
.eclipse
.jface
.viewers
.Viewer
;
9 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
10 import org
.osgi
.service
.useradmin
.User
;
13 * Filter user list using JFace mechanism on the client (yet on the server) side
14 * rather than having the UserAdmin to process the search
16 public class UserFilter
extends ViewerFilter
{
17 private static final long serialVersionUID
= 5082509381672880568L;
19 private String searchString
;
20 private boolean showSystemRole
= true;
22 private final String
[] knownProps
= { LdapAttrs
.DN
, LdapAttrs
.cn
.name(), LdapAttrs
.givenName
.name(),
23 LdapAttrs
.sn
.name(), LdapAttrs
.uid
.name(), LdapAttrs
.description
.name(), LdapAttrs
.mail
.name() };
25 public void setSearchText(String s
) {
26 // ensure that the value can be used for matching
28 searchString
= ".*" + s
.toLowerCase() + ".*";
33 public void setShowSystemRole(boolean showSystemRole
) {
34 this.showSystemRole
= showSystemRole
;
38 public boolean select(Viewer viewer
, Object parentElement
, Object element
) {
39 User user
= (User
) element
;
40 if (!showSystemRole
&& user
.getName().matches(".*(" + CmsConstants
.SYSTEM_ROLES_BASEDN
+ ")"))
41 // UserAdminUtils.getProperty(user, LdifName.dn.name())
42 // .toLowerCase().endsWith(AuthConstants.ROLES_BASEDN))
45 if (searchString
== null || searchString
.length() == 0)
48 if (user
.getName().matches(searchString
))
51 for (String key
: knownProps
) {
52 String currVal
= UserAdminUtils
.getProperty(user
, key
);
53 if (notEmpty(currVal
) && currVal
.toLowerCase().matches(searchString
))