Package org.apache.james.mailbox.model

Examples of org.apache.james.mailbox.model.MailboxACL


    }

    @Test
    public void testSufficientRights() throws Exception {

        final MailboxACL acl = SimpleMailboxACL.OWNER_FULL_ACL;

        Expectations expectations = prepareRightsExpectations();
       
        expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
        expectations.will(Expectations.returnValue(messageManagerStub));
View Full Code Here


    }

   
    @Test
    public void testDelete() throws MailboxException {
        final MailboxACL acl = SimpleMailboxACL.OWNER_FULL_ACL;

        Expectations expectations = prepareRightsExpectations();
       
        expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
        expectations.will(Expectations.returnValue(messageManagerStub));
View Full Code Here

    }

   
    @Test
    public void testListRights() throws MailboxException {
        final MailboxACL acl = SimpleMailboxACL.OWNER_FULL_ACL;

        Expectations expectations = prepareRightsExpectations();
       
        expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
        expectations.will(Expectations.returnValue(messageManagerStub));
View Full Code Here

    public void testAddRights() throws Exception {
        testOp("+", EditMode.ADD);
    }
   
    private void testOp(String prefix, EditMode editMode) throws MailboxException {
        final MailboxACL acl = SimpleMailboxACL.OWNER_FULL_ACL;

        Expectations expectations = prepareRightsExpectations();
       
        expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
        expectations.will(Expectations.returnValue(messageManagerStub));
View Full Code Here

                recent(resetRecent, mailboxSession);
            }
            recent = new ArrayList<Long>();
            break;
        }
        MailboxACL resolvedAcl = getResolvedMailboxACL(mailboxSession);
        return new MailboxMetaData(recent, permanentFlags, uidValidity, uidNext, highestModSeq, messageCount, unseenCount, firstUnseen, isWriteable(mailboxSession), isModSeqPermanent(mailboxSession), resolvedAcl);
    }
View Full Code Here

     * @throws UnsupportedRightException
     * @see org.apache.james.mailbox.MessageManager#setRights(java.lang.String, org.apache.james.mailbox.model.MailboxACL.EditMode, org.apache.james.mailbox.model.MailboxACL.MailboxACLRights)
     */
    @Override
    public void setRights(MailboxACLEntryKey mailboxACLEntryKey, EditMode editMode, MailboxACLRights mailboxAclRights) throws UnsupportedRightException {
        MailboxACL acl = mailbox.getACL();
        if (acl == null) {
            acl = SimpleMailboxACL.EMPTY;
        }
        switch (editMode) {
        case ADD:
            acl = acl.union(mailboxACLEntryKey, mailboxAclRights);
            break;
        case REMOVE:
            acl = acl.except(mailboxACLEntryKey, mailboxAclRights);
            break;
        case REPLACE:
            acl = acl.replace(mailboxACLEntryKey, mailboxAclRights);
            break;
        default:
            throw new IllegalStateException("Unexpected "+ EditMode.class.getName() +"."+ editMode);
        }
        mailbox.setACL(acl);
View Full Code Here

        }, true);
       
    }
   
    public void setACL(final MailboxSession session, final MailboxACL acl) throws MailboxException {
        MailboxACL old = this.acl;
        if (old != acl && (old == null || !old.equals(acl))) {
            /* change only if different */
            saveACL(acl, session);
            this.acl = acl;
        }
       
View Full Code Here

     */
    @Override
    public MailboxACLRights[] listRights(final MailboxACLEntryKey queryKey, final GroupMembershipResolver groupMembershipResolver, final String resourceOwner, final boolean resourceOwnerIsGroup) throws UnsupportedRightException {
        MailboxACL.MailboxACLRights[] positiveNegativePair = { SimpleMailboxACL.NO_RIGHTS, SimpleMailboxACL.NO_RIGHTS };

        MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL;
        resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair);

        if (queryKey.isNegative()) {
            return toListRightsArray(positiveNegativePair[NEGATIVE_INDEX]);
        } else {
            return toListRightsArray(positiveNegativePair[POSITIVE_INDEX].except(positiveNegativePair[NEGATIVE_INDEX]));
View Full Code Here

     */
    @Override
    public MailboxACL.MailboxACLRights resolveRights(String requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException {
        MailboxACL.MailboxACLRights[] positiveNegativePair = { SimpleMailboxACL.NO_RIGHTS, SimpleMailboxACL.NO_RIGHTS };
        final MailboxACLEntryKey queryKey = requestUser == null ? null : new SimpleMailboxACLEntryKey(requestUser, NameType.user, false);
        MailboxACL userACL = resourceOwnerIsGroup ? groupGlobalACL : userGlobalACL;
        resolveRights(queryKey, groupMembershipResolver, userACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair);

        if (resourceACL != null) {
            resolveRights(queryKey, groupMembershipResolver, resourceACL.getEntries(), resourceOwner, resourceOwnerIsGroup, positiveNegativePair);
        }

View Full Code Here

        user1Key = SimpleMailboxACLEntryKey.createUser(USER_1);
        user2Key = SimpleMailboxACLEntryKey.createUser(USER_2);
        group1Key = SimpleMailboxACLEntryKey.createGroup(GROUP_1);
        group2Key = SimpleMailboxACLEntryKey.createGroup(GROUP_2);
       
        MailboxACL acl = new SimpleMailboxACL(new SimpleMailboxACL.SimpleMailboxACLEntry[] { new SimpleMailboxACL.SimpleMailboxACLEntry(SimpleMailboxACL.AUTHENTICATED_KEY, SimpleMailboxACL.FULL_RIGHTS) });
        authenticatedReadListWriteGlobal = new UnionMailboxACLResolver(acl, acl);
        acl = new SimpleMailboxACL(new SimpleMailboxACL.SimpleMailboxACLEntry[] { new SimpleMailboxACL.SimpleMailboxACLEntry(SimpleMailboxACL.ANYBODY_KEY, new Rfc4314Rights("rl")) });
        anyoneReadListGlobal = new UnionMailboxACLResolver(acl, acl);
        acl = new SimpleMailboxACL(new SimpleMailboxACL.SimpleMailboxACLEntry[] { new SimpleMailboxACL.SimpleMailboxACLEntry(SimpleMailboxACL.OWNER_KEY, SimpleMailboxACL.FULL_RIGHTS) });
        ownerFullGlobal = new UnionMailboxACLResolver(acl, acl);
View Full Code Here

TOP

Related Classes of org.apache.james.mailbox.model.MailboxACL

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.