Search in sources :

Example 11 with ZimbraACE

use of com.zimbra.cs.account.accesscontrol.ZimbraACE in project zm-mailbox by Zimbra.

the class TestACLAttrRight method grantRight.

/*
     * TODO: following methods (grantRight and verify) copied from legacy
     *       com.zimbra.qa.unittest.TestACL.
     *       Move to ACLTestUtil if used in other classes as we continue to renovate ACL
     *       unit tests.
     *
     *
     * utility methods to grant/revoke right
     *
     * To simulate how grants are done in the real server/zmprov, we first call TargetType.lookupTarget to
     * "look for" the taret, then use the returned entry instead of giving the target entry passed in
     * directly to RightUtil.
     *
     * This is for testing user rights, which goes to RightUtil directly (i.e. not through RightCommand)
     *
     */
private List<ZimbraACE> grantRight(TargetType targetType, Entry target, Set<ZimbraACE> aces) throws ServiceException {
    /*
         * make sure all rights are user right, tests written earlier could still be using
         * this to grant
         */
    for (ZimbraACE ace : aces) {
        assertTrue(ace.getRight().isUserRight());
    }
    Entry targetEntry;
    if (target instanceof Zimlet) {
        // must be by name
        String targetName = ((Zimlet) target).getName();
        targetEntry = TargetType.lookupTarget(prov, targetType, TargetBy.name, targetName);
    } else {
        String targetId = (target instanceof NamedEntry) ? ((NamedEntry) target).getId() : null;
        targetEntry = TargetType.lookupTarget(prov, targetType, TargetBy.id, targetId);
    }
    return ACLUtil.grantRight(prov, targetEntry, aces);
}
Also used : ZimbraACE(com.zimbra.cs.account.accesscontrol.ZimbraACE) NamedEntry(com.zimbra.cs.account.NamedEntry) NamedEntry(com.zimbra.cs.account.NamedEntry) Entry(com.zimbra.cs.account.Entry) Zimlet(com.zimbra.cs.account.Zimlet)

Aggregations

ZimbraACE (com.zimbra.cs.account.accesscontrol.ZimbraACE)11 Account (com.zimbra.cs.account.Account)7 HashSet (java.util.HashSet)7 Element (com.zimbra.common.soap.Element)6 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)6 Right (com.zimbra.cs.account.accesscontrol.Right)5 NamedEntry (com.zimbra.cs.account.NamedEntry)4 ServiceException (com.zimbra.common.service.ServiceException)2 AccountServiceException (com.zimbra.cs.account.AccountServiceException)2 DistributionList (com.zimbra.cs.account.DistributionList)2 Entry (com.zimbra.cs.account.Entry)2 GuestAccount (com.zimbra.cs.account.GuestAccount)2 Zimlet (com.zimbra.cs.account.Zimlet)2 GranteeType (com.zimbra.cs.account.accesscontrol.GranteeType)2 RightModifier (com.zimbra.cs.account.accesscontrol.RightModifier)2 JavaMailInternetAddress (com.zimbra.common.mime.shim.JavaMailInternetAddress)1 Group (com.zimbra.cs.account.Group)1 MockProvisioning (com.zimbra.cs.account.MockProvisioning)1 Provisioning (com.zimbra.cs.account.Provisioning)1 CacheEntry (com.zimbra.cs.account.Provisioning.CacheEntry)1