private List<String> fetchGroupsFromLdapUser(User user, AuthenticationOrigin authenticationOrigin) throws NamingException { List<String> groups = new ArrayList<>(); if (user == null) { return groups; } String userRdn = (String) user.getAttributes().get("LDAP_RDN"); String base = ((String) authenticationOrigin.getOptions().get(AuthenticationOrigin.USERS_SEARCH)); return LDAPUtils.getGroupsFromLdapUser(authenticationOrigin.getHost(), userRdn, base); }
AuthenticationOrigin getAuthenticationOrigin(String authOrigin) { if (configuration.getAuthentication().getAuthenticationOrigins() != null) { for (AuthenticationOrigin authenticationOrigin : configuration.getAuthentication().getAuthenticationOrigins()) { if (authOrigin.equals(authenticationOrigin.getId())) { return authenticationOrigin; } } } return null; }
if (configuration.getAuthentication().getAuthenticationOrigins() != null) { for (AuthenticationOrigin authenticationOrigin : configuration.getAuthentication().getAuthenticationOrigins()) { if (authenticationOrigin.getId() != null) { switch (authenticationOrigin.getType()) { case LDAP: authenticationManagerMap.put(authenticationOrigin.getId(), new LDAPAuthenticationManager(authenticationOrigin.getHost(), configuration)); break; default: AuthenticationOrigin authenticationOrigin = new AuthenticationOrigin(); if (configuration.getAuthentication().getAuthenticationOrigins() == null) { configuration.getAuthentication().setAuthenticationOrigins(Arrays.asList(authenticationOrigin)); if (AuthenticationOrigin.AuthenticationType.OPENCGA == origin.getType()) { catalogPresent = true; break;
List<Attributes> userInfoFromLDAP = LDAPUtils.getUserInfoFromLDAP(authenticationOrigin.getHost(), Arrays.asList(userId), (String) authenticationOrigin.getOptions().get(AuthenticationOrigin.USERS_SEARCH)); if (userInfoFromLDAP == null || userInfoFromLDAP.isEmpty()) { throw new CatalogException("The user id " + userId + " does not exist nor could be found in LDAP."); if (AuthenticationOrigin.AuthenticationType.LDAP == authenticationOrigin.getType()) { if (user == null) { throw new CatalogException("Internal error: This error should never happen.");
String base = ((String) authenticationOrigin.getOptions().get(AuthenticationOrigin.GROUPS_SEARCH)); Set<String> usersFromLDAP = new HashSet<>(); usersFromLDAP.addAll(userList); try { usersFromLDAP.addAll(LDAPUtils.getUsersFromLDAPGroup(authenticationOrigin.getHost(), ldapGroup, base)); } catch (NamingException e) { logger.error(e.getMessage(), e); if (usersFromLDAP.size() > 0) { base = ((String) authenticationOrigin.getOptions().get(AuthenticationOrigin.USERS_SEARCH)); List<Attributes> userAttrList; try { List<String> userListCopy = new ArrayList<>(usersFromLDAP.size()); userListCopy.addAll(usersFromLDAP); userAttrList = LDAPUtils.getUserInfoFromLDAP(authenticationOrigin.getHost(), userListCopy, base); } catch (NamingException e) { logger.error(e.getMessage(), e);
String base = ((String) authenticationOrigin.getOptions().get(AuthenticationOrigin.GROUPS_SEARCH)); if (!LDAPUtils.existsLDAPGroup(authenticationOrigin.getHost(), externalGroup, base)) { throw new CatalogException("Group " + externalGroup + " not found in origin " + authenticationOriginId);