Examples of CLdapServerConfiguration


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");
    }

    // get the ldap model object
    CLdapServerConfiguration ldapServer = toLdapModel(ldapServerRequest.getData());
    if (ldapServer.getId() == null && request.getResourceRef() != null) {
      ldapServer.setId(request.getResourceRef().getQueryAsForm().getFirstValue("ldapServerId"));
    }
    replaceFakePassword(ldapServer.getConnectionInfo(), ldapServer.getId(), ldapConfigurationManager);

    // validate it
    ValidationResponse validationResponse = this.configurationValidator.validateLdapServerConfiguration(
        ldapServer,
        false);
    // if the info is not valid throw
    if (!validationResponse.isValid()) {
      throw new InvalidConfigurationException(validationResponse);
    }

    // its valid, now we need to deal with getting the users
    LdapUserListResponse result = new LdapUserListResponse();
    try {
      // get the users
      SortedSet<LdapUser> ldapUsers = ldapConnectionTester.testUserAndGroupMapping(
          buildDefaultLdapContextFactory(ldapServer.getId(), ldapServer.getConnectionInfo()),
          LdapConnectionUtils.getLdapAuthConfiguration(ldapServer),
          20
      );

      // now add them to the result
View Full Code Here

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

  {
    LdapConfigurationManager ldapConfigManager = this.lookup(LdapConfigurationManager.class);

    String id = "testDeleteServer";

    CLdapServerConfiguration serverConfig = new CLdapServerConfiguration();
    serverConfig.setId(id);
    serverConfig.setName(id + "-name");

    CConnectionInfo connInfo = this.buildConnectionInfo();
    serverConfig.setConnectionInfo(connInfo);
    serverConfig.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());

    ldapConfigManager.addLdapServerConfiguration(serverConfig);
    ldapConfigManager.deleteLdapServerConfiguration(id);

    try {
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("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());

    ldapConfigurationManager.setServerOrder(newOrder);

    // 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
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.