Java 8 UserPrincipalLookupService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 UserPrincipalLookupService class.

This code example shows how to use the following methods:lookupPrincipalByGroupName, lookupPrincipalByName
    List<String> groups = singletonList("grOup");
    StringTransformer transformer = StringTransformers.caseInsensitive(Locale.US);
    UserPrincipalLookupService lookupService = new MemoryUserPrincipalLookupService(users, groups, transformer,
            new ClosedFileSystemChecker()); 
 
    UserPrincipal user = lookupService.lookupPrincipalByName("user");
    assertEquals("usEr", user.getName());
    assertEquals(user,lookupService.lookupPrincipalByName("USER"));
 
    try { 
      lookupService.lookupPrincipalByName("group");
      fail("lookup should fail"); 
    } catch (UserPrincipalNotFoundException e) {
      assertEquals("group", e.getName());
    } 
 
    UserPrincipal group = lookupService.lookupPrincipalByGroupName("group");
    assertEquals("grOup", group.getName());
    assertEquals(group,lookupService.lookupPrincipalByGroupName("GROUP"));
 

5
CodeRank
This code example shows how to use the following methods:lookupPrincipalByGroupName, lookupPrincipalByName
public class UserLookupServiceTest { 
 
  @Test
  public void testUserLookupService() throws IOException {
    UserPrincipalLookupService service = new UserLookupService(true);
    UserPrincipal bob1 = service.lookupPrincipalByName("bob");
    UserPrincipal bob2 = service.lookupPrincipalByName("bob");
    UserPrincipal alice = service.lookupPrincipalByName("alice");
 
    assertThat(bob1).isEqualTo(bob2);
    assertThat(bob1).isNotEqualTo(alice);
 
    GroupPrincipal group1 = service.lookupPrincipalByGroupName("group");
    GroupPrincipal group2 = service.lookupPrincipalByGroupName("group");
    GroupPrincipal foo = service.lookupPrincipalByGroupName("foo");
 
    assertThat(group1).isEqualTo(group2);
    assertThat(group1).isNotEqualTo(foo);
  } 
 
5
CodeRank
See Code Examples for Java 8 UserPrincipalLookupService Methods: