Search in sources :

Example 16 with AccountBy

use of com.zimbra.common.account.Key.AccountBy in project zm-mailbox by Zimbra.

the class LockoutMailbox method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = super.getZimbraSoapContext(context);
    LockoutMailboxRequest req = zsc.elementToJaxb(request);
    AccountNameSelector acctSel = req.getAccount();
    if (acctSel == null) {
        throw ServiceException.INVALID_REQUEST(String.format("missing <%s>", AdminConstants.E_ACCOUNT), null);
    }
    String accountSelectorKey = acctSel.getKey();
    AccountBy by = acctSel.getBy().toKeyAccountBy();
    Provisioning prov = Provisioning.getInstance();
    Account account = prov.get(by, accountSelectorKey, zsc.getAuthToken());
    defendAgainstAccountOrCalendarResourceHarvesting(account, by, accountSelectorKey, zsc, Admin.R_moveAccountMailbox, Admin.R_moveCalendarResourceMailbox);
    // Reload account to pick up any changes made by other servers.
    prov.reload(account);
    // check rights
    checkRights(zsc, context, account);
    String method = request.getAttribute(AdminConstants.A_OPERATION, AdminConstants.A_START);
    if (method.equalsIgnoreCase(AdminConstants.A_START)) {
        MailboxManager.getInstance().lockoutMailbox(account.getId());
    } else if (method.equalsIgnoreCase(AdminConstants.A_END)) {
        MailboxManager.getInstance().undoLockout(account.getId());
    } else {
        throw ServiceException.FAILURE("Unknown lockout method " + method, null);
    }
    return zsc.createElement(AdminConstants.LOCKOUT_MAILBOX_RESPONSE);
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AccountNameSelector(com.zimbra.soap.type.AccountNameSelector) Provisioning(com.zimbra.cs.account.Provisioning) LockoutMailboxRequest(com.zimbra.soap.admin.message.LockoutMailboxRequest) AccountBy(com.zimbra.common.account.Key.AccountBy)

Aggregations

AccountBy (com.zimbra.common.account.Key.AccountBy)16 Account (com.zimbra.cs.account.Account)13 Provisioning (com.zimbra.cs.account.Provisioning)13 Element (com.zimbra.common.soap.Element)10 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)10 ServiceException (com.zimbra.common.service.ServiceException)5 Domain (com.zimbra.cs.account.Domain)4 HashMap (java.util.HashMap)4 AccountServiceException (com.zimbra.cs.account.AccountServiceException)3 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)3 AuthToken (com.zimbra.cs.account.AuthToken)3 AuthTokenException (com.zimbra.cs.account.AuthTokenException)3 AccountSelector (com.zimbra.soap.type.AccountSelector)3 Key (com.zimbra.common.account.Key)2 Server (com.zimbra.cs.account.Server)2 TwoFactorAuth (com.zimbra.cs.account.auth.twofactor.TwoFactorAuth)2 EmailAddress (com.zimbra.cs.account.names.NameUtil.EmailAddress)2 ZMailbox (com.zimbra.client.ZMailbox)1 DistributionListBy (com.zimbra.common.account.Key.DistributionListBy)1 XMLElement (com.zimbra.common.soap.Element.XMLElement)1