Search in sources :

Example 6 with LdapConnectionConfig

use of org.apache.directory.ldap.client.api.LdapConnectionConfig in project graylog2-server by Graylog2.

the class LdapConnectorTest method setUp.

@Before
public void setUp() throws Exception {
    final LdapServer server = getLdapServer();
    final LdapConnectionConfig config = new LdapConnectionConfig();
    config.setLdapHost("localHost");
    config.setLdapPort(server.getPort());
    config.setName(ADMIN_DN);
    config.setCredentials(ADMIN_PASSWORD);
    connector = new LdapConnector(10000);
    connection = connector.connect(config);
}
Also used : CreateLdapServer(org.apache.directory.server.annotations.CreateLdapServer) LdapServer(org.apache.directory.server.ldap.LdapServer) LdapConnectionConfig(org.apache.directory.ldap.client.api.LdapConnectionConfig) Before(org.junit.Before)

Example 7 with LdapConnectionConfig

use of org.apache.directory.ldap.client.api.LdapConnectionConfig in project graylog2-server by Graylog2.

the class LdapUserAuthenticatorTest method setUp.

@Before
public void setUp() throws Exception {
    server = getLdapServer();
    final LdapConnectionConfig ldapConfig = new LdapConnectionConfig();
    ldapConfig.setLdapHost("localHost");
    ldapConfig.setLdapPort(server.getPort());
    ldapConfig.setName(ADMIN_DN);
    ldapConfig.setCredentials(ADMIN_PASSWORD);
    configuration = mock(Configuration.class);
    when(configuration.getPasswordSecret()).thenReturn(PASSWORD_SECRET);
    ldapConnector = new LdapConnector(10000);
    ldapSettingsService = mock(LdapSettingsService.class);
    userService = mock(UserService.class);
    ldapSettings = new LdapSettingsImpl(configuration, mock(RoleService.class));
    ldapSettings.setEnabled(true);
    ldapSettings.setUri(URI.create("ldap://localhost:" + server.getPort()));
    ldapSettings.setUseStartTls(false);
    ldapSettings.setSystemUsername(ADMIN_DN);
    ldapSettings.setSystemPassword(ADMIN_PASSWORD);
    ldapSettings.setSearchBase("ou=users,dc=example,dc=com");
    ldapSettings.setSearchPattern("(&(objectClass=posixAccount)(uid={0}))");
    ldapSettings.setDisplayNameAttribute("cn");
    ldapSettings.setActiveDirectory(false);
    ldapSettings.setGroupSearchBase("ou=groups,dc=example,dc=com");
    ldapSettings.setGroupIdAttribute("cn");
    ldapSettings.setGroupSearchPattern("(|(objectClass=groupOfNames)(objectClass=posixGroup))");
}
Also used : LdapSettingsService(org.graylog2.security.ldap.LdapSettingsService) Configuration(org.graylog2.Configuration) UserService(org.graylog2.shared.users.UserService) LdapSettingsImpl(org.graylog2.security.ldap.LdapSettingsImpl) LdapConnectionConfig(org.apache.directory.ldap.client.api.LdapConnectionConfig) LdapConnector(org.graylog2.security.ldap.LdapConnector) Before(org.junit.Before)

Aggregations

LdapConnectionConfig (org.apache.directory.ldap.client.api.LdapConnectionConfig)7 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)3 LdapNetworkConnection (org.apache.directory.ldap.client.api.LdapNetworkConnection)3 TrustAllX509TrustManager (org.graylog2.security.TrustAllX509TrustManager)3 ApiOperation (io.swagger.annotations.ApiOperation)2 IOException (java.io.IOException)2 URI (java.net.URI)2 BadRequestException (javax.ws.rs.BadRequestException)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 CursorException (org.apache.directory.api.ldap.model.cursor.CursorException)2 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)2 ValidationException (org.graylog2.plugin.database.ValidationException)2 LdapEntry (org.graylog2.shared.security.ldap.LdapEntry)2 LdapSettings (org.graylog2.shared.security.ldap.LdapSettings)2 Before (org.junit.Before)2 Timed (com.codahale.metrics.annotation.Timed)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Nonnull (javax.annotation.Nonnull)1