Package org.sonatype.security.ldap.realms

Examples of org.sonatype.security.ldap.realms.LdapManager


  @Test
  public void testUserAuthentication()
      throws Exception
  {
    LdapManager ldapManager = this.lookup(LdapManager.class);

    // all systems are good
    Assert.assertNotNull(ldapManager.authenticateUser("rwalker", "rwalker123"));

    // stop the main server
    mainConnector.stop();

    // try again, this time it should hit the cache
    Assert.assertNotNull(ldapManager.authenticateUser("rwalker", "rwalker123"));

    // wait 2 sec cache should still be valid
    Thread.sleep(1000 * 2);
    Assert.assertNotNull(ldapManager.authenticateUser("rwalker", "rwalker123"));

    // now wait another 2 seconds and cache should be cleared
    Thread.sleep(1000 * 2);
    // server down and cache cleared
    try {
      ldapManager.authenticateUser("rwalker", "rwalker123");
      Assert.fail("expected NoSuchLdapUserException");
    }
    catch (AuthenticationException e) {
      // expected
    }
View Full Code Here

TOP

Related Classes of org.sonatype.security.ldap.realms.LdapManager

Copyright © 2018 www.massapicom. 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.