Examples of CLdapServerConfiguration


Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

  {
    LdapConfigurationManager ldapConfigurationManager = this.lookup(LdapConfigurationManager.class);
    ldapConfigurationManager.deleteLdapServerConfiguration("default");

    // add 2 ldapServers
    CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
    ldapServer1.setName("testSuccess1");
    ldapServer1.setConnectionInfo(this.buildConnectionInfo());
    ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    CLdapServerConfiguration ldapServer2 = new CLdapServerConfiguration();
    ldapServer2.setName("testSuccess2");
    ldapServer2.setConnectionInfo(this.buildConnectionInfo());
    ldapServer2.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer2);

    CLdapServerConfiguration ldapServer3 = new CLdapServerConfiguration();
    ldapServer3.setName("testSuccess3");
    ldapServer3.setConnectionInfo(this.buildConnectionInfo());
    ldapServer3.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer3);

    CLdapServerConfiguration ldapServer4 = new CLdapServerConfiguration();
    ldapServer4.setName("testSuccess4");
    ldapServer4.setConnectionInfo(this.buildConnectionInfo());
    ldapServer4.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer4);

    // the order at this point is 1, 2, 3, 4
    // we will change it to 3, 1, 4, 2
    List<String> newOrder = new ArrayList<String>();
    newOrder.add(ldapServer3.getId());
    newOrder.add(ldapServer1.getId());
    newOrder.add(ldapServer4.getId());
    newOrder.add(ldapServer2.getId());

    LdapServerOrderRequest orderRequest = new LdapServerOrderRequest();
    orderRequest.setData(newOrder);

    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerOrderPlexusResource");
    List<String> resultNewOrder = ((LdapServerOrderRequest) pr.put(null, null, null, orderRequest)).getData();
    Assert.assertEquals(newOrder, resultNewOrder);

    // check for the same order as above
    List<CLdapServerConfiguration> ldapServers = ldapConfigurationManager.listLdapServerConfigurations();
    Assert.assertEquals(ldapServers.get(0).getId(), ldapServer3.getId());
    Assert.assertEquals(ldapServers.get(1).getId(), ldapServer1.getId());
    Assert.assertEquals(ldapServers.get(2).getId(), ldapServer4.getId());
    Assert.assertEquals(ldapServers.get(3).getId(), ldapServer2.getId());

  }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

  {
    LdapConfigurationManager ldapConfigurationManager = this.lookup(LdapConfigurationManager.class);
    ldapConfigurationManager.deleteLdapServerConfiguration("default");

    // add 2 ldapServers
    CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
    ldapServer1.setName("testSuccess1");
    ldapServer1.setConnectionInfo(this.buildConnectionInfo());
    ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    CLdapServerConfiguration ldapServer2 = new CLdapServerConfiguration();
    ldapServer2.setName("testSuccess2");
    ldapServer2.setConnectionInfo(this.buildConnectionInfo());
    ldapServer2.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer2);

    CLdapServerConfiguration ldapServer3 = new CLdapServerConfiguration();
    ldapServer3.setName("testSuccess3");
    ldapServer3.setConnectionInfo(this.buildConnectionInfo());
    ldapServer3.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer3);

    CLdapServerConfiguration ldapServer4 = new CLdapServerConfiguration();
    ldapServer4.setName("testSuccess4");
    ldapServer4.setConnectionInfo(this.buildConnectionInfo());
    ldapServer4.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer4);

    // the order at this point is 1, 2, 3, 4
    // we will change it to 3, 1, 4, 2
    List<String> newOrder = new ArrayList<String>();
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

    final CLdapConfiguration cnf = testSubject.load();
    assertThat(cnf.getVersion(), notNullValue());
    assertThat(cnf.getVersion(), equalTo(CLdapConfiguration.MODEL_VERSION));
    assertThat(cnf.getServers(), hasSize(1));
    final CLdapServerConfiguration server = cnf.getServers().get(0);
    assertThat(server.getConnectionInfo().getSearchBase(), equalTo("o=sonatype"));
    assertThat(server.getUserAndGroupConfig().getGroupMemberFormat(), equalTo("uid=${username},ou=people,o=sonatype"));
  }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

    final CLdapConfiguration cnf = testSubject.load();
    assertThat(cnf.getVersion(), notNullValue());
    assertThat(cnf.getVersion(), equalTo(CLdapConfiguration.MODEL_VERSION));
    assertThat(cnf.getServers(), hasSize(1));
    final CLdapServerConfiguration server = cnf.getServers().get(0);
    assertThat(server.getConnectionInfo().getSearchBase(), equalTo("o=example"));
    assertThat(server.getUserAndGroupConfig().getUserBaseDn(), equalTo("ou=people"));
  }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

      throws Exception
  {
    LdapConfigurationManager ldapConfigurationManager = this.lookup(LdapConfigurationManager.class);

    // add 2 ldapServers
    CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
    ldapServer1.setName("testGet1");
    ldapServer1.setConnectionInfo(this.buildConnectionInfo());
    ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    CLdapServerConfiguration ldapServer2 = new CLdapServerConfiguration();
    ldapServer2.setName("testGet2");
    ldapServer2.setConnectionInfo(this.buildConnectionInfo());
    ldapServer2.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer2);

    // now get the second one
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerPlexusResource");
    LdapServerRequest ldapResponse = (LdapServerRequest) pr.get(
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

  public void testPut()
      throws Exception
  {
    LdapConfigurationManager ldapConfigurationManager = this.lookup(LdapConfigurationManager.class);

    CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
    ldapServer1.setName("testPut");
    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");

    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerPlexusResource");
    Request request = this.buildRequest(ldapServer1.getId());
    LdapServerRequest ldapResponse = (LdapServerRequest) pr.put(
        null,
        request,
        null,
        ldapRequest);
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

      throws Exception
  {
    LdapConfigurationManager ldapConfigurationManager = this.lookup(LdapConfigurationManager.class);

    // add 2 ldapServers
    CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
    ldapServer1.setName("testDelete1");
    ldapServer1.setConnectionInfo(this.buildConnectionInfo());
    ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    CLdapServerConfiguration ldapServer2 = new CLdapServerConfiguration();
    ldapServer2.setName("testDelete2");
    ldapServer2.setConnectionInfo(this.buildConnectionInfo());
    ldapServer2.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());
    ldapConfigurationManager.addLdapServerConfiguration(ldapServer2);

    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerPlexusResource");
    pr.delete(null, this.buildRequest(ldapServer1.getId()), null);
    try {
      ldapConfigurationManager.getLdapServerConfiguration(ldapServer1.getId());
      Assert.fail("epected LdapServerNotFoundException");
    }
    catch (LdapServerNotFoundException e) {
      // expected
    }

    pr.delete(null, this.buildRequest(ldapServer2.getId()), null);
    try {
      ldapConfigurationManager.getLdapServerConfiguration(ldapServer1.getId());
      Assert.fail("epected LdapServerNotFoundException");
    }
    catch (LdapServerNotFoundException e) {
      // expected
    }

    try {
      pr.delete(null, this.buildRequest(ldapServer2.getId()), null);
    }
    catch (ResourceException e) {
      Assert.assertEquals(404, e.getStatus().getCode());
    }
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

    if (ldapServerRequest.getData() == null) {
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Payload is empty");
    }

    CLdapServerConfiguration ldapServer = this.toLdapModel(ldapServerRequest.getData());
    this.ldapConfigurationManager.addLdapServerConfiguration(ldapServer);

    try {
      LdapServerRequest ldapServerResponse = new LdapServerRequest();
      ldapServerResponse
          .setData(this.toDto(this.ldapConfigurationManager.getLdapServerConfiguration(ldapServer.getId())));
      // need to update the url with the new url
      ldapServerResponse.getData().setUrl(this.createChildReference(request, ldapServer.getId()).toString());

      return ldapServerResponse;
    }
    catch (LdapServerNotFoundException e) {
      throw new ResourceException(
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Payload is empty");
    }

    String serverId = this.getServerId(request);

    CLdapServerConfiguration ldapServer = this.toLdapModel(ldapServerRequest.getData());
    ldapServer.setId(serverId);
    replaceFakePassword(ldapServer.getConnectionInfo(), ldapServer.getId(), ldapConfigurationManager);

    try {
      this.ldapConfigurationManager.updateLdapServerConfiguration(ldapServer);
    }
    catch (LdapServerNotFoundException e) {
View Full Code Here

Examples of com.sonatype.security.ldap.realms.persist.model.CLdapServerConfiguration

    }

    // this list is ordered so we need to replace the old one
    final CLdapConfiguration ldapConfiguration = getConfiguration();
    for (int ii = 0; ii < ldapConfiguration.getServers().size(); ii++) {
      CLdapServerConfiguration ldapServer = ldapConfiguration.getServers().get(ii);
      if (ldapServer.getId().equals(ldapServerConfiguration.getId())) {
        ldapConfiguration.getServers().remove(ii);
        ldapConfiguration.getServers().add(ii, ldapServerConfiguration);
      }
    }
    save();
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.