Examples of LdapConfigurationManager


Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  public void testFailure()
      throws Exception
  {
    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());
View Full Code Here

Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  public void testGet()
      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(
        null,
View Full Code Here

Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  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");
View Full Code Here

Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  public void testDelete()
      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
    }
View Full Code Here

Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  public void testAuthenticateTest()
      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.persist.LdapConfigurationManager

  @Test
  public void testAuthenticateTestInvalidServer()
      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);
View Full Code Here

Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  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,
View Full Code Here

Examples of com.sonatype.security.ldap.persist.LdapConfigurationManager

  @Test
  public void testSuccess()
      throws Exception
  {
    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
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.