Search in sources :

Example 1 with TargetType

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

the class ProvUtil method getRightArgsTarget.

private void getRightArgsTarget(RightArgs ra) throws ServiceException, ArgException {
    if (ra.mCurPos >= ra.mArgs.length) {
        throw new ArgException("not enough arguments");
    }
    ra.mTargetType = ra.mArgs[ra.mCurPos++];
    TargetType tt = TargetType.fromCode(ra.mTargetType);
    if (tt.needsTargetIdentity()) {
        if (ra.mCurPos >= ra.mArgs.length) {
            throw new ArgException("not enough arguments");
        }
        ra.mTargetIdOrName = ra.mArgs[ra.mCurPos++];
    } else {
        ra.mTargetIdOrName = null;
    }
}
Also used : TargetType(com.zimbra.cs.account.accesscontrol.TargetType)

Example 2 with TargetType

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

the class ProvUtil method doGetAllEffectiveRights.

private void doGetAllEffectiveRights(String[] args) throws ServiceException, ArgException {
    RightArgs ra = new RightArgs(args);
    if (prov instanceof LdapProv) {
        // must provide grantee info
        getRightArgsGrantee(ra, true, false);
    } else {
        // has more args, use it for the requested grantee
        if (ra.mCurPos < args.length) {
            getRightArgsGrantee(ra, true, false);
        }
    }
    boolean expandSetAttrs = false;
    boolean expandGetAttrs = false;
    // if there are more args, see if they are expandSetAttrs/expandGetAttrs
    for (int i = ra.mCurPos; i < args.length; i++) {
        if ("expandSetAttrs".equals(args[i])) {
            expandSetAttrs = true;
        } else if ("expandGetAttrs".equals(args[i])) {
            expandGetAttrs = true;
        } else {
            throw new ArgException("unrecognized arg: " + args[i]);
        }
    }
    GranteeBy granteeBy = (ra.mGranteeIdOrName == null) ? null : guessGranteeBy(ra.mGranteeIdOrName);
    RightCommand.AllEffectiveRights allEffRights = prov.getAllEffectiveRights(ra.mGranteeType, granteeBy, ra.mGranteeIdOrName, expandSetAttrs, expandGetAttrs);
    console.println(allEffRights.granteeType() + " " + allEffRights.granteeName() + "(" + allEffRights.granteeId() + ")" + " has the following rights:");
    for (Map.Entry<TargetType, RightCommand.RightsByTargetType> rightsByTargetType : allEffRights.rightsByTargetType().entrySet()) {
        RightCommand.RightsByTargetType rbtt = rightsByTargetType.getValue();
        if (!rbtt.hasNoRight()) {
            dumpRightsByTargetType(rightsByTargetType.getKey(), rbtt, expandSetAttrs, expandGetAttrs);
        }
    }
}
Also used : LdapProv(com.zimbra.cs.account.ldap.LdapProv) GranteeBy(com.zimbra.soap.admin.type.GranteeSelector.GranteeBy) TargetType(com.zimbra.cs.account.accesscontrol.TargetType) RightCommand(com.zimbra.cs.account.accesscontrol.RightCommand) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap)

Example 3 with TargetType

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

the class TestACLEffectiveRights method getEffectiveRights.

@Test
public void getEffectiveRights() throws Exception {
    Domain domain = provUtil.createDomain(genDomainSegmentName() + "." + BASE_DOMAIN_NAME);
    Account target = provUtil.createAccount(genAcctNameLocalPart("user"), domain);
    Account grantee = provUtil.createDelegatedAdmin(genAcctNameLocalPart("da"), domain);
    Account grantingAccount = globalAdmin;
    TargetType targetType = TargetType.getTargetType(target);
    GranteeType granteeType = GranteeType.GT_USER;
    Right right = ADMIN_PRESET_ACCOUNT;
    RightCommand.grantRight(prov, grantingAccount, targetType.getCode(), TargetBy.name, target.getName(), granteeType.getCode(), GranteeBy.name, grantee.getName(), null, right.getName(), null);
    EffectiveRights effRights = RightCommand.getEffectiveRights(prov, TargetType.account.getCode(), TargetBy.name, target.getName(), GranteeBy.name, grantee.getName(), false, false);
    assertTrue(effRights.presetRights().contains(right.getName()));
}
Also used : Account(com.zimbra.cs.account.Account) GranteeType(com.zimbra.cs.account.accesscontrol.GranteeType) EffectiveRights(com.zimbra.cs.account.accesscontrol.RightCommand.EffectiveRights) AllEffectiveRights(com.zimbra.cs.account.accesscontrol.RightCommand.AllEffectiveRights) RightsByTargetType(com.zimbra.cs.account.accesscontrol.RightCommand.RightsByTargetType) TargetType(com.zimbra.cs.account.accesscontrol.TargetType) InlineAttrRight(com.zimbra.cs.account.accesscontrol.InlineAttrRight) Right(com.zimbra.cs.account.accesscontrol.Right) Domain(com.zimbra.cs.account.Domain) Test(org.junit.Test)

Example 4 with TargetType

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

the class TestACLAll method testAll.

/*
     * full test
     */
private void testAll() throws Exception {
    SKIP_FOR_REAL_LDAP_SERVER(SkipTestReason.LONG_TEST);
    int totalTests = TargetType.values().length * TestGranteeType.TEST_GRANTEE_TYPES.size() * rights.size();
    int curTest = 1;
    for (TargetType targetType : TargetType.values()) {
        for (TestGranteeType granteeType : TestGranteeType.TEST_GRANTEE_TYPES) {
            boolean skip = EXCLUDE_GRANTEE_TYPES.contains(granteeType.getCode());
            for (Right right : rights) {
                doTest((curTest++) + "/" + totalTests, targetType, granteeType, right, skip);
            }
        }
    }
}
Also used : TargetType(com.zimbra.cs.account.accesscontrol.TargetType) RightsByTargetType(com.zimbra.cs.account.accesscontrol.RightCommand.RightsByTargetType) DomainedRightsByTargetType(com.zimbra.cs.account.accesscontrol.RightCommand.DomainedRightsByTargetType) ComboRight(com.zimbra.cs.account.accesscontrol.ComboRight) CheckRight(com.zimbra.cs.account.accesscontrol.CheckRight) UserRight(com.zimbra.cs.account.accesscontrol.UserRight) AttrRight(com.zimbra.cs.account.accesscontrol.AttrRight) PresetRight(com.zimbra.cs.account.accesscontrol.PresetRight) Right(com.zimbra.cs.account.accesscontrol.Right)

Example 5 with TargetType

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

the class TestACLAll method testTarget.

/*
     * test a particular target type and a range of rights for all grantee types
     */
private void testTarget() throws Exception {
    SKIP_FOR_REAL_LDAP_SERVER(SkipTestReason.LONG_TEST);
    /*
         *  account
         *  calresource
         *  cos
         *  dl
         *  group
         *  domain
         *  server
         *  ucservice
         *  xmppcomponent
         *  zimlet
         *  config
         *  global
         */
    TargetType targetType = TargetType.ucservice;
    // sRights.indexOf(ADMIN_COMBO_ACCOUNT);  // inclusive
    int beginRight = 0;
    // inclusive
    int endRight = rights.size() - 1;
    int totalTests = TestGranteeType.TEST_GRANTEE_TYPES.size() * (endRight - beginRight + 1);
    int curTest = 1;
    for (TestGranteeType granteeType : TestGranteeType.TEST_GRANTEE_TYPES) {
        boolean skip = EXCLUDE_GRANTEE_TYPES.contains(granteeType.getCode());
        // for (Right right : sRights) {
        for (int i = beginRight; i <= endRight; i++) {
            Right right = rights.get(i);
            doTest((curTest++) + "/" + totalTests, targetType, granteeType, right, skip);
        }
    }
}
Also used : TargetType(com.zimbra.cs.account.accesscontrol.TargetType) RightsByTargetType(com.zimbra.cs.account.accesscontrol.RightCommand.RightsByTargetType) DomainedRightsByTargetType(com.zimbra.cs.account.accesscontrol.RightCommand.DomainedRightsByTargetType) ComboRight(com.zimbra.cs.account.accesscontrol.ComboRight) CheckRight(com.zimbra.cs.account.accesscontrol.CheckRight) UserRight(com.zimbra.cs.account.accesscontrol.UserRight) AttrRight(com.zimbra.cs.account.accesscontrol.AttrRight) PresetRight(com.zimbra.cs.account.accesscontrol.PresetRight) Right(com.zimbra.cs.account.accesscontrol.Right)

Aggregations

TargetType (com.zimbra.cs.account.accesscontrol.TargetType)23 RightsByTargetType (com.zimbra.cs.account.accesscontrol.RightCommand.RightsByTargetType)13 DomainedRightsByTargetType (com.zimbra.cs.account.accesscontrol.RightCommand.DomainedRightsByTargetType)11 Right (com.zimbra.cs.account.accesscontrol.Right)7 UserRight (com.zimbra.cs.account.accesscontrol.UserRight)7 Element (com.zimbra.common.soap.Element)6 Account (com.zimbra.cs.account.Account)4 Entry (com.zimbra.cs.account.Entry)4 NamedEntry (com.zimbra.cs.account.NamedEntry)4 Provisioning (com.zimbra.cs.account.Provisioning)4 AttrRight (com.zimbra.cs.account.accesscontrol.AttrRight)4 CheckRight (com.zimbra.cs.account.accesscontrol.CheckRight)4 ComboRight (com.zimbra.cs.account.accesscontrol.ComboRight)4 PresetRight (com.zimbra.cs.account.accesscontrol.PresetRight)4 RightCommand (com.zimbra.cs.account.accesscontrol.RightCommand)4 AllEffectiveRights (com.zimbra.cs.account.accesscontrol.RightCommand.AllEffectiveRights)4 EffectiveRights (com.zimbra.cs.account.accesscontrol.RightCommand.EffectiveRights)4 Map (java.util.Map)4 AccessManager (com.zimbra.cs.account.AccessManager)3 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)3