Search in sources :

Example 1 with GenericEntryFactory

use of com.novell.ldapchai.impl.generic.entry.GenericEntryFactory in project ldapchai by ldapchai.

the class ChaiUtility method getRootDSE.

public static ChaiEntry getRootDSE(final ChaiProvider provider) throws ChaiUnavailableException {
    final List<String> splitUrls = provider.getChaiConfiguration().bindURLsAsList();
    final StringBuilder newUrlConfig = new StringBuilder();
    boolean currentURLsHavePath = false;
    for (final String splitUrl : splitUrls) {
        final URI uri = URI.create(splitUrl);
        final String newURI = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort();
        newUrlConfig.append(newURI);
        if (uri.getPath() != null && uri.getPath().length() > 0) {
            currentURLsHavePath = true;
        }
        newUrlConfig.append(",");
    }
    final ChaiConfiguration rootDSEChaiConfig = ChaiConfiguration.builder(provider.getChaiConfiguration()).setSetting(ChaiSetting.BIND_URLS, newUrlConfig.toString()).build();
    final ChaiProvider rootDseProvider = currentURLsHavePath ? provider.getProviderFactory().newProvider(rootDSEChaiConfig) : provider;
    // can not call the VendorFactory here, because VendorFactory in turn calls this method to get the
    // directory vendor.  Instead, we will go directly to the Generic VendorFactory
    final GenericEntryFactory genericEntryFactory = new GenericEntryFactory();
    return genericEntryFactory.newChaiEntry("", rootDseProvider);
}
Also used : ChaiProvider(com.novell.ldapchai.provider.ChaiProvider) GenericEntryFactory(com.novell.ldapchai.impl.generic.entry.GenericEntryFactory) URI(java.net.URI) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration)

Aggregations

GenericEntryFactory (com.novell.ldapchai.impl.generic.entry.GenericEntryFactory)1 ChaiConfiguration (com.novell.ldapchai.provider.ChaiConfiguration)1 ChaiProvider (com.novell.ldapchai.provider.ChaiProvider)1 URI (java.net.URI)1