Examples of LdapServerConfigurationDTO


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

  @Test
  public void testDamiansProblem()
      throws Exception
  {
    LdapServerRequest resource = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    resource.setData(dto);

    dto.setId("id");

    validateMarshalAndUnmarchal(resource);
  }
View Full Code Here

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

  }

  @Test
  public void testEmptyUserAndGroupConfig() {
    LdapServerRequest request = new LdapServerRequest();
    request.setData(new LdapServerConfigurationDTO());

    // and with groupBaseDn set to null
    LdapUserAndGroupAuthConfigurationDTO dto = new LdapUserAndGroupAuthConfigurationDTO();
    dto.setGroupBaseDn(null);
    dto.setGroupIdAttribute("groupIdAttribute");
View Full Code Here

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

    ldapServer1.setConnectionInfo(this.buildConnectionInfo());
    ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    LdapServerRequest ldapRequest = new LdapServerRequest();
    ldapRequest.setData(this.convert(ldapServer1, new LdapServerConfigurationDTO()));

    ldapRequest.getData().setName("testPut-new");
    ldapRequest.getData().getConnectionInfo().setHost("newhost");
    ldapRequest.getData().getUserAndGroupConfig().setEmailAddressAttribute("newEmailAddressAttribute");
View Full Code Here

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

      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");

    LdapServerRequest ldapServerRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    // dto.setId( "testPost" ); // this will be generated
    dto.setName("Test Post");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    Request request = this.buildRequest();
    LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);

    // we need to update the ID in the original, because it was set on the server
    Assert.assertNotNull(postResult.getData().getId());
    dto.setId(postResult.getData().getId());

    // update the request with the expected URL, so we can compare
    dto.setUrl(request.getResourceRef().toString() + "/" + dto.getId());

    dto.getConnectionInfo().setSystemPassword(encodeBase64((AbstractLdapPlexusResource.FAKE_PASSWORD)));
    this.compare(dto, postResult.getData());
  }
View Full Code Here

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

      throws Exception
  {
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerListPlexusResource");

    LdapServerRequest ldapServerRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    LdapConnectionInfoDTO connectionDto = new LdapConnectionInfoDTO();
    LdapUserAndGroupAuthConfigurationDTO userGroupDto = new LdapUserAndGroupAuthConfigurationDTO();

    ldapServerRequest.setData(dto);
    dto.setConnectionInfo(connectionDto);
    dto.setUserAndGroupConfig(userGroupDto);

    dto.setName("test");
    connectionDto.setHost("test");
    connectionDto.setPort(389);
    connectionDto.setSearchBase("test");
    connectionDto.setAuthScheme("none");
    connectionDto.setProtocol("ldap");
    connectionDto.setBackupMirrorProtocol("ldap");
    connectionDto.setBackupMirrorHost("asdf");
    connectionDto.setBackupMirrorPort(389);
    connectionDto.setConnectionTimeout(33);
    connectionDto.setConnectionRetryDelay(44);
    connectionDto.setCacheTimeout(55);
    userGroupDto.setEmailAddressAttribute("qasdf");
    userGroupDto.setLdapGroupsAsRoles(true);
    userGroupDto.setUserPasswordAttribute("asdf");
    userGroupDto.setUserIdAttribute("asdf");
    userGroupDto.setUserObjectClass("asdf");
    userGroupDto.setUserRealNameAttribute("asdf");
    userGroupDto.setUserSubtree(false);
    userGroupDto.setGroupSubtree(false);
    userGroupDto.setUserMemberOfAttribute("asdf");

    Request request = this.buildRequest();

    LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);

    // we need to update the ID in the original, because it was set on the server
    Assert.assertNotNull(postResult.getData().getId());
    dto.setId(postResult.getData().getId());

    // update the request with the expected URL, so we can compare
    dto.setUrl(request.getResourceRef().toString() + "/" + dto.getId());

    this.compare(dto, postResult.getData());
  }
View Full Code Here

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

    config.setConnectionInfo(decode(config.getConnectionInfo()));
    return config;
  }

  protected LdapServerConfigurationDTO toDto(CLdapServerConfiguration ldapServer) {
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    dto.setId(ldapServer.getId());
    dto.setName(ldapServer.getName());

    if (ldapServer.getConnectionInfo() != null) {
      CConnectionInfo connInfo = ldapServer.getConnectionInfo();

      LdapConnectionInfoDTO infoDto = new LdapConnectionInfoDTO();
      infoDto.setAuthScheme(connInfo.getAuthScheme());
      infoDto.setBackupMirrorHost(connInfo.getBackupMirrorHost());
      infoDto.setBackupMirrorPort(connInfo.getBackupMirrorPort());
      infoDto.setBackupMirrorProtocol(connInfo.getBackupMirrorProtocol());
      infoDto.setCacheTimeout(connInfo.getCacheTimeout());
      infoDto.setConnectionRetryDelay(connInfo.getConnectionRetryDelay());
      infoDto.setConnectionTimeout(connInfo.getConnectionTimeout());
      infoDto.setHost(connInfo.getHost());
      infoDto.setPort(connInfo.getPort());
      infoDto.setProtocol(connInfo.getProtocol());
      infoDto.setRealm(connInfo.getRealm());
      infoDto.setSearchBase(connInfo.getSearchBase());
      infoDto.setSystemUsername(connInfo.getSystemUsername());
      if (connInfo.getSystemPassword() != null) {
        infoDto.setSystemPassword(FAKE_PASSWORD);
      }
      dto.setConnectionInfo(encode(infoDto));
    }

    if (ldapServer.getUserAndGroupConfig() != null) {
      CUserAndGroupAuthConfiguration userGroupConf = ldapServer.getUserAndGroupConfig();
      LdapUserAndGroupAuthConfigurationDTO userGroupDto = new LdapUserAndGroupAuthConfigurationDTO();
      dto.setUserAndGroupConfig(userGroupDto);

      userGroupDto.setEmailAddressAttribute(userGroupConf.getEmailAddressAttribute());
      userGroupDto.setGroupBaseDn(userGroupConf.getGroupBaseDn());
      userGroupDto.setGroupIdAttribute(userGroupConf.getGroupIdAttribute());
      userGroupDto.setGroupMemberAttribute(userGroupConf.getGroupMemberAttribute());
View Full Code Here

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

    Request request = this.buildRequest();

    // ONE
    LdapServerRequest ldapServerRequest = new LdapServerRequest();
    LdapServerConfigurationDTO dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    dto.setName("testGet-1");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.getConnectionInfo().setHost("testGet1");
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    LdapServerRequest postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
    Assert.assertNotNull(postResult.getData().getId());
    expectedIds.add(postResult.getData().getId());

    // TWO
    ldapServerRequest = new LdapServerRequest();
    dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    dto.setName("testGet-2");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.getConnectionInfo().setPort(7788);
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
    Assert.assertNotNull(postResult.getData().getId());
    expectedIds.add(postResult.getData().getId());

    // THREE
    ldapServerRequest = new LdapServerRequest();
    dto = new LdapServerConfigurationDTO();
    ldapServerRequest.setData(dto);
    dto.setName("testGet-3");
    dto.setConnectionInfo(this.buildConnectionInfoDTO());
    dto.getConnectionInfo().setSearchBase("ou=testGet3");
    dto.setUserAndGroupConfig(this.buildUserAndGroupAuthConfigurationDTO());

    postResult = (LdapServerRequest) pr.post(null, request, null, ldapServerRequest);
    Assert.assertNotNull(postResult.getData().getId());
    expectedIds.add(postResult.getData().getId());
View Full Code Here

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

  public void testLdapLoginTest()
      throws Exception
  {
    LdapServerLoginTestRequest ldapServerLoginTestRequest = new LdapServerLoginTestRequest();
    ldapServerLoginTestRequest.setData(new LdapServerLoginTestDTO());
    ldapServerLoginTestRequest.getData().setConfiguration(new LdapServerConfigurationDTO());

    ldapServerLoginTestRequest.getData().getConfiguration().setId(null); // not set
    ldapServerLoginTestRequest.getData().getConfiguration().setName("test");
    ldapServerLoginTestRequest.getData().getConfiguration().setUrl(null); // set on the return, not the request
View Full Code Here

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

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

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

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

    // there will be no user as backend will fail to connect to LDAP server since it has an untrusted certificate
    {
      final List<PlexusUserResource> ldapUsers = getLdapUsers();
      assertThat(ldapUsers, hasSize(0));
    }

    // enable Nexus TrustStore for default server
    nexusClient.getSubsystem(TrustStore.class).enableFor(ldapTrustStoreKey(ldapServerConfig.getId()));
    // trust ldap server certificate
    nexusClient.getSubsystem(Certificates.class).get(uri.getHost(), uri.getPort(), uri.getScheme()).save();

    // there should be at least one user as now the certificate is trusted so ldap server can be accessed
    {
View Full Code Here

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

  public void testConnectionToSelfSignedLdapServer()
      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 connection without sending the ldap server id. This will result in not using Nexus SSL Trust Store which
    // should result in a failure
    try {
      testConnection(ldapServerConfig, false);
      assertThat("Expected to fail with Exception", false);
    }
    catch (Exception e) {
      assertThat(e.getMessage(), containsString("unable to find valid certification path"));
    }

    // test connection 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 {
      testConnection(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 connection with sending the ldap server id. Nexus SSL Trust Store will be used as it is enabled
    // which should result in a success
    testConnection(ldapServerConfig, true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.