@Test public void testFindUserManagerWhenPrimaryPrincipal() throws NoSuchUserManagerException { final PrincipalCollection principals = getPrincipals(); UserManager userManager = underTest.findUserManager(principals); assertThat(userManager, is(userManagerAlpha)); }
public UserManager findUserManager(final PrincipalCollection principals) throws NoSuchUserManagerException { if (principals == null) { throw new NoSuchUserManagerException("Missing principals"); } boolean isPrimary = true; for (final String realmName : principals.getRealmNames()) { if (isPrimary || principals.fromRealm(realmName).contains(principals.getPrimaryPrincipal())) { for (final UserManager userManager : userManagers) { if (realmName.equals(userManager.getAuthenticationRealmName())) { return userManager; } } isPrimary = false; } } throw new NoSuchUserManagerException("User-manager not found for realm(s)", principals.getRealmNames().toString()); }
UserPrincipalsHelper extends ComponentSupport { public UserManager findUserManager(final PrincipalCollection principals) throws NoSuchUserManagerException { if (principals == null) { throw new NoSuchUserManagerException("Missing principals"); } boolean isPrimary = true; for (final String realmName : principals.getRealmNames()) { if (isPrimary || principals.fromRealm(realmName).contains(principals.getPrimaryPrincipal())) { for (final UserManager userManager : userManagers) { if (realmName.equals(userManager.getAuthenticationRealmName())) { return userManager; } } isPrimary = false; } } throw new NoSuchUserManagerException("User-manager not found for realm(s)", principals.getRealmNames().toString()); } }
UserPrincipalsHelper extends ComponentSupport { public UserManager findUserManager(final PrincipalCollection principals) throws NoSuchUserManagerException { if (principals == null) { throw new NoSuchUserManagerException("Missing principals"); } boolean isPrimary = true; for (final String realmName : principals.getRealmNames()) { if (isPrimary || principals.fromRealm(realmName).contains(principals.getPrimaryPrincipal())) { for (final UserManager userManager : userManagers) { if (realmName.equals(userManager.getAuthenticationRealmName())) { return userManager; } } isPrimary = false; } } throw new NoSuchUserManagerException("User-manager not found for realm(s)", principals.getRealmNames().toString()); } @Inject  UserPrincipalsHelper(final List<UserManager> userManagers); }
UserPrincipalsHelper extends ComponentSupport { public UserManager findUserManager(final PrincipalCollection principals) throws NoSuchUserManagerException { if (principals == null) { throw new NoSuchUserManagerException("Missing principals"); } boolean isPrimary = true; for (final String realmName : principals.getRealmNames()) { if (isPrimary || principals.fromRealm(realmName).contains(principals.getPrimaryPrincipal())) { for (final UserManager userManager : userManagers) { if (realmName.equals(userManager.getAuthenticationRealmName())) { return userManager; } } isPrimary = false; } } throw new NoSuchUserManagerException("User-manager not found for realm(s)", principals.getRealmNames().toString()); } @Inject  UserPrincipalsHelper(final List<UserManager> userManagers); UserStatus getUserStatus(final PrincipalCollection principals); UserManager findUserManager(final PrincipalCollection principals); }
UserPrincipalsHelper extends ComponentSupport { public UserManager findUserManager(final PrincipalCollection principals) throws NoSuchUserManagerException { if (principals == null) { throw new NoSuchUserManagerException("Missing principals"); } boolean isPrimary = true; for (final String realmName : principals.getRealmNames()) { if (isPrimary || principals.fromRealm(realmName).contains(principals.getPrimaryPrincipal())) { for (final UserManager userManager : userManagers) { if (realmName.equals(userManager.getAuthenticationRealmName())) { return userManager; } } isPrimary = false; } } throw new NoSuchUserManagerException("User-manager not found for realm(s)", principals.getRealmNames().toString()); } @Inject  UserPrincipalsHelper(final List<UserManager> userManagers); UserStatus getUserStatus(final PrincipalCollection principals); UserManager findUserManager(final PrincipalCollection principals);  }