Package com.sonatype.security.ldap.api.dto

Examples of com.sonatype.security.ldap.api.dto.LdapServerConfigurationDTO


  public void testUserAndGroupMappingsToSelfSignedLdapServer()
      throws Exception
  {
    final NexusClient nexusClient = getNexusClient();

    final LdapServerConfigurationDTO ldapServerConfig = getLdapServerConfiguration();
    final URI uri = getLdapServerUri(ldapServerConfig);

    // trust ldap server certificate
    nexusClient.getSubsystem(Certificates.class).get(uri.getHost(), uri.getPort(), uri.getScheme()).save();

    // disable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).disableFor(ldapTrustStoreKey(ldapServerConfig.getId()));

    // test without sending the ldap server id. This will result in not using Nexus SSL Trust Store which
    // should result in a failure
    try {
      testUserAndGroupMappings(ldapServerConfig, false);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // test with sending the ldap server id. Nexus SSL Trust Store will not be used as is not enabled
    // which should result in a failure
    try {
      testUserAndGroupMappings(ldapServerConfig, true);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // enable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).enableFor(ldapTrustStoreKey(ldapServerConfig.getId()));

    // test with sending the ldap server id. Nexus SSL Trust Store will be used as it is enabled
    // which should result in a success
    testUserAndGroupMappings(ldapServerConfig, true);
View Full Code Here


  public void testLoginToSelfSignedLdapServer()
      throws Exception
  {
    final NexusClient nexusClient = getNexusClient();

    final LdapServerConfigurationDTO ldapServerConfig = getLdapServerConfiguration();
    final URI uri = getLdapServerUri(ldapServerConfig);

    // trust ldap server certificate
    nexusClient.getSubsystem(Certificates.class).get(uri.getHost(), uri.getPort(), uri.getScheme()).save();

    // disable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).disableFor(ldapTrustStoreKey(ldapServerConfig.getId()));

    // test without sending the ldap server id. This will result in not using Nexus SSL Trust Store which
    // should result in a failure
    try {
      testLogin(ldapServerConfig, false);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // test with sending the ldap server id. Nexus SSL Trust Store will not be used as is not enabled
    // which should result in a failure
    try {
      testLogin(ldapServerConfig, true);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // enable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).enableFor(ldapTrustStoreKey(ldapServerConfig.getId()));

    // test with sending the ldap server id. Nexus SSL Trust Store will be used as it is enabled
    // which should result in a success
    testLogin(ldapServerConfig, true);
View Full Code Here

  private LdapServerRequest createServer()
      throws Exception
  {
    LdapServerRequest serverRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    serverRequest.setData(dto);

    dto.setId(null); // not set
    dto.setName("testPost");
    dto.setUrl(null); // set on the return, not the request

    LdapConnectionInfoDTO connInfo = new LdapConnectionInfoDTO();
    dto.setConnectionInfo(connInfo);

    connInfo.setAuthScheme("ldap");
    connInfo.setBackupMirrorHost("backupHost");
    connInfo.setBackupMirrorPort(11111);
    connInfo.setBackupMirrorProtocol("ldap");
    connInfo.setCacheTimeout(30);
    connInfo.setConnectionRetryDelay(300);
    connInfo.setConnectionTimeout(15);
    connInfo.setHost("localhost");
    connInfo.setPort(386);
    connInfo.setProtocol("ldap");
    connInfo.setRealm("");
    connInfo.setSearchBase("ou=searchbase");
    connInfo.setSystemPassword(encodeBase64("systemPassword"));
    connInfo.setSystemUsername(encodeBase64("systemUsername"));

    LdapUserAndGroupAuthConfigurationDTO userGroupConf = new LdapUserAndGroupAuthConfigurationDTO();
    dto.setUserAndGroupConfig(userGroupConf);

    userGroupConf.setUserMemberOfAttribute("userMemberOfAttribute");
    userGroupConf.setGroupBaseDn("groupBaseDn");
    userGroupConf.setGroupIdAttribute("groupIdAttribute");
    userGroupConf.setGroupMemberAttribute("groupMemberAttribute");
View Full Code Here

  @Test
  public void testPostFail()
      throws IOException
  {
    LdapServerRequest serverRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    serverRequest.setData(dto);

    dto.setId(null); // not set
    dto.setName("testPost");
    dto.setUrl(null); // set on the return, not the request

    LdapConnectionInfoDTO connInfo = new LdapConnectionInfoDTO();
    dto.setConnectionInfo(connInfo);

    connInfo.setAuthScheme("ldap");
    connInfo.setBackupMirrorHost("backupHost");
    connInfo.setBackupMirrorPort(11111);
    connInfo.setBackupMirrorProtocol("ldap");
    connInfo.setCacheTimeout(30);
    connInfo.setConnectionRetryDelay(300);
    connInfo.setConnectionTimeout(15);
    connInfo.setHost(null); // missing host
    connInfo.setPort(386);
    connInfo.setProtocol("ldap");
    connInfo.setRealm("");
    connInfo.setSearchBase("ou=searchbase");
    connInfo.setSystemPassword(encodeBase64("systemPassword"));
    connInfo.setSystemUsername(encodeBase64("systemUsername"));

    LdapUserAndGroupAuthConfigurationDTO userGroupConf = new LdapUserAndGroupAuthConfigurationDTO();
    dto.setUserAndGroupConfig(userGroupConf);

    userGroupConf.setUserMemberOfAttribute("userMemberOfAttribute");
    userGroupConf.setGroupBaseDn("groupBaseDn");
    userGroupConf.setGroupIdAttribute("groupIdAttribute");
    userGroupConf.setGroupMemberAttribute("groupMemberAttribute");
View Full Code Here

  }

  private LdapServerRequest createServer() throws Exception {
    LdapServerRequest serverRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    serverRequest.setData(dto);

    dto.setId(null); // not set
    dto.setName("testPost");
    dto.setUrl(null); // set on the return, not the request

    LdapConnectionInfoDTO connInfo = new LdapConnectionInfoDTO();
    dto.setConnectionInfo(connInfo);

    connInfo.setAuthScheme("ldap");
    connInfo.setBackupMirrorHost("backupHost");
    connInfo.setBackupMirrorPort(11111);
    connInfo.setBackupMirrorProtocol("ldap");
    connInfo.setCacheTimeout(30);
    connInfo.setConnectionRetryDelay(300);
    connInfo.setConnectionTimeout(15);
    connInfo.setHost("localhost");
    connInfo.setPort(386);
    connInfo.setProtocol("ldap");
    connInfo.setRealm("");
    connInfo.setSearchBase("ou=searchbase");
    connInfo.setSystemPassword(encodeBase64("systemPassword"));
    connInfo.setSystemUsername(encodeBase64("systemUsername"));

    LdapUserAndGroupAuthConfigurationDTO userGroupConf = new LdapUserAndGroupAuthConfigurationDTO();
    dto.setUserAndGroupConfig(userGroupConf);

    userGroupConf.setUserMemberOfAttribute("userMemberOfAttribute");
    userGroupConf.setGroupBaseDn("groupBaseDn");
    userGroupConf.setGroupIdAttribute("groupIdAttribute");
    userGroupConf.setGroupMemberAttribute("groupMemberAttribute");
View Full Code Here

TOP

Related Classes of com.sonatype.security.ldap.api.dto.LdapServerConfigurationDTO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.