Package org.apache.james.mailbox.model.MailboxACL

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


    }
   
    @Test
    public void testNegativeAnybody() throws UnsupportedRightException {
       
        MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString());
        assertEquals(k.isNegative(), true);
        assertEquals(k.getNameType(), NameType.special);
        assertEquals(k.getName(), SpecialName.anybody.toString());
       
    }
View Full Code Here


   

    @Test
    public void testAuthenticated() throws UnsupportedRightException {
       
        MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString());
        assertEquals(k.isNegative(), false);
        assertEquals(k.getNameType(), NameType.special);
        assertEquals(k.getName(), SpecialName.authenticated.toString());
       
    }
View Full Code Here

    }
   
    @Test
    public void testNegativeAuthenticated() throws UnsupportedRightException {
       
        MailboxACLEntryKey k = new SimpleMailboxACLEntryKey(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString());
        assertEquals(k.isNegative(), true);
        assertEquals(k.getNameType(), NameType.special);
        assertEquals(k.getName(), SpecialName.authenticated.toString());
       
    }
View Full Code Here

     *      org.apache.james.mailbox.MailboxACL.MailboxACLRight,
     *      org.apache.james.mailbox.MailboxACL, java.lang.String)
     */
    @Override
    public boolean hasRight(String requestUser, GroupMembershipResolver groupMembershipResolver, MailboxACLRight right, MailboxACL resourceACL, String resourceOwner, boolean resourceOwnerIsGroup) throws UnsupportedRightException {
        final MailboxACLEntryKey queryKey = requestUser == null ? null : new SimpleMailboxACLEntryKey(requestUser, NameType.user, false);
        boolean result = false;
        Map<MailboxACLEntryKey, MailboxACLRights> entries = resourceOwnerIsGroup ? groupGlobalACL.getEntries() : userGlobalACL.getEntries();
        if (entries != null) {
            for (Iterator<Map.Entry<MailboxACLEntryKey, MailboxACLRights>> it = entries.entrySet().iterator(); it.hasNext();) {
                final Entry<MailboxACLEntryKey, MailboxACLRights> entry = it.next();
                final MailboxACLEntryKey key = entry.getKey();
                if (applies(key, queryKey, groupMembershipResolver, resourceOwner, resourceOwnerIsGroup) && entry.getValue().contains(right)) {
                    if (key.isNegative()) {
                        return false;
                    } else {
                        result = true;
                    }
                }
            }
        }

        if (resourceACL != null) {
            entries = resourceACL.getEntries();
            if (entries != null) {
                for (Iterator<Map.Entry<MailboxACLEntryKey, MailboxACLRights>> it = entries.entrySet().iterator(); it.hasNext();) {
                    final Entry<MailboxACLEntryKey, MailboxACLRights> entry = it.next();
                    final MailboxACLEntryKey key = entry.getKey();
                    if (applies(key, queryKey, groupMembershipResolver, resourceOwner, resourceOwnerIsGroup) && entry.getValue().contains(right)) {
                        if (key.isNegative()) {
                            return false;
                        } else {
                            result = true;
                        }
                    }
View Full Code Here

     *      java.lang.String)
     */
    @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

    private void resolveRights(MailboxACLEntryKey queryKey, GroupMembershipResolver groupMembershipResolver, final Map<MailboxACLEntryKey, MailboxACLRights> entries, String resourceOwner, boolean resourceOwnerIsGroup, MailboxACL.MailboxACLRights[] positiveNegativePair)
            throws UnsupportedRightException {
        if (entries != null) {
            for (Iterator<Map.Entry<MailboxACLEntryKey, MailboxACLRights>> it = entries.entrySet().iterator(); it.hasNext();) {
                final Entry<MailboxACLEntryKey, MailboxACLRights> entry = it.next();
                final MailboxACLEntryKey key = entry.getKey();
                if (applies(key, queryKey, groupMembershipResolver, resourceOwner, resourceOwnerIsGroup)) {
                    if (key.isNegative()) {
                        positiveNegativePair[NEGATIVE_INDEX] = positiveNegativePair[NEGATIVE_INDEX].union(entry.getValue());
                    } else {
                        positiveNegativePair[POSITIVE_INDEX] = positiveNegativePair[POSITIVE_INDEX].union(entry.getValue());
                    }
                }
View Full Code Here

TOP

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

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.