@Test public void testGetProviderURLWithSpaces() throws Exception { final Map<String, String> properties = new HashMap<>(); properties.put("ldap.host", "localhost"); properties.put("ldap.port", "389"); properties.put("ldap.sslEnabled", "false"); final LdapManager manager = new LdapManager( properties ); final LdapName name = new LdapName("ou=people,dc=example with spaces,dc=org"); final String result = manager.getProviderURL( name ); assertEquals("ldap: }
String getProviderURL(LdapName baseDN) throws NamingException { StringBuffer ldapURL = new StringBuffer(); try { for ( String host : hosts ) { final URI uri = new URI(sslEnabled ? "ldaps" : "ldap", null, host, port, "/" + baseDN.toString(), null, null); ldapURL.append(uri.toASCIIString()); ldapURL.append(" "); } return ldapURL.toString().trim(); } catch ( Exception e ) { Log.error( "Unable to generate provider URL for baseDN: '{}'.", baseDN, e ); throw new NamingException( "Unable to generate provider URL for baseDN: '"+baseDN+"': " + e.getMessage() ); } }
LdapManager { String getProviderURL(LdapName baseDN) throws NamingException { StringBuffer ldapURL = new StringBuffer(); try { for ( String host : hosts ) { final URI uri = new URI(sslEnabled ? "ldaps" : "ldap", null, host, port, "/" + baseDN.toString(), null, null); ldapURL.append(uri.toASCIIString()); ldapURL.append(" "); } return ldapURL.toString().trim(); } catch ( Exception e ) { Log.error( "Unable to generate provider URL for baseDN: '{}'.", baseDN, e ); throw new NamingException( "Unable to generate provider URL for baseDN: '"+baseDN+"': " + e.getMessage() ); } } }
LdapManager { String getProviderURL(LdapName baseDN) throws NamingException { StringBuffer ldapURL = new StringBuffer(); try { for ( String host : hosts ) { final URI uri = new URI(sslEnabled ? "ldaps" : "ldap", null, host, port, "/" + baseDN.toString(), null, null); ldapURL.append(uri.toASCIIString()); ldapURL.append(" "); } return ldapURL.toString().trim(); } catch ( Exception e ) { Log.error( "Unable to generate provider URL for baseDN: '{}'.", baseDN, e ); throw new NamingException( "Unable to generate provider URL for baseDN: '"+baseDN+"': " + e.getMessage() ); } } LdapManager(Map<String, String> properties); }
LdapManager { String getProviderURL(LdapName baseDN) throws NamingException { StringBuffer ldapURL = new StringBuffer(); try { for ( String host : hosts ) { final URI uri = new URI(sslEnabled ? "ldaps" : "ldap", null, host, port, "/" + baseDN.toString(), null, null); ldapURL.append(uri.toASCIIString()); ldapURL.append(" "); } return ldapURL.toString().trim(); } catch ( Exception e ) { Log.error( "Unable to generate provider URL for baseDN: '{}'.", baseDN, e ); throw new NamingException( "Unable to generate provider URL for baseDN: '"+baseDN+"': " + e.getMessage() ); } } LdapManager(Map<String, String> properties); static void setInstance(LdapManager instance); static LdapManager getInstance(); static List<String> splitFilter( final String input ); static String joinFilter( char operator, List<String> parts ); LdapName parseAsLdapNameOrLog( String value ); static Rdn[] getRelativeDNFromResult( SearchResult answer ); LdapContext getContext(); LdapContext getContext(LdapName baseDN); boolean checkAuthentication(Rdn[] userRDN, String password); boolean isFindUsersFromGroupsEnabled(); static LdapName createNewAbsolute( LdapName base, Rdn[] relative ); Rdn[] findUserRDN( String username ); Rdn[] findUserRDN(String username, LdapName baseDN); Rdn[] findGroupRDN(String groupname); LdapName findGroupAbsoluteDN(String groupname); Rdn[] findGroupRDN(String groupname, LdapName baseDN); boolean isGroupDN(LdapName dn); Collection<String> getHosts(); void setHosts(Collection<String> hosts); int getPort(); void setPort(int port); boolean isDebugEnabled(); void setDebugEnabled(boolean debugEnabled); boolean isSslEnabled(); void setSslEnabled(boolean sslEnabled); boolean isStartTlsEnabled(); void setStartTlsEnabled(boolean startTlsEnabled); String getUsernameField(); String getUsernameSuffix(); void setUsernameField(String usernameField); void setUsernameSuffix(String usernameSuffix); LdapUserTester.PropertyMapping getNameField(); void setNameField(LdapUserTester.PropertyMapping nameField); String getEmailField(); void setEmailField(String emailField); LdapName getBaseDN(); void setBaseDN(LdapName baseDN); LdapName getAlternateBaseDN(); void setAlternateBaseDN(LdapName alternateBaseDN); LdapName getUsersBaseDN( String username ); LdapName getGroupsBaseDN(String groupname); String getAdminDN(); void setAdminDN(String adminDN); String getAdminPassword(); void setAdminPassword(String adminPassword); void setConnectionPoolEnabled(boolean connectionPoolEnabled); boolean isConnectionPoolEnabled(); String getSearchFilter(); void setSearchFilter(String searchFilter); boolean isSubTreeSearch(); void setSubTreeSearch(boolean subTreeSearch); boolean isFollowReferralsEnabled(); void setFollowReferralsEnabled(boolean followReferrals); boolean isFollowAliasReferralsEnabled(); void setFollowAliasReferralsEnabled(boolean followAliasReferrals); String getGroupNameField(); void setGroupNameField(String groupNameField); String getGroupMemberField(); void setGroupMemberField(String groupMemberField); String getGroupDescriptionField(); void setGroupDescriptionField(String groupDescriptionField); boolean isPosixMode(); void setPosixMode(boolean posixMode); String getGroupSearchFilter(); boolean isFlattenNestedGroups(); void setFlattenNestedGroups(boolean flattenNestedGroups); void setGroupSearchFilter(String groupSearchFilter); List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim); List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim, boolean escapeJIDs); String retrieveSingle(String attribute, String searchFilter, boolean failOnMultipleResults); String retrieveSingle(String attribute, String searchFilter, boolean failOnMultipleResults, LdapName baseDN); List<String> retrieveAttributeOf(String attributeName, LdapName dn); Integer retrieveListCount(String attribute, String searchFilter); static String sanitizeSearchFilter(final String value); static LdapName escapeForJNDI(Rdn... rdn); static String sanitizeSearchFilter(final String value, boolean acceptWildcard ); }
LdapManager { String getProviderURL(LdapName baseDN) throws NamingException { StringBuffer ldapURL = new StringBuffer(); try { for ( String host : hosts ) { final URI uri = new URI(sslEnabled ? "ldaps" : "ldap", null, host, port, "/" + baseDN.toString(), null, null); ldapURL.append(uri.toASCIIString()); ldapURL.append(" "); } return ldapURL.toString().trim(); } catch ( Exception e ) { Log.error( "Unable to generate provider URL for baseDN: '{}'.", baseDN, e ); throw new NamingException( "Unable to generate provider URL for baseDN: '"+baseDN+"': " + e.getMessage() ); } } LdapManager(Map<String, String> properties); static void setInstance(LdapManager instance); static LdapManager getInstance(); static List<String> splitFilter( final String input ); static String joinFilter( char operator, List<String> parts ); LdapName parseAsLdapNameOrLog( String value ); static Rdn[] getRelativeDNFromResult( SearchResult answer ); LdapContext getContext(); LdapContext getContext(LdapName baseDN); boolean checkAuthentication(Rdn[] userRDN, String password); boolean isFindUsersFromGroupsEnabled(); static LdapName createNewAbsolute( LdapName base, Rdn[] relative ); Rdn[] findUserRDN( String username ); Rdn[] findUserRDN(String username, LdapName baseDN); Rdn[] findGroupRDN(String groupname); LdapName findGroupAbsoluteDN(String groupname); Rdn[] findGroupRDN(String groupname, LdapName baseDN); boolean isGroupDN(LdapName dn); Collection<String> getHosts(); void setHosts(Collection<String> hosts); int getPort(); void setPort(int port); boolean isDebugEnabled(); void setDebugEnabled(boolean debugEnabled); boolean isSslEnabled(); void setSslEnabled(boolean sslEnabled); boolean isStartTlsEnabled(); void setStartTlsEnabled(boolean startTlsEnabled); String getUsernameField(); String getUsernameSuffix(); void setUsernameField(String usernameField); void setUsernameSuffix(String usernameSuffix); LdapUserTester.PropertyMapping getNameField(); void setNameField(LdapUserTester.PropertyMapping nameField); String getEmailField(); void setEmailField(String emailField); LdapName getBaseDN(); void setBaseDN(LdapName baseDN); LdapName getAlternateBaseDN(); void setAlternateBaseDN(LdapName alternateBaseDN); LdapName getUsersBaseDN( String username ); LdapName getGroupsBaseDN(String groupname); String getAdminDN(); void setAdminDN(String adminDN); String getAdminPassword(); void setAdminPassword(String adminPassword); void setConnectionPoolEnabled(boolean connectionPoolEnabled); boolean isConnectionPoolEnabled(); String getSearchFilter(); void setSearchFilter(String searchFilter); boolean isSubTreeSearch(); void setSubTreeSearch(boolean subTreeSearch); boolean isFollowReferralsEnabled(); void setFollowReferralsEnabled(boolean followReferrals); boolean isFollowAliasReferralsEnabled(); void setFollowAliasReferralsEnabled(boolean followAliasReferrals); String getGroupNameField(); void setGroupNameField(String groupNameField); String getGroupMemberField(); void setGroupMemberField(String groupMemberField); String getGroupDescriptionField(); void setGroupDescriptionField(String groupDescriptionField); boolean isPosixMode(); void setPosixMode(boolean posixMode); String getGroupSearchFilter(); boolean isFlattenNestedGroups(); void setFlattenNestedGroups(boolean flattenNestedGroups); void setGroupSearchFilter(String groupSearchFilter); List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim); List<String> retrieveList(String attribute, String searchFilter, int startIndex, int numResults, String suffixToTrim, boolean escapeJIDs); String retrieveSingle(String attribute, String searchFilter, boolean failOnMultipleResults); String retrieveSingle(String attribute, String searchFilter, boolean failOnMultipleResults, LdapName baseDN); List<String> retrieveAttributeOf(String attributeName, LdapName dn); Integer retrieveListCount(String attribute, String searchFilter); static String sanitizeSearchFilter(final String value); static LdapName escapeForJNDI(Rdn... rdn); static String sanitizeSearchFilter(final String value, boolean acceptWildcard ); static final SystemProperty<Integer> LDAP_PAGE_SIZE; }