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;
}
}
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);
}
}
}
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()));
}
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);
}
}
}
}
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);
}
}
}
Aggregations