public PrincipalIterator getGroupMembership(Principal principal) { if (principal instanceof EveryonePrincipal) { return PrincipalIteratorAdapter.EMPTY; } else { return new PrincipalIteratorAdapter(Collections.singletonList(EveryonePrincipal.getInstance())); } }
public PrincipalIterator getGroupMembership(Principal principal) { if (principal instanceof EveryonePrincipal) { return PrincipalIteratorAdapter.EMPTY; } else { return new PrincipalIteratorAdapter(Collections.singletonList(EveryonePrincipal.getInstance())); } }
public PrincipalIterator getPrincipals(int searchType) { PrincipalIterator it; switch (searchType) { case PrincipalManager.SEARCH_TYPE_GROUP: it = new PrincipalIteratorAdapter(Collections.singletonList(EveryonePrincipal.getInstance())); break; case PrincipalManager.SEARCH_TYPE_NOT_GROUP: Set<Principal> set = new HashSet<Principal>(principals.values()); set.remove(EveryonePrincipal.getInstance()); it = new PrincipalIteratorAdapter(set); break; case PrincipalManager.SEARCH_TYPE_ALL: it = new PrincipalIteratorAdapter(principals.values()); break; // no default default: throw new IllegalArgumentException("Unknown search type " + searchType); } return it; }
public PrincipalIterator getPrincipals(int searchType) { PrincipalIterator it; switch (searchType) { case PrincipalManager.SEARCH_TYPE_GROUP: it = new PrincipalIteratorAdapter(Collections.singletonList(EveryonePrincipal.getInstance())); break; case PrincipalManager.SEARCH_TYPE_NOT_GROUP: Set<Principal> set = new HashSet<Principal>(principals.values()); set.remove(EveryonePrincipal.getInstance()); it = new PrincipalIteratorAdapter(set); break; case PrincipalManager.SEARCH_TYPE_ALL: it = new PrincipalIteratorAdapter(principals.values()); break; // no default default: throw new IllegalArgumentException("Unknown search type " + searchType); } return it; }
private SimplePrincipalProvider() { if (adminID != null) { principals.put(adminID, new AdminPrincipal(adminID)); } if (anonymID != null) { principals.put(anonymID, new AnonymousPrincipal()); } EveryonePrincipal everyone = EveryonePrincipal.getInstance(); principals.put(everyone.getName(), everyone); }
private SimplePrincipalProvider() { if (adminID != null) { principals.put(adminID, new AdminPrincipal(adminID)); } if (anonymID != null) { principals.put(anonymID, new AnonymousPrincipal()); } EveryonePrincipal everyone = EveryonePrincipal.getInstance(); principals.put(everyone.getName(), everyone); }
/** * {@inheritDoc} */ @Override public void init( Properties options ) { adminId = options.getProperty( KEY_ADMIN_ID, SecurityConstants.ADMIN_ID ); adminPrincipal = new AdminPrincipal( adminId ); adminRole = options.getProperty( KEY_ADMIN_ROLE, SecurityConstants.ADMINISTRATORS_NAME ); adminRolePrincipal = new SpringSecurityRolePrincipal( adminRole ); anonymousId = options.getProperty( KEY_ANONYMOUS_ID, SecurityConstants.ANONYMOUS_ID ); principals.put( adminId, adminPrincipal ); principals.put( adminRole, adminRolePrincipal ); ArrayList<SpringSecurityRolePrincipal> assignedAdminRoles = new ArrayList<SpringSecurityRolePrincipal>(); assignedAdminRoles.add( adminRolePrincipal ); roleAssignments.put( adminId, assignedAdminRoles ); principals.put( anonymousId, anonymousPrincipal ); EveryonePrincipal everyone = EveryonePrincipal.getInstance(); principals.put( everyone.getName(), everyone ); }
/** * {@inheritDoc} */ public Principal getEveryone() { checkIsValid(); Principal everyone = getPrincipal(EveryonePrincipal.NAME); if (everyone == null) { everyone = EveryonePrincipal.getInstance(); } return everyone; }
/** * {@inheritDoc} */ public Principal getEveryone() { checkIsValid(); Principal everyone = getPrincipal(EveryonePrincipal.NAME); if (everyone == null) { everyone = EveryonePrincipal.getInstance(); } return everyone; }
public void testEveryonePrincipal() { Principal everyone = EveryonePrincipal.getInstance(); assertEquals(EveryonePrincipal.NAME, everyone.getName()); assertEquals(everyone, EveryonePrincipal.getInstance()); }
@Override protected void setUp() throws Exception { super.setUp(); if (!(acMgr instanceof JackrabbitAccessControlManager)) { throw new NotExecutableException(); } Principal principal = EveryonePrincipal.getInstance(); principals = Collections.singleton(principal); }
@Test public void getPrincipal_Everyone() throws Exception { Principal principal = provider.getPrincipal( EveryonePrincipal.getInstance().getName() ); assertEquals( principal, EveryonePrincipal.getInstance() ); }
public void testEveryonePrincipal2() { Principal everyone = EveryonePrincipal.getInstance(); Principal someotherEveryone = new Principal() { public String getName() { return EveryonePrincipal.NAME; } }; assertFalse(everyone.equals(someotherEveryone)); }
public void testEveryonePrincipal3() { Principal everyone = EveryonePrincipal.getInstance(); Principal someotherEveryone = new JackrabbitPrincipal() { public String getName() { return EveryonePrincipal.NAME; } @Override public boolean equals(Object o) { if (o instanceof JackrabbitPrincipal) { return getName().equals(((JackrabbitPrincipal) o).getName()); } return false; } @Override public int hashCode() { return getName().hashCode(); } }; assertEquals(someotherEveryone, everyone); assertEquals(everyone, someotherEveryone); }
public void testEveryonePrincipal4() throws NotExecutableException, RepositoryException { Principal everyone = EveryonePrincipal.getInstance(); Group everyoneGroup = null; try { everyoneGroup = getUserManager(superuser).createGroup(EveryonePrincipal.NAME); superuser.save(); assertEquals(everyoneGroup.getPrincipal(), everyone); assertEquals(everyone, everyoneGroup.getPrincipal()); } finally { if (everyoneGroup != null) { everyoneGroup.remove(); superuser.save(); } } }
public void testEveryonePrincipal() throws Exception { Principal p = principalProvider.getPrincipal(EveryonePrincipal.NAME); assertNotNull(p); assertEquals(EveryonePrincipal.getInstance(), p); PrincipalIterator pit = principalProvider.findPrincipals(EveryonePrincipal.NAME); assertNotNull(pit); if (pit.getSize() == -1) { assertTrue(pit.hasNext()); assertEquals(EveryonePrincipal.getInstance(), pit.nextPrincipal()); assertFalse(pit.hasNext()); } else { assertEquals(1, pit.getSize()); assertEquals(EveryonePrincipal.getInstance(), pit.nextPrincipal()); } }
@Override protected void tearDown() throws Exception { try { if (otherSession != null) { otherSession.logout(); } } finally { Authorizable a = userMgr.getAuthorizable(otherUID); if (a != null) { for (Iterator<Group> it = a.memberOf(); it.hasNext();) { Group gr = it.next(); if (!gr.getPrincipal().equals(EveryonePrincipal.getInstance())) { gr.removeMember(a); } } a.remove(); } a = userMgr.getAuthorizable(uID); if (a != null) { a.remove(); } save(superuser); } super.tearDown(); }
public void testUnknownUserMemberShip() throws RepositoryException { Principal userPrincipal = getTestPrincipal(); PrincipalIterator pit = principalProvider.getGroupMembership(userPrincipal); // unknown user must be in 'everyone' group but nothing else assertTrue(pit.hasNext()); assertEquals(EveryonePrincipal.getInstance(), pit.nextPrincipal()); assertFalse(pit.hasNext()); }
public void testInheritedGroupPermissions() throws NotExecutableException, RepositoryException { Group testGroup = getTestGroup(); AccessControlManager testAcMgr = getTestACManager(); /* precondition: testuser must have READ-only permission on test-node and below */ checkReadOnly(path); Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES); /* give MODIFY_PROPERTIES privilege for testGroup at 'path' */ givePrivileges(path, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path)); /* withdraw MODIFY_PROPERTIES privilege for everyone at 'childNPath' */ withdrawPrivileges(childNPath, EveryonePrincipal.getInstance(), privileges, getRestrictions(superuser, path)); // result at 'child path' must be deny assertFalse(testAcMgr.hasPrivileges(childNPath, privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES))); }
public void testInheritedGroupPermissions2() throws NotExecutableException, RepositoryException { Group testGroup = getTestGroup(); AccessControlManager testAcMgr = getTestACManager(); /* precondition: testuser must have READ-only permission on test-node and below */ checkReadOnly(path); Privilege[] privileges = privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES); // NOTE: same as testInheritedGroupPermissions above but using // everyone on path, testgroup on childpath -> result must be the same /* give MODIFY_PROPERTIES privilege for everyone at 'path' */ givePrivileges(path, EveryonePrincipal.getInstance(), privileges, getRestrictions(superuser, path)); /* withdraw MODIFY_PROPERTIES privilege for testGroup at 'childNPath' */ withdrawPrivileges(childNPath, testGroup.getPrincipal(), privileges, getRestrictions(superuser, path)); // result at 'child path' must be deny assertFalse(testAcMgr.hasPrivileges(childNPath, privilegesFromName(Privilege.JCR_MODIFY_PROPERTIES))); }