Search in sources :

Example 1 with DefaultLdapRealm

use of org.apache.shiro.realm.ldap.DefaultLdapRealm in project zeppelin by apache.

the class ShiroAuthenticationService method getMatchedUsers.

/**
 * Get candidated users based on searchText
 *
 * @param searchText
 * @param numUsersToFetch
 * @return
 */
@Override
public List<String> getMatchedUsers(String searchText, int numUsersToFetch) {
    List<String> usersList = new ArrayList<>();
    try {
        Collection<Realm> realmsList = getRealmsList();
        if (realmsList != null) {
            for (Realm realm : realmsList) {
                String realClassName = realm.getClass().getName();
                LOGGER.debug("RealmClass.getName: {}", realClassName);
                if (INI_REALM.equals(realClassName)) {
                    usersList.addAll(getUserList((IniRealm) realm));
                } else if (LDAP_GROUP_REALM.equals(realClassName)) {
                    usersList.addAll(getUserList((DefaultLdapRealm) realm, searchText, numUsersToFetch));
                } else if (LDAP_REALM.equals(realClassName)) {
                    usersList.addAll(getUserList((LdapRealm) realm, searchText, numUsersToFetch));
                } else if (ACTIVE_DIRECTORY_GROUP_REALM.equals(realClassName)) {
                    usersList.addAll(getUserList((ActiveDirectoryGroupRealm) realm, searchText, numUsersToFetch));
                } else if (JDBC_REALM.equals(realClassName)) {
                    usersList.addAll(getUserList((JdbcRealm) realm));
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error("Exception in retrieving Users from realms ", e);
    }
    return usersList;
}
Also used : JdbcRealm(org.apache.shiro.realm.jdbc.JdbcRealm) ArrayList(java.util.ArrayList) IniRealm(org.apache.shiro.realm.text.IniRealm) LdapRealm(org.apache.zeppelin.realm.LdapRealm) DefaultLdapRealm(org.apache.shiro.realm.ldap.DefaultLdapRealm) IniRealm(org.apache.shiro.realm.text.IniRealm) LdapRealm(org.apache.zeppelin.realm.LdapRealm) Realm(org.apache.shiro.realm.Realm) KnoxJwtRealm(org.apache.zeppelin.realm.jwt.KnoxJwtRealm) DefaultLdapRealm(org.apache.shiro.realm.ldap.DefaultLdapRealm) ActiveDirectoryGroupRealm(org.apache.zeppelin.realm.ActiveDirectoryGroupRealm) JdbcRealm(org.apache.shiro.realm.jdbc.JdbcRealm) UnavailableSecurityManagerException(org.apache.shiro.UnavailableSecurityManagerException) NamingException(javax.naming.NamingException)

Aggregations

ArrayList (java.util.ArrayList)1 NamingException (javax.naming.NamingException)1 UnavailableSecurityManagerException (org.apache.shiro.UnavailableSecurityManagerException)1 Realm (org.apache.shiro.realm.Realm)1 JdbcRealm (org.apache.shiro.realm.jdbc.JdbcRealm)1 DefaultLdapRealm (org.apache.shiro.realm.ldap.DefaultLdapRealm)1 IniRealm (org.apache.shiro.realm.text.IniRealm)1 ActiveDirectoryGroupRealm (org.apache.zeppelin.realm.ActiveDirectoryGroupRealm)1 LdapRealm (org.apache.zeppelin.realm.LdapRealm)1 KnoxJwtRealm (org.apache.zeppelin.realm.jwt.KnoxJwtRealm)1