Search in sources :

Example 6 with DirectoryVendor

use of com.novell.ldapchai.provider.DirectoryVendor in project ldapchai by ldapchai.

the class ChaiErrors method getErrorForMessage.

public static ChaiError getErrorForMessage(final String message) {
    for (final DirectoryVendor vendor : DirectoryVendor.values()) {
        final ErrorMap errorMap = vendor.getVendorFactory().getErrorMap();
        final ChaiError errorCode = errorMap.errorForMessage(message);
        if (errorCode != null && errorCode != ChaiError.UNKNOWN) {
            return errorCode;
        }
    }
    return ChaiError.UNKNOWN;
}
Also used : DirectoryVendor(com.novell.ldapchai.provider.DirectoryVendor)

Example 7 with DirectoryVendor

use of com.novell.ldapchai.provider.DirectoryVendor in project ldapchai by ldapchai.

the class ChaiUtility method determineDirectoryVendor.

/**
 * Determines the vendor of a the ldap directory by reading RootDSE attributes.
 *
 * @param rootDSE A valid entry
 * @return the proper directory vendor, or {@link DirectoryVendor#GENERIC} if the vendor can not be determined.
 * @throws ChaiUnavailableException If the directory is unreachable
 * @throws ChaiOperationException   If there is an error reading values from the Root DSE entry
 */
public static DirectoryVendor determineDirectoryVendor(final ChaiEntry rootDSE) throws ChaiUnavailableException, ChaiOperationException {
    final Set<String> interestedAttributes = new HashSet<>();
    for (final DirectoryVendor directoryVendor : DirectoryVendor.values()) {
        interestedAttributes.addAll(directoryVendor.getVendorFactory().interestedDseAttributes());
    }
    final SearchHelper searchHelper = new SearchHelper();
    searchHelper.setAttributes(interestedAttributes.toArray(new String[interestedAttributes.size()]));
    searchHelper.setFilter("(objectClass=*)");
    searchHelper.setMaxResults(1);
    searchHelper.setSearchScope(SearchScope.BASE);
    final Map<String, Map<String, List<String>>> results = rootDSE.getChaiProvider().searchMultiValues("", searchHelper);
    if (results != null && !results.isEmpty()) {
        final Map<String, List<String>> rootDseSearchResults = results.values().iterator().next();
        for (final DirectoryVendor directoryVendor : DirectoryVendor.values()) {
            if (directoryVendor.getVendorFactory().detectVendorFromRootDSEData(rootDseSearchResults)) {
                return directoryVendor;
            }
        }
    }
    return DirectoryVendor.GENERIC;
}
Also used : DirectoryVendor(com.novell.ldapchai.provider.DirectoryVendor) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

DirectoryVendor (com.novell.ldapchai.provider.DirectoryVendor)7 ArrayList (java.util.ArrayList)4 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)4 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)3 ChaiProvider (com.novell.ldapchai.provider.ChaiProvider)3 ChaiEntry (com.novell.ldapchai.ChaiEntry)2 ChaiException (com.novell.ldapchai.exception.ChaiException)2 MalformedURLException (java.net.MalformedURLException)2 UnknownHostException (java.net.UnknownHostException)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 LdapProfile (password.pwm.config.profile.LdapProfile)2 ErrorInformation (password.pwm.error.ErrorInformation)2 ChaiError (com.novell.ldapchai.exception.ChaiError)1 ChaiConfiguration (com.novell.ldapchai.provider.ChaiConfiguration)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 URISyntaxException (java.net.URISyntaxException)1