Examples of CLdapServerConfiguration


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

             LdapServerNotFoundException
  {
    final boolean lastEntry = getConfiguration().getServers().size() == 1;
    for (Iterator<CLdapServerConfiguration> iter = getConfiguration().getServers().iterator(); iter
        .hasNext(); ) {
      CLdapServerConfiguration ldapServer = iter.next();
      if (ldapServer.getId().equals(id)) {
        iter.remove();
        save();
        if (lastEntry) {
          mayDeactivateLdapRealm();
        }
View Full Code Here

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

      throws Exception
  {
    EnterpriseLdapManager ldapManager = (EnterpriseLdapManager) this.lookup(LdapManager.class);
    LdapConfigurationManager ldapConfiguration = this.lookup(LdapConfigurationManager.class);

    CLdapServerConfiguration ldapServer = ldapConfiguration.getLdapServerConfiguration("default");
    ldapServer = this.clone(ldapServer);

    Assert.assertNotNull(ldapManager.authenticateUserTest("brianf", "brianf123", ldapServer));

    try {
View Full Code Here

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

      throws Exception
  {
    EnterpriseLdapManager ldapManager = (EnterpriseLdapManager) this.lookup(LdapManager.class);
    LdapConfigurationManager ldapConfiguration = this.lookup(LdapConfigurationManager.class);

    CLdapServerConfiguration ldapServer = ldapConfiguration.getLdapServerConfiguration("default");
    ldapServer = this.clone(ldapServer);
    ldapServer.getConnectionInfo().setHost("INVALIDSERVERNAME");

    try {
      ldapManager.authenticateUserTest("brianf", "brianf123", ldapServer);
      Assert.fail("Expected NoSuchUserException");
    }
View Full Code Here

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

  }

  protected CLdapServerConfiguration toLdapModel(final LdapServerConfigurationDTO dto)
      throws ResourceException, InvalidConfigurationException
  {
    CLdapServerConfiguration config = convert(dto, new CLdapServerConfiguration());
    config.setConnectionInfo(decode(config.getConnectionInfo()));
    return config;
  }
View Full Code Here

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

      return null;
    }
    String systemPassword = connectionInfo.getSystemPassword();
    if (FAKE_PASSWORD.equals(systemPassword) && ldapServerId != null) {
      try {
        CLdapServerConfiguration config = ldapConfigurationManager.getLdapServerConfiguration(ldapServerId);
        connectionInfo.setSystemPassword(config.getConnectionInfo().getSystemPassword());
      }
      catch (LdapServerNotFoundException e) {
        throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, e);
      }
    }
View Full Code Here

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

        }
        catch (Exception e) {
          throw new CorruptModelException("Could not decrypt legacy encrypted LDAP password during upgrade", e);
        }
      }
      final CLdapServerConfiguration newServerConfig = new CLdapServerConfiguration();
      newServerConfig.setId("default");
      newServerConfig.setName(buildName(ossConfiguration.getConnectionInfo()));
      newServerConfig.setConnectionInfo(convertConnectionInfo(ossConfiguration.getConnectionInfo()));
      // encrypt system password
      if (newServerConfig.getConnectionInfo() != null
          && !Strings.isNullOrEmpty(newServerConfig.getConnectionInfo().getSystemPassword())) {
        try {
          newServerConfig.getConnectionInfo().setSystemPassword(
              passwordHelper.encrypt(newServerConfig.getConnectionInfo().getSystemPassword()));
        }
        catch (Exception e) {
          // this means JRE does not have needed JCE stuff? Die hard
          throw Throwables.propagate(e);
        }
      }
      newServerConfig.setUserAndGroupConfig(convertUserAndGroupInfo(ossConfiguration.getUserAndGroupConfig()));
      final CLdapConfiguration newConfiguration = new CLdapConfiguration();
      newConfiguration.setVersion(toVersion());
      newConfiguration.addServer(newServerConfig);
      new LdapConfigurationXpp3Writer().write(writer, newConfiguration);
    }
View Full Code Here

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

    if (StringUtils.isEmpty(password)) {
      throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Missing password argument.");
    }

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

    // try the login
    try {
      this.ldapManager.authenticateUserTest(username, password, ldapServer);
    }
View Full Code Here

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

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

    String id = "testAddAndGetServer";

    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);
    CLdapServerConfiguration result = ldapConfigManager.getLdapServerConfiguration(id);
    Assert.assertNotNull(result);

    // compare the results
    this.compareConfiguration(serverConfig, result);
  }
View Full Code Here

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

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

    String id = "testUpdateServer";

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

    serverConfig.setConnectionInfo(this.buildConnectionInfo());
    serverConfig.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());

    // add the server
    ldapConfigManager.addLdapServerConfiguration(serverConfig);

    // NOT the same instance!
    serverConfig = new CLdapServerConfiguration();
    serverConfig.setId(id);
    serverConfig.setName(id + "-name");

    serverConfig.setConnectionInfo(this.buildConnectionInfo());
    serverConfig.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());

    serverConfig.setName(id + "newName");
    serverConfig.getConnectionInfo().setBackupMirrorHost("newbackupMirrorHost");
    serverConfig.getUserAndGroupConfig().setUserBaseDn("newuserBaseDn");
    // save the updated one
    ldapConfigManager.updateLdapServerConfiguration(serverConfig);

    // get the config
    CLdapServerConfiguration result = ldapConfigManager.getLdapServerConfiguration(id);

    // manual check a couple things
    Assert.assertEquals(id + "newName", result.getName());
    Assert.assertEquals("newbackupMirrorHost", result.getConnectionInfo().getBackupMirrorHost());
    Assert.assertEquals("newuserBaseDn", result.getUserAndGroupConfig().getUserBaseDn());

    // compare the results
    this.compareConfiguration(serverConfig, result);

    // make sure there is only the one item
View Full Code Here

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

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

    CLdapServerConfiguration ldapServer1 = new CLdapServerConfiguration();
    ldapServer1.setName("testGet1");
    ldapServer1.setConnectionInfo(this.buildConnectionInfo());
    ldapServer1.setUserAndGroupConfig(this.buildUserAndGroupAuthConfiguration());

    // HERE IS THE MAGIC FOR THIS TEST
    ldapServer1.getUserAndGroupConfig().setPreferredPasswordEncoding("Clear"); // doesn't matter the actual value

    ldapConfigurationManager.addLdapServerConfiguration(ldapServer1);

    // now get the second one
    PlexusResource pr = this.lookup(PlexusResource.class, "LdapServerPlexusResource");
    LdapServerRequest ldapResponse = (LdapServerRequest) pr.get(
        null,
        this.buildRequest(ldapServer1.getId()),
        null,
        null);

    this.compare(ldapResponse.getData(), ldapServer1);
  }
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.