System.out.println("testLdapExample2");
UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke", "theduke".toCharArray());
LoginContext lc = new LoginContext("testLdapExample2", handler);
lc.login();
Subject subject = lc.getSubject();
System.out.println("Subject: "+subject);
Set groups = subject.getPrincipals(Group.class);
assertTrue("Principals contains jduke", subject.getPrincipals().contains(new SimplePrincipal("jduke")));
assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
Group roles = (Group) groups.iterator().next();
assertTrue("Echo is a role", roles.isMember(new SimplePrincipal("Echo")));
assertTrue("TheDuke is a role", roles.isMember(new SimplePrincipal("TheDuke")));
assertFalse("Echo2 is NOT a role", roles.isMember(new SimplePrincipal("Echo2")));