container-common/src/main/java/com/streamsets/datacollector/http/LdapLoginModule.java
private List<String> getUserRoles(String username, String userDn)
  {
    List<String> roleList = new ArrayList<>();
    if (StringUtils.isBlank(_roleBaseDn)|| StringUtils.isBlank(_roleObjectClass)
        || StringUtils.isBlank(_roleNameAttribute) || StringUtils.isBlank(_roleMemberAttribute)){
      LOG.debug("Failed to get roles because at least one of the following is null : " +
          "[_roleBaseDn, _roleObjectClass, _roleNameAttribute, _roleMemberAttribute ]");
      return roleList;
    }

    String roleFilter = buildFilter(_roleFilter, _roleObjectClass, _roleMemberAttribute);
    if (_roleFilter.contains(DN)) {
      userDn = userDn.replace("\\", "\\\\\\");
      roleFilter = roleFilter.replace(DN, userDn);
    } else if (_roleFilter.contains(USER)){
      roleFilter = roleFilter.replace(USER, username);
    } else {
      LOG.error("roleFilter contains invalid filter {}. Check the roleFilter option");
      return roleList;
    }

    LOG.debug("Searching roles using the filter {} on role baseDn {}", roleFilter, _roleBaseDn);
    // Get the group names from each group, which is obtained from roleNameAttribute attribute.
    SearchRequest request = new SearchRequest(_roleBaseDn, roleFilter, _roleNameAttribute);
    request.setSearchScope(SearchScope.SUBTREE);

    try {
      SearchOperation search = new SearchOperation(conn);
      org.ldaptive.SearchResult result = search.execute(request).getResult();
      Collection<LdapEntry> entries = result.getEntries();
      LOG.info("Found roles?: {}", !(entries == null || entries.isEmpty()));
      if (entries != null) {
        for (LdapEntry entry : entries) {
          roleList.add(entry.getAttribute().getStringValue());
        }
      }
    } catch (LdapException ex) {
      LOG.error(ex.getMessage(), ex);
    }
    LOG.info("Found roles: {}", roleList);
    return roleList;
  }
private List<String> getUserRoles(String username, String userDn)
  {
    List<String> roleList = new ArrayList<>();
    if (StringUtils.isBlank(_roleBaseDn)|| StringUtils.isBlank(_roleObjectClass)
        || StringUtils.isBlank(_roleNameAttribute) || StringUtils.isBlank(_roleMemberAttribute)){
      LOG.debug("Failed to get roles because at least one of the following is null : " +
          "[_roleBaseDn, _roleObjectClass, _roleNameAttribute, _roleMemberAttribute ]");
      return roleList;
    }

    String roleFilter = buildFilter(_roleFilter, _roleObjectClass, _roleMemberAttribute);
    if (_roleFilter.contains(DN)) {
      userDn = userDn.replace("\\", "\\\\\\");
      roleFilter = roleFilter.replace(DN, userDn);
    } else if (_roleFilter.contains(USER)){
      roleFilter = roleFilter.replace(USER, username);
    } else {
      LOG.error("roleFilter contains invalid filter {}. Check the roleFilter option");
      return roleList;
    }

    LOG.debug("Searching roles using the filter {} on role baseDn {}", roleFilter, _roleBaseDn);
    // Get the group names from each group, which is obtained from roleNameAttribute attribute.
    SearchRequest request = new SearchRequest(_roleBaseDn, roleFilter, _roleNameAttribute);
    request.setSearchScope(SearchScope.SUBTREE);

    try {
      SearchOperation search = new SearchOperation(conn);
      org.ldaptive.SearchResult result = search.execute(request).getResult();
      Collection<LdapEntry> entries = result.getEntries();
      LOG.info("Found roles?: {}", !(entries == null || entries.isEmpty()));
      if (entries != null) {
        for (LdapEntry entry : entries) {
          roleList.add(entry.getAttribute().getStringValue());
        }
      }
    } catch (LdapException ex) {
      LOG.error(ex.getMessage(), ex);
    }
    LOG.info("Found roles: {}", roleList);
    return roleList;
  }
private List < String > getUserRoles ( String username , String userDn ) { List < String > roleList = new ArrayList <> ( ) ; if ( StringUtils . isBlank ( _roleBaseDn ) || StringUtils . isBlank ( _roleObjectClass ) || StringUtils . isBlank ( _roleNameAttribute ) || StringUtils . isBlank ( _roleMemberAttribute ) ) { LOG . debug ( "Failed to get roles because at least one of the following is null : " + "[_roleBaseDn, _roleObjectClass, _roleNameAttribute, _roleMemberAttribute ]" ) ; return roleList ; } String roleFilter = buildFilter ( _roleFilter , _roleObjectClass , _roleMemberAttribute ) ; if ( _roleFilter . contains ( DN ) ) { userDn = userDn . replace ( "\\" , "\\\\\\" ) ; roleFilter = roleFilter . replace ( DN , userDn ) ; } else if ( _roleFilter . contains ( USER ) ) { roleFilter = roleFilter . replace ( USER , username ) ; } else { LOG . error ( "roleFilter contains invalid filter {}. Check the roleFilter option" ) ; return roleList ; } LOG . debug ( "Searching roles using the filter {} on role baseDn {}" , roleFilter , _roleBaseDn ) ; // Get the group names from each group, which is obtained from roleNameAttribute attribute. SearchRequest request = new SearchRequest ( _roleBaseDn , roleFilter , _roleNameAttribute ) ; request . setSearchScope ( SearchScope . SUBTREE ) ; try { SearchOperation search = new SearchOperation ( conn ) ; org . ldaptive . SearchResult result = search . execute ( request ) . getResult ( ) ; Collection < LdapEntry > entries = result . getEntries ( ) ; LOG . info ( "Found roles?: {}" , ! ( entries == null || entries . isEmpty ( ) ) ) ; if ( entries != null ) { for ( LdapEntry entry : entries ) { roleList . add ( entry . getAttribute ( ) . getStringValue ( ) ) ; } } } catch ( LdapException ex ) { LOG . error ( ex . getMessage ( ) , ex ) ; } LOG . info ( "Found roles: {}" , roleList ) ; return roleList ; }
attempts to get the users roles
<p/>
NOTE: this is not an user authenticated operation

@param username
@return
@throws LoginException
attempts to get the users roles <p / > NOTE : this is not an user authenticated operation