@Test public void testAuthenticate() { Account userOne = ldap.authenticate("UserOne", "userOnePassword"); assertNotNull(userOne); assertTrue("UserOne is missing the 'Git_Admins' role!", userOne.hasRole("Git_Admins")); assertTrue("UserOne is missing the 'Git_Users' role!", userOne.hasRole("Git_Users")); assertTrue("UserOne should be an administrator!", userOne.isAdministrator()); Account userOneAuthenticationFailed = ldap.authenticate("UserOne", "userTwoPassword"); assertNull(userOneAuthenticationFailed); Account userTwo = ldap.authenticate("UserTwo", "userTwoPassword"); assertNotNull(userTwo); assertTrue("UserTwo is missing the 'Git_Users' role!", userTwo.hasRole("Git_Users")); assertFalse("UserTwo has the 'Git_Admins' role!", userTwo.hasRole("Git_Admins")); assertTrue("UserTwo is missing the 'Git Admins' role!", userTwo.hasRole("Git Admins")); assertTrue("UserTwo should be an administrator!", userTwo.isAdministrator()); Account userThree = ldap.authenticate("UserThree", "userThreePassword"); assertNotNull(userThree); assertTrue("UserThree is missing the 'Git_Users' role!", userThree.hasRole("Git_Users")); assertFalse("UserThree has the 'Git_Admins role!", userThree.hasRole("Git_Admins")); assertTrue("UserThree should be an administrator!", userThree.isAdministrator()); }
@Override public Account authenticate(StandardCredentials requestCredentials) { final String username = getSimpleUsername(requestCredentials.getUsername()); final String password = requestCredentials.getPassword(); if (hasAccount(username)) { return super.authenticate(new StandardCredentials(username, password)); } return authenticate(username, password); }
LdapRealm extends CachingRealm { @Override public Account authenticate(StandardCredentials requestCredentials) { final String username = getSimpleUsername(requestCredentials.getUsername()); final String password = requestCredentials.getPassword(); if (hasAccount(username)) { return super.authenticate(new StandardCredentials(username, password)); } return authenticate(username, password); } }
LdapRealm extends CachingRealm { @Override public Account authenticate(StandardCredentials requestCredentials) { final String username = getSimpleUsername(requestCredentials.getUsername()); final String password = requestCredentials.getPassword(); if (hasAccount(username)) { return super.authenticate(new StandardCredentials(username, password)); } return authenticate(username, password); }  }
LdapRealm extends CachingRealm { @Override public Account authenticate(StandardCredentials requestCredentials) { final String username = getSimpleUsername(requestCredentials.getUsername()); final String password = requestCredentials.getPassword(); if (hasAccount(username)) { return super.authenticate(new StandardCredentials(username, password)); } return authenticate(username, password); }  static final String escapeLDAPSearchFilter(String filter); @Override void setup(Config config); @Override void start(); @Override void stop(); @Override Account authenticate(StandardCredentials requestCredentials); @Override Account authenticate(final String username, final String password); }
LdapRealm extends CachingRealm { @Override public Account authenticate(StandardCredentials requestCredentials) { final String username = getSimpleUsername(requestCredentials.getUsername()); final String password = requestCredentials.getPassword(); if (hasAccount(username)) { return super.authenticate(new StandardCredentials(username, password)); } return authenticate(username, password); }  static final String escapeLDAPSearchFilter(String filter); @Override void setup(Config config); @Override void start(); @Override void stop(); @Override Account authenticate(StandardCredentials requestCredentials); @Override Account authenticate(final String username, final String password);  }