Search in sources :

Example 31 with ZimbraSoapContext

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

the class GetIdentities 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");
    }
    Element response = zsc.createElement(AccountConstants.GET_IDENTITIES_RESPONSE);
    Provisioning prov = Provisioning.getInstance();
    for (Identity ident : prov.getAllIdentities(account)) {
        ToXML.encodeIdentity(response, ident);
    }
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) Identity(com.zimbra.cs.account.Identity) Provisioning(com.zimbra.cs.account.Provisioning)

Example 32 with ZimbraSoapContext

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

the class GetOAuthConsumers method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(zsc);
    GetOAuthConsumersResponse response = new GetOAuthConsumersResponse();
    encodeResponse(account, response);
    return zsc.jaxbToElement(response);
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) GetOAuthConsumersResponse(com.zimbra.soap.account.message.GetOAuthConsumersResponse)

Example 33 with ZimbraSoapContext

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

the class SearchGal method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(getZimbraSoapContext(context));
    if (!canAccessAccount(zsc, account))
        throw ServiceException.PERM_DENIED("can not access account");
    return searchGal(zsc, account, request);
}
Also used : Account(com.zimbra.cs.account.Account) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext)

Example 34 with ZimbraSoapContext

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

the class SyncGal method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    disableJettyTimeout(context);
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Account account = getRequestedAccount(getZimbraSoapContext(context));
    if (!canAccessAccount(zsc, account))
        throw ServiceException.PERM_DENIED("can not access account");
    String tokenAttr = request.getAttribute(MailConstants.A_TOKEN, "");
    String galAcctId = request.getAttribute(AccountConstants.A_GAL_ACCOUNT_ID, null);
    boolean idOnly = request.getAttributeBool(AccountConstants.A_ID_ONLY, false);
    boolean getCount = request.getAttributeBool(AccountConstants.A_GET_COUNT, false);
    int limit = request.getAttributeInt(MailConstants.A_LIMIT, 0);
    GalSearchParams params = new GalSearchParams(account, zsc);
    params.setType(GalSearchType.all);
    ZimbraLog.gal.debug("SyncGalRequest token: %s  limit: %d", tokenAttr, limit);
    params.setToken(tokenAttr);
    params.setRequest(request);
    params.setResponseName(AccountConstants.SYNC_GAL_RESPONSE);
    params.setIdOnly(idOnly);
    params.setGetCount(getCount);
    params.setUserAgent(zsc.getUserAgent());
    params.setLimit(limit);
    if (galAcctId != null)
        params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
    params.setResultCallback(new SyncGalCallback(params));
    GalSearchControl gal = new GalSearchControl(params);
    gal.sync();
    return params.getResultCallback().getResponse();
}
Also used : Account(com.zimbra.cs.account.Account) GalSearchControl(com.zimbra.cs.gal.GalSearchControl) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) GalSearchParams(com.zimbra.cs.gal.GalSearchParams)

Example 35 with ZimbraSoapContext

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

the class AddAccountAlias method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Provisioning prov = Provisioning.getInstance();
    AddAccountAliasRequest req = zsc.elementToJaxb(request);
    String id = req.getId();
    String alias = req.getAlias();
    Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
    defendAgainstAccountOrCalendarResourceHarvesting(account, AccountBy.id, id, zsc, Admin.R_addAccountAlias, Admin.R_addCalendarResourceAlias);
    // if the admin can create an alias in the domain
    checkDomainRightByEmail(zsc, alias, Admin.R_createAlias);
    prov.addAlias(account, alias);
    ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "AddAccountAlias", "name", account.getName(), "alias", alias }));
    return zsc.jaxbToElement(new AddAccountAliasResponse());
}
Also used : Account(com.zimbra.cs.account.Account) AddAccountAliasRequest(com.zimbra.soap.admin.message.AddAccountAliasRequest) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) AddAccountAliasResponse(com.zimbra.soap.admin.message.AddAccountAliasResponse) 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