@Test void testResolveRightsUserNotMemberOfOwnerGroup() throws UnsupportedRightException { assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, user1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, user1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, user1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, user1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, user1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, user1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, user1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, user1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, user1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, user1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, group1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, group1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, group1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, group1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, group1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, group1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, group1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, group1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, group1Read, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, group1ReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, anybodyRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, anybodyReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, anybodyReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, authenticatedRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, authenticatedReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, authenticatedReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, ownerRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( anyoneReadListGlobal.resolveRights(USER_1, groupMembershipResolver, ownerReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, ownerRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( authenticatedReadListWriteGlobal.resolveRights(USER_1, groupMembershipResolver, ownerReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isTrue(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, ownerRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( ownerFullGlobal.resolveRights(USER_1, groupMembershipResolver, ownerReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, ownerRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( noGlobals.resolveRights(USER_1, groupMembershipResolver, ownerReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, ownerRead, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); assertThat( negativeGroup2FullGlobal.resolveRights(USER_1, groupMembershipResolver, ownerReadNegative, GROUP_2, true) .contains(MailboxACL.Right.Read)) .isFalse(); }
@Override public Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException { Rfc4314Rights[] positiveNegativePair = { MailboxACL.NO_RIGHTS, MailboxACL.NO_RIGHTS }; final EntryKey queryKey = requestUser == null ? null : EntryKey.createUserEntryKey(requestUser); MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL; resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); if (resourceACL != null) { resolveRights(queryKey, groupMembershipResolver, resourceACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); } return positiveNegativePair[POSITIVE_INDEX].except(positiveNegativePair[NEGATIVE_INDEX]); }
UnionMailboxACLResolver implements MailboxACLResolver { @Override public Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException { Rfc4314Rights[] positiveNegativePair = { MailboxACL.NO_RIGHTS, MailboxACL.NO_RIGHTS }; final EntryKey queryKey = requestUser == null ? null : EntryKey.createUserEntryKey(requestUser); MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL; resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); if (resourceACL != null) { resolveRights(queryKey, groupMembershipResolver, resourceACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); } return positiveNegativePair[POSITIVE_INDEX].except(positiveNegativePair[NEGATIVE_INDEX]); } }
UnionMailboxACLResolver implements MailboxACLResolver { @Override public Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException { Rfc4314Rights[] positiveNegativePair = { MailboxACL.NO_RIGHTS, MailboxACL.NO_RIGHTS }; final EntryKey queryKey = requestUser == null ? null : EntryKey.createUserEntryKey(requestUser); MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL; resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); if (resourceACL != null) { resolveRights(queryKey, groupMembershipResolver, resourceACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); } return positiveNegativePair[POSITIVE_INDEX].except(positiveNegativePair[NEGATIVE_INDEX]); } UnionMailboxACLResolver();  UnionMailboxACLResolver(MailboxACL userGlobalACL, MailboxACL groupGlobalACL); }
UnionMailboxACLResolver implements MailboxACLResolver { @Override public Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException { Rfc4314Rights[] positiveNegativePair = { MailboxACL.NO_RIGHTS, MailboxACL.NO_RIGHTS }; final EntryKey queryKey = requestUser == null ? null : EntryKey.createUserEntryKey(requestUser); MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL; resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); if (resourceACL != null) { resolveRights(queryKey, groupMembershipResolver, resourceACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); } return positiveNegativePair[POSITIVE_INDEX].except(positiveNegativePair[NEGATIVE_INDEX]); } UnionMailboxACLResolver();  UnionMailboxACLResolver(MailboxACL userGlobalACL, MailboxACL groupGlobalACL); @Override MailboxACL applyGlobalACL(MailboxACL resourceACL, boolean resourceOwnerIsGroup); @Override List<Rfc4314Rights> listRights(EntryKey queryKey, GroupMembershipResolver groupMembershipResolver, String resourceOwner, boolean resourceOwnerIsGroup); @Override Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup); }
UnionMailboxACLResolver implements MailboxACLResolver { @Override public Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException { Rfc4314Rights[] positiveNegativePair = { MailboxACL.NO_RIGHTS, MailboxACL.NO_RIGHTS }; final EntryKey queryKey = requestUser == null ? null : EntryKey.createUserEntryKey(requestUser); MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL; resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); if (resourceACL != null) { resolveRights(queryKey, groupMembershipResolver, resourceACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair); } return positiveNegativePair[POSITIVE_INDEX].except(positiveNegativePair[NEGATIVE_INDEX]); } UnionMailboxACLResolver();  UnionMailboxACLResolver(MailboxACL userGlobalACL, MailboxACL groupGlobalACL); @Override MailboxACL applyGlobalACL(MailboxACL resourceACL, boolean resourceOwnerIsGroup); @Override List<Rfc4314Rights> listRights(EntryKey queryKey, GroupMembershipResolver groupMembershipResolver, String resourceOwner, boolean resourceOwnerIsGroup); @Override Rfc4314Rights resolveRights(Username requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup); static final MailboxACL DEFAULT_GLOBAL_GROUP_ACL; static final MailboxACL DEFAULT_GLOBAL_USER_ACL; }