@NotNull @Override public Principal perform() { return principalManager.getEveryone(); } });
@NotNull @Override public Principal perform() { return principalManager.getEveryone(); } });
@Nonnull @Override public Principal perform() { return principalManager.getEveryone(); } });
@Override protected Principal getSecondPrincipal() throws Exception { return principalMgr.getEveryone(); }
public void testEveryoneName() throws RepositoryException { Principal everyone = principalManager.getEveryone(); String expectedName = null; // EXERCISE type the expected authorizable name using constants defined by oak. assertEquals(expectedName, everyone.getName()); }
@Override protected Principal resolvePrincipal(final String principalId) throws RepositoryException { final Principal principal; final Session session = getAdminSession(); if ("everyone".equals(principalId)) { principal = ((JackrabbitSession) session).getPrincipalManager().getEveryone(); } else { final Authorizable authorizable = this.resolveAuthorizable(principalId); principal = authorizable.getPrincipal(); } return principal; }
private Principal getValidPrincipal() throws NotExecutableException, RepositoryException { if (!(superuser instanceof JackrabbitSession)) { throw new NotExecutableException(); } PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager(); return pMgr.getEveryone(); }
@Override protected void setUp() throws Exception { super.setUp(); if (!(superuser instanceof JackrabbitSession)) { superuser.logout(); throw new NotExecutableException(); } principalMgr = ((JackrabbitSession) superuser).getPrincipalManager(); everyone = (GroupPrincipal) principalMgr.getEveryone(); }
public void testAccessByName() throws RepositoryException { Principal everyone = principalManager.getEveryone(); assertTrue(principalManager.hasPrincipal(everyone.getName())); Principal everyoneByName = null; // EXERCISE: retrieve the everyone principal by name assertEquals(everyone, everyoneByName); }
public void testGetEveryone() { Principal principal = principalMgr.getEveryone(); assertTrue(principal != null); assertTrue(isGroup(principal)); }
public void testGroupMembers() { PrincipalIterator it = principalMgr.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL); while (it.hasNext()) { Principal p = it.nextPrincipal(); if (isGroup(p) && !p.equals(principalMgr.getEveryone())) { Enumeration<? extends Principal> en = ((GroupPrincipal) p).members(); while (en.hasMoreElements()) { Principal memb = en.nextElement(); assertTrue(principalMgr.hasPrincipal(memb.getName())); } } } }
@Before @Override protected void setUp() throws Exception { super.setUp(); if (!(superuser instanceof JackrabbitSession)) { superuser.logout(); throw new NotExecutableException(); } principalMgr = ((JackrabbitSession) superuser).getPrincipalManager(); everyone = (GroupPrincipal) principalMgr.getEveryone(); adminPrincipals = getPrincipals(getHelper().getSuperuserCredentials()); }
public void testEveryoneExists() throws RepositoryException { Principal everyone = principalManager.getEveryone(); assertNotNull(everyone); assertTrue(everyone instanceof GroupPrincipal); Authorizable everyoneAuthorizable = ((JackrabbitSession) superuser).getUserManager().getAuthorizable(everyone); assertNull(everyoneAuthorizable); }
public void testEveryoneIsMemberofEveryone() throws RepositoryException { GroupPrincipal everyone = (GroupPrincipal) principalManager.getEveryone(); PrincipalIterator it = principalManager.getPrincipals(PrincipalManager.SEARCH_TYPE_ALL); // EXERCISE: discuss the dynamic nature of the everyone group principal while (it.hasNext()) { Principal principal = it.nextPrincipal(); if (everyone.equals(principal)) { assertFalse(everyone.isMember(principal)); } else { assertTrue(everyone.isMember(principal)); } } }
public void testSetEntryForGroupPrincipal() throws RepositoryException, NotExecutableException { JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath()); Privilege[] privs = privilegesFromName(Privilege.JCR_READ); GroupPrincipal grPrincipal = (GroupPrincipal) principalMgr.getEveryone(); // adding allow-entry must succeed assertTrue(pt.addAccessControlEntry(grPrincipal, privs)); // adding deny-entry must succeed pt.addEntry(grPrincipal, privs, false, null); }
@Test public void testGetEveryone() { Principal principal = principalMgr.getEveryone(); assertTrue(principal != null); assertTrue(isGroup(principal)); assertEquals(EveryonePrincipal.getInstance(), principal); assertFalse(principal instanceof ItemBasedPrincipal); }
@Test public void testSetEntryForGroupPrincipal() throws Exception { Privilege[] privs = privilegesFromNames(JCR_READ); Principal grPrincipal = principalManager.getEveryone(); // adding allow-entry must succeed assertTrue(acl.addAccessControlEntry(grPrincipal, privs)); // adding deny-entry must succeed assertTrue(acl.addEntry(grPrincipal, privs, false)); assertEquals(1, acl.size()); assertFalse(acl.getEntries().get(0).isAllow()); }
@Test public void testNewEntriesAppendedAtEnd() throws Exception { Privilege[] readPriv = privilegesFromNames(JCR_READ); Privilege[] writePriv = privilegesFromNames(JCR_WRITE); acl.addEntry(testPrincipal, readPriv, true); acl.addEntry(principalManager.getEveryone(), readPriv, true); acl.addEntry(testPrincipal, writePriv, false); AccessControlEntry[] entries = acl.getAccessControlEntries(); assertEquals(3, entries.length); JackrabbitAccessControlEntry last = (JackrabbitAccessControlEntry) entries[2]; assertEquals(testPrincipal, last.getPrincipal()); assertACE(last, false, writePriv); }
@Test public void testMultiplePrincipals() throws Exception { Principal everyone = principalManager.getEveryone(); Privilege[] privs = privilegesFromNames(JCR_READ); acl.addAccessControlEntry(testPrincipal, privs); assertFalse(acl.addAccessControlEntry(testPrincipal, privs)); // add same privileges for another principal -> must modify as well. assertTrue(acl.addAccessControlEntry(everyone, privs)); // .. 2 entries must be present. assertTrue(acl.getAccessControlEntries().length == 2); assertEquals(everyone, acl.getAccessControlEntries()[1].getPrincipal()); }
@Test public void testUpdateGroupEntry() throws Exception { Privilege[] readPriv = privilegesFromNames(JCR_READ); Privilege[] writePriv = privilegesFromNames(JCR_WRITE); Principal everyone = principalManager.getEveryone(); acl.addEntry(testPrincipal, readPriv, true); acl.addEntry(everyone, readPriv, true); acl.addEntry(testPrincipal, writePriv, false); // adding an entry that should update the existing allow-entry for everyone. acl.addEntry(everyone, writePriv, true); AccessControlEntry[] entries = acl.getAccessControlEntries(); assertEquals(3, entries.length); JackrabbitAccessControlEntry princ2AllowEntry = (JackrabbitAccessControlEntry) entries[1]; assertEquals(everyone, princ2AllowEntry.getPrincipal()); assertACE(princ2AllowEntry, true, privilegesFromNames(JCR_READ, JCR_WRITE)); }