Search in sources :

Example 1 with RightModifierInfo

use of com.zimbra.soap.admin.type.RightModifierInfo in project zm-mailbox by Zimbra.

the class TestServerEnumeration method grantRightToAdmin.

private static void grantRightToAdmin(SoapProvisioning adminSoapProv, TargetType targetType, String targetName, String granteeName, String rightName) throws ServiceException {
    GranteeSelector grantee = new GranteeSelector(GranteeType.usr, GranteeBy.name, granteeName);
    EffectiveRightsTargetSelector target = null;
    if (targetName == null) {
        target = new EffectiveRightsTargetSelector(targetType, null, null);
    } else {
        target = new EffectiveRightsTargetSelector(targetType, TargetBy.name, targetName);
    }
    RightModifierInfo right = new RightModifierInfo(rightName);
    GrantRightResponse grResp = adminSoapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
    assertNotNull("GrantRightResponse for " + right.getValue(), grResp);
}
Also used : RightModifierInfo(com.zimbra.soap.admin.type.RightModifierInfo) GrantRightRequest(com.zimbra.soap.admin.message.GrantRightRequest) GranteeSelector(com.zimbra.soap.admin.type.GranteeSelector) GrantRightResponse(com.zimbra.soap.admin.message.GrantRightResponse) EffectiveRightsTargetSelector(com.zimbra.soap.admin.type.EffectiveRightsTargetSelector)

Example 2 with RightModifierInfo

use of com.zimbra.soap.admin.type.RightModifierInfo in project zm-mailbox by Zimbra.

the class TestDomainAdmin method grantRight.

private void grantRight(SoapProvisioning soapProv, TargetType targetType, String targetName, GranteeType granteeType, String granteeName, String rightName) throws ServiceException {
    GranteeSelector grantee;
    EffectiveRightsTargetSelector target;
    RightModifierInfo right;
    GrantRightResponse grResp;
    grantee = new GranteeSelector(granteeType, GranteeBy.name, granteeName);
    target = new EffectiveRightsTargetSelector(targetType, TargetBy.name, targetName);
    right = new RightModifierInfo(rightName);
    grResp = soapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
    assertNotNull("GrantRightResponse for " + right.getValue(), grResp);
}
Also used : RightModifierInfo(com.zimbra.soap.admin.type.RightModifierInfo) GrantRightRequest(com.zimbra.soap.admin.message.GrantRightRequest) GranteeSelector(com.zimbra.soap.admin.type.GranteeSelector) GrantRightResponse(com.zimbra.soap.admin.message.GrantRightResponse) EffectiveRightsTargetSelector(com.zimbra.soap.admin.type.EffectiveRightsTargetSelector)

Example 3 with RightModifierInfo

use of com.zimbra.soap.admin.type.RightModifierInfo in project zm-mailbox by Zimbra.

the class TestDomainAdmin method failToGrantRight.

private void failToGrantRight(SoapProvisioning soapProv, TargetType targetType, String targetName, String granteeName, String rightName, String expectedFailureReason) throws ServiceException {
    GranteeSelector grantee;
    EffectiveRightsTargetSelector target;
    RightModifierInfo right;
    grantee = new GranteeSelector(GranteeType.usr, GranteeBy.name, granteeName);
    target = new EffectiveRightsTargetSelector(targetType, TargetBy.name, targetName);
    right = new RightModifierInfo(rightName);
    try {
        soapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
        fail(String.format("granting %s right succeeded when it shouldn't have", rightName));
    } catch (SoapFaultException sfe) {
        checkSoapReason(sfe, expectedFailureReason);
    }
}
Also used : RightModifierInfo(com.zimbra.soap.admin.type.RightModifierInfo) GrantRightRequest(com.zimbra.soap.admin.message.GrantRightRequest) GranteeSelector(com.zimbra.soap.admin.type.GranteeSelector) EffectiveRightsTargetSelector(com.zimbra.soap.admin.type.EffectiveRightsTargetSelector) SoapFaultException(com.zimbra.common.soap.SoapFaultException)

Example 4 with RightModifierInfo

use of com.zimbra.soap.admin.type.RightModifierInfo in project zm-mailbox by Zimbra.

the class GrantRight method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    GrantRightRequest grReq = JaxbUtil.elementToJaxb(request);
    RightModifierInfo modifierInfo = grReq.getRight();
    if (modifierInfo == null) {
        throw ServiceException.INVALID_REQUEST("No information specified on what right to assign", null);
    }
    RightModifier rightModifier = getRightModifier(modifierInfo);
    // right checking is done in RightCommand
    EffectiveRightsTargetSelector erTargSel = grReq.getTarget();
    RightCommand.grantRight(Provisioning.getInstance(), getAuthenticatedAccount(zsc), erTargSel, grReq.getGrantee(), modifierInfo.getValue(), rightModifier);
    // Bug 100965 Avoid Cross server delegate admin being broken after initial creation due to stale caches
    if (com.zimbra.soap.type.TargetType.domain == erTargSel.getType()) {
        TargetBy by = erTargSel.getBy();
        if ((TargetBy.id == by) || (TargetBy.name == by)) {
            CacheSelector cacheSel = new CacheSelector(true, /* allServers */
            CacheEntryType.domain.toString());
            CacheEntrySelector ceSel = new CacheEntrySelector((TargetBy.id == erTargSel.getBy()) ? CacheEntryBy.id : CacheEntryBy.name, erTargSel.getValue());
            cacheSel.addEntry(ceSel);
            FlushCacheRequest fcReq = new FlushCacheRequest(cacheSel);
            try {
                FlushCache.doFlushCache(this, context, fcReq);
            } catch (ServiceException se) {
                ZimbraLog.acl.info("Problem flushing acl cache for domain %s/%s after granting rights", erTargSel.getBy(), erTargSel.getValue(), se);
            }
        }
    }
    Element response = zsc.createElement(AdminConstants.GRANT_RIGHT_RESPONSE);
    return response;
}
Also used : CacheSelector(com.zimbra.soap.admin.type.CacheSelector) RightModifierInfo(com.zimbra.soap.admin.type.RightModifierInfo) GrantRightRequest(com.zimbra.soap.admin.message.GrantRightRequest) CacheEntrySelector(com.zimbra.soap.admin.type.CacheEntrySelector) ServiceException(com.zimbra.common.service.ServiceException) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) RightModifier(com.zimbra.cs.account.accesscontrol.RightModifier) FlushCacheRequest(com.zimbra.soap.admin.message.FlushCacheRequest) TargetBy(com.zimbra.soap.type.TargetBy) EffectiveRightsTargetSelector(com.zimbra.soap.admin.type.EffectiveRightsTargetSelector)

Example 5 with RightModifierInfo

use of com.zimbra.soap.admin.type.RightModifierInfo in project zm-mailbox by Zimbra.

the class TestLockoutMailbox method grantRightToAdmin.

private static void grantRightToAdmin(SoapProvisioning adminSoapProv, TargetType targetType, String targetName, String granteeName, String rightName) throws ServiceException {
    GranteeSelector grantee = new GranteeSelector(GranteeType.usr, GranteeBy.name, granteeName);
    EffectiveRightsTargetSelector target = null;
    if (targetName == null) {
        target = new EffectiveRightsTargetSelector(targetType, null, null);
    } else {
        target = new EffectiveRightsTargetSelector(targetType, TargetBy.name, targetName);
    }
    RightModifierInfo right = new RightModifierInfo(rightName);
    GrantRightResponse grResp = adminSoapProv.invokeJaxb(new GrantRightRequest(target, grantee, right));
    assertNotNull("GrantRightResponse for " + right.getValue(), grResp);
}
Also used : RightModifierInfo(com.zimbra.soap.admin.type.RightModifierInfo) GrantRightRequest(com.zimbra.soap.admin.message.GrantRightRequest) GranteeSelector(com.zimbra.soap.admin.type.GranteeSelector) GrantRightResponse(com.zimbra.soap.admin.message.GrantRightResponse) EffectiveRightsTargetSelector(com.zimbra.soap.admin.type.EffectiveRightsTargetSelector)

Aggregations

GrantRightRequest (com.zimbra.soap.admin.message.GrantRightRequest)6 EffectiveRightsTargetSelector (com.zimbra.soap.admin.type.EffectiveRightsTargetSelector)6 RightModifierInfo (com.zimbra.soap.admin.type.RightModifierInfo)6 GranteeSelector (com.zimbra.soap.admin.type.GranteeSelector)5 GrantRightResponse (com.zimbra.soap.admin.message.GrantRightResponse)4 ServiceException (com.zimbra.common.service.ServiceException)1 Element (com.zimbra.common.soap.Element)1 SoapFaultException (com.zimbra.common.soap.SoapFaultException)1 RightModifier (com.zimbra.cs.account.accesscontrol.RightModifier)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 FlushCacheRequest (com.zimbra.soap.admin.message.FlushCacheRequest)1 CacheEntrySelector (com.zimbra.soap.admin.type.CacheEntrySelector)1 CacheSelector (com.zimbra.soap.admin.type.CacheSelector)1 TargetBy (com.zimbra.soap.type.TargetBy)1