Search in sources :

Example 26 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class CreateDistributionList method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Account acct = getAuthenticatedAccount(zsc);
    String name = request.getAttribute(AccountConstants.E_NAME).toLowerCase();
    if (!AccessManager.getInstance().canCreateGroup(acct, name)) {
        throw ServiceException.PERM_DENIED("you do not have sufficient rights to create distribution list");
    }
    Map<String, Object> attrs = AccountService.getKeyValuePairs(request, AccountConstants.E_A, AccountConstants.A_N);
    boolean dynamic = request.getAttributeBool(AccountConstants.A_DYNAMIC, true);
    // creator of the group will automatically become the first owner of the group
    Account creator = getAuthenticatedAccount(zsc);
    Group group = prov.createDelegatedGroup(name, attrs, dynamic, creator);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CreateDistributionList", "name", name }, attrs));
    Element response = zsc.createElement(AccountConstants.CREATE_DISTRIBUTION_LIST_RESPONSE);
    Element eDL = response.addElement(AccountConstants.E_DL);
    eDL.addAttribute(AccountConstants.A_NAME, group.getName());
    if (group.isDynamic()) {
        eDL.addAttribute(AccountConstants.A_REF, ((LdapDynamicGroup) group).getDN());
    } else {
        eDL.addAttribute(AccountConstants.A_REF, ((LdapDistributionList) group).getDN());
    }
    eDL.addAttribute(AccountConstants.A_ID, group.getId());
    GetDistributionList.encodeAttrs(group, eDL, null);
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) LdapDynamicGroup(com.zimbra.cs.account.ldap.entry.LdapDynamicGroup) Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 27 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class DistributionListAction method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Account acct = getAuthenticatedAccount(zsc);
    Group group = getGroupBasic(request, prov);
    DistributionListActionHandler handler = new DistributionListActionHandler(group, request, prov, acct);
    handler.handle();
    Element response = zsc.createElement(AccountConstants.DISTRIBUTION_LIST_ACTION_RESPONSE);
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Example 28 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class RevokeOAuthConsumer method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    account = getRequestedAccount(zsc);
    RevokeOAuthConsumerRequest revokeRequest = zsc.elementToJaxb(request);
    accessTokenToBeRemoved = revokeRequest.getAccessToken();
    removeOAuthAccessor();
    removeAccessTokenFromForeignPrincipal();
    // Remove from cache
    OAuthTokenCache.remove(accessTokenToBeRemoved, OAuthTokenCache.ACCESS_TOKEN_TYPE);
    RevokeOAuthConsumerResponse response = new RevokeOAuthConsumerResponse();
    return zsc.jaxbToElement(response);
}
Also used : ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) RevokeOAuthConsumerRequest(com.zimbra.soap.account.message.RevokeOAuthConsumerRequest) RevokeOAuthConsumerResponse(com.zimbra.soap.account.message.RevokeOAuthConsumerResponse)

Example 29 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetAvailableLocales method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    if (!canAccessAccount(zsc, account)) {
        throw ServiceException.PERM_DENIED("can not access account");
    }
    Locale displayLocale = getDisplayLocale(account, context);
    // get installed locales, sorted
    Locale[] installedLocales = WebClientL10nUtil.getLocales(displayLocale);
    // get avail locales for this account/COS
    Set<String> allowedLocales = account.getMultiAttrSet(Provisioning.A_zimbraAvailableLocale);
    Locale[] availLocales = null;
    if (allowedLocales.size() > 0) {
        availLocales = computeAvailLocales(installedLocales, allowedLocales);
    } else {
        availLocales = installedLocales;
    }
    Element response = zsc.createElement(AccountConstants.GET_AVAILABLE_LOCALES_RESPONSE);
    for (Locale locale : availLocales) {
        if (locale != null) {
            ToXML.encodeLocale(response, locale, displayLocale);
        } else {
            break;
        }
    }
    return response;
}
Also used : Locale(java.util.Locale) Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element)

Example 30 with ZimbraSoapContext

use of com.zimbra.soap.ZimbraSoapContext in project zm-mailbox by Zimbra.

the class GetDistributionList method handle.

public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    Account acct = getAuthenticatedAccount(zsc);
    Element response = zsc.createElement(AccountConstants.GET_DISTRIBUTION_LIST_RESPONSE);
    Group group = getGroupBasic(request, prov);
    GetDistributionListHandler handler = new GetDistributionListHandler(group, request, response, prov, acct);
    handler.handle();
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) Group(com.zimbra.cs.account.Group) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)410 Element (com.zimbra.common.soap.Element)322 Account (com.zimbra.cs.account.Account)175 Provisioning (com.zimbra.cs.account.Provisioning)164 Mailbox (com.zimbra.cs.mailbox.Mailbox)126 OperationContext (com.zimbra.cs.mailbox.OperationContext)95 ItemId (com.zimbra.cs.service.util.ItemId)60 Server (com.zimbra.cs.account.Server)48 ServiceException (com.zimbra.common.service.ServiceException)43 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)43 HashMap (java.util.HashMap)42 Domain (com.zimbra.cs.account.Domain)34 ArrayList (java.util.ArrayList)27 HashSet (java.util.HashSet)26 IOException (java.io.IOException)24 Test (org.junit.Test)20 Message (com.zimbra.cs.mailbox.Message)18 Group (com.zimbra.cs.account.Group)17 CalendarItem (com.zimbra.cs.mailbox.CalendarItem)17 MimeMessage (javax.mail.internet.MimeMessage)16