Search in sources :

Example 11 with AccountServiceException

use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.

the class LdapProvisioning method createAccount.

private Account createAccount(String emailAddress, String password, Map<String, Object> acctAttrs, SpecialAttrs specialAttrs, String[] additionalObjectClasses, boolean restoring, Map<String, Object> origAttrs) throws ServiceException {
    String uuid = specialAttrs.getZimbraId();
    String baseDn = specialAttrs.getLdapBaseDn();
    emailAddress = emailAddress.toLowerCase().trim();
    String[] parts = emailAddress.split("@");
    if (parts.length != 2) {
        throw ServiceException.INVALID_REQUEST("must be valid email address: " + emailAddress, null);
    }
    String localPart = parts[0];
    String domain = parts[1];
    domain = IDNUtil.toAsciiDomainName(domain);
    emailAddress = localPart + "@" + domain;
    validEmailAddress(emailAddress);
    if (restoring) {
        validate(ProvisioningValidator.CREATE_ACCOUNT, emailAddress, additionalObjectClasses, origAttrs);
        validate(ProvisioningValidator.CREATE_ACCOUNT_CHECK_DOMAIN_COS_AND_FEATURE, emailAddress, origAttrs);
    } else {
        validate(ProvisioningValidator.CREATE_ACCOUNT, emailAddress, additionalObjectClasses, acctAttrs);
        validate(ProvisioningValidator.CREATE_ACCOUNT_CHECK_DOMAIN_COS_AND_FEATURE, emailAddress, acctAttrs);
    }
    if (acctAttrs == null) {
        acctAttrs = new HashMap<String, Object>();
    }
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
    callbackContext.setCreatingEntryName(emailAddress);
    AttributeManager.getInstance().preModify(acctAttrs, null, callbackContext, true);
    Account acct = null;
    String dn = null;
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_ACCOUNT);
        Domain d = getDomainByAsciiName(domain, zlc);
        if (d == null) {
            throw AccountServiceException.NO_SUCH_DOMAIN(domain);
        }
        if (!d.isLocal()) {
            throw ServiceException.INVALID_REQUEST("domain type must be local", null);
        }
        ZMutableEntry entry = LdapClient.createMutableEntry();
        entry.mapToAttrs(acctAttrs);
        for (int i = 0; i < sInvalidAccountCreateModifyAttrs.length; i++) {
            String a = sInvalidAccountCreateModifyAttrs[i];
            if (entry.hasAttribute(a))
                throw ServiceException.INVALID_REQUEST("invalid attribute for CreateAccount: " + a, null);
        }
        Set<String> ocs;
        if (additionalObjectClasses == null) {
            // We are creating a pure account object, get all object classes for account.
            //
            // If restoring, only add zimbra default object classes, do not add extra
            // ones configured.  After createAccount, the restore code will issue a
            // modifyAttrs call and all object classes in the backed up account will be
            // in the attr map passed to modifyAttrs.
            //
            ocs = LdapObjectClass.getAccountObjectClasses(this, restoring);
        } else {
            // We are creating a "subclass" of account (e.g. calendar resource), get just the
            // zimbra default object classes for account, then add extra object classes needed
            // by the subclass.  All object classes needed by the subclass (calendar resource)
            // were figured out in the createCalendarResource method: including the zimbra
            // default (zimbracalendarResource) and any extra ones configured via
            // globalconfig.zimbraCalendarResourceExtraObjectClass.
            //
            // It doesn't matter if the additionalObjectClasses already contains object classes
            // added by the getAccountObjectClasses(this, true).  When additional object classes
            // are added to the set, duplicated once will only appear once.
            //
            //
            // The "restoring" flag is ignored in this path.
            // When restoring a calendar a resource, the restoring code:
            //     - always calls createAccount, not createCalendarResource
            //     - always pass null for additionalObjectClasses
            //     - like restoring an account, it will call modifyAttrs after the
            //       entry is created, any object classes in the backed up data
            //       will be in the attr map passed to modifyAttrs.
            ocs = LdapObjectClass.getAccountObjectClasses(this, true);
            for (int i = 0; i < additionalObjectClasses.length; i++) ocs.add(additionalObjectClasses[i]);
        }
        boolean skipCountingLicenseQuota = false;
        /* bug 48226
             *
             * Check if any of the OCs in the backup is a structural OC that subclasses
             * our default OC (defined in ZIMBRA_DEFAULT_PERSON_OC).
             * If so, add that OC now while creating the account, because it cannot be modified later.
             */
        if (restoring && origAttrs != null) {
            Object ocsInBackupObj = origAttrs.get(A_objectClass);
            String[] ocsInBackup = StringUtil.toStringArray(ocsInBackupObj);
            String mostSpecificOC = LdapObjectClassHierarchy.getMostSpecificOC(this, ocsInBackup, LdapObjectClass.ZIMBRA_DEFAULT_PERSON_OC);
            if (!LdapObjectClass.ZIMBRA_DEFAULT_PERSON_OC.equalsIgnoreCase(mostSpecificOC)) {
                ocs.add(mostSpecificOC);
            }
            //calendar resource doesn't count against license quota
            if (origAttrs.get(A_zimbraCalResType) != null) {
                skipCountingLicenseQuota = true;
            }
            if (origAttrs.get(A_zimbraIsSystemResource) != null) {
                entry.setAttr(A_zimbraIsSystemResource, "TRUE");
                skipCountingLicenseQuota = true;
            }
            if (origAttrs.get(A_zimbraIsExternalVirtualAccount) != null) {
                entry.setAttr(A_zimbraIsExternalVirtualAccount, "TRUE");
                skipCountingLicenseQuota = true;
            }
        }
        entry.addAttr(A_objectClass, ocs);
        String zimbraIdStr;
        if (uuid == null) {
            zimbraIdStr = LdapUtil.generateUUID();
        } else {
            zimbraIdStr = uuid;
        }
        entry.setAttr(A_zimbraId, zimbraIdStr);
        entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
        // default account status is active
        if (!entry.hasAttribute(Provisioning.A_zimbraAccountStatus)) {
            entry.setAttr(A_zimbraAccountStatus, Provisioning.ACCOUNT_STATUS_ACTIVE);
        }
        Cos cos = null;
        String cosId = entry.getAttrString(Provisioning.A_zimbraCOSId);
        if (cosId != null) {
            cos = lookupCos(cosId, zlc);
            if (!cos.getId().equals(cosId)) {
                cosId = cos.getId();
            }
            entry.setAttr(Provisioning.A_zimbraCOSId, cosId);
        } else {
            String domainCosId = domain != null ? isExternalVirtualAccount(entry) ? d.getDomainDefaultExternalUserCOSId() : d.getDomainDefaultCOSId() : null;
            if (domainCosId != null) {
                cos = get(Key.CosBy.id, domainCosId);
            }
            if (cos == null) {
                cos = getCosByName(isExternalVirtualAccount(entry) ? Provisioning.DEFAULT_EXTERNAL_COS_NAME : Provisioning.DEFAULT_COS_NAME, zlc);
            }
        }
        boolean hasMailTransport = entry.hasAttribute(Provisioning.A_zimbraMailTransport);
        // zimbraMailHost(and zimbraMailTransport) if it is not specified
        if (!hasMailTransport) {
            addMailHost(entry, cos, true);
        }
        // set all the mail-related attrs if zimbraMailHost or zimbraMailTransport was specified
        if (entry.hasAttribute(Provisioning.A_zimbraMailHost) || entry.hasAttribute(Provisioning.A_zimbraMailTransport)) {
            // default mail status is enabled
            if (!entry.hasAttribute(Provisioning.A_zimbraMailStatus)) {
                entry.setAttr(A_zimbraMailStatus, MAIL_STATUS_ENABLED);
            }
            // default account mail delivery address is email address
            if (!entry.hasAttribute(Provisioning.A_zimbraMailDeliveryAddress)) {
                entry.setAttr(A_zimbraMailDeliveryAddress, emailAddress);
            }
        } else {
            throw ServiceException.INVALID_REQUEST("missing " + Provisioning.A_zimbraMailHost + " or " + Provisioning.A_zimbraMailTransport + " for CreateAccount: " + emailAddress, null);
        }
        // amivisAccount requires the mail attr, so we always add it
        entry.setAttr(A_mail, emailAddress);
        // required for ZIMBRA_DEFAULT_PERSON_OC class
        if (!entry.hasAttribute(Provisioning.A_cn)) {
            String displayName = entry.getAttrString(Provisioning.A_displayName);
            if (displayName != null) {
                entry.setAttr(A_cn, displayName);
            } else {
                entry.setAttr(A_cn, localPart);
            }
        }
        // required for ZIMBRA_DEFAULT_PERSON_OC class
        if (!entry.hasAttribute(Provisioning.A_sn)) {
            entry.setAttr(A_sn, localPart);
        }
        entry.setAttr(A_uid, localPart);
        String entryPassword = entry.getAttrString(Provisioning.A_userPassword);
        if (entryPassword != null) {
            //password is a hash i.e. from autoprov; do not set with modify password
            password = null;
        } else if (password != null) {
            //user entered
            checkPasswordStrength(password, null, cos, entry);
        }
        entry.setAttr(Provisioning.A_zimbraPasswordModifiedTime, LdapDateUtil.toGeneralizedTime(new Date()));
        String ucPassword = entry.getAttrString(Provisioning.A_zimbraUCPassword);
        if (ucPassword != null) {
            String encryptedPassword = Account.encrypytUCPassword(entry.getAttrString(Provisioning.A_zimbraId), ucPassword);
            entry.setAttr(Provisioning.A_zimbraUCPassword, encryptedPassword);
        }
        dn = mDIT.accountDNCreate(baseDn, entry.getAttributes(), localPart, domain);
        entry.setDN(dn);
        zlc.createEntry(entry);
        acct = getAccountById(zimbraIdStr, zlc, true);
        if (acct == null) {
            throw ServiceException.FAILURE("unable to get account after creating LDAP account entry: " + emailAddress + ", check ldap log for possible error", null);
        }
        AttributeManager.getInstance().postModify(acctAttrs, acct, callbackContext);
        removeExternalAddrsFromAllDynamicGroups(acct.getAllAddrsSet(), zlc);
        validate(ProvisioningValidator.CREATE_ACCOUNT_SUCCEEDED, emailAddress, acct, skipCountingLicenseQuota);
        if (password != null) {
            setLdapPassword(acct, zlc, password);
        }
        return acct;
    } catch (LdapEntryAlreadyExistException e) {
        throw AccountServiceException.ACCOUNT_EXISTS(emailAddress, dn, e);
    } catch (LdapException e) {
        throw e;
    } catch (AccountServiceException e) {
        throw e;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to create account: " + emailAddress, e);
    } finally {
        LdapClient.closeContext(zlc);
        if (!restoring && acct != null) {
            for (PostCreateAccountListener listener : ProvisioningExt.getPostCreateAccountListeners()) {
                if (listener.enabled()) {
                    listener.handle(acct);
                }
            }
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) GuestAccount(com.zimbra.cs.account.GuestAccount) LdapAccount(com.zimbra.cs.account.ldap.entry.LdapAccount) ZMutableEntry(com.zimbra.cs.ldap.ZMutableEntry) LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) LdapCos(com.zimbra.cs.account.ldap.entry.LdapCos) Cos(com.zimbra.cs.account.Cos) Date(java.util.Date) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) CallbackContext(com.zimbra.cs.account.callback.CallbackContext) PostCreateAccountListener(com.zimbra.cs.account.ProvisioningExt.PostCreateAccountListener) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) Domain(com.zimbra.cs.account.Domain) LdapException(com.zimbra.cs.ldap.LdapException)

Example 12 with AccountServiceException

use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.

the class LdapProvisioning method createDistributionList.

private DistributionList createDistributionList(String listAddress, Map<String, Object> listAttrs, Account creator) throws ServiceException {
    SpecialAttrs specialAttrs = mDIT.handleSpecialAttrs(listAttrs);
    String baseDn = specialAttrs.getLdapBaseDn();
    listAddress = listAddress.toLowerCase().trim();
    String[] parts = listAddress.split("@");
    if (parts.length != 2)
        throw ServiceException.INVALID_REQUEST("must be valid list address: " + listAddress, null);
    String localPart = parts[0];
    String domain = parts[1];
    domain = IDNUtil.toAsciiDomainName(domain);
    listAddress = localPart + "@" + domain;
    validEmailAddress(listAddress);
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
    callbackContext.setCreatingEntryName(listAddress);
    AttributeManager.getInstance().preModify(listAttrs, null, callbackContext, true);
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_DISTRIBUTIONLIST);
        Domain d = getDomainByAsciiName(domain, zlc);
        if (d == null)
            throw AccountServiceException.NO_SUCH_DOMAIN(domain);
        if (!d.isLocal()) {
            throw ServiceException.INVALID_REQUEST("domain type must be local", null);
        }
        ZMutableEntry entry = LdapClient.createMutableEntry();
        entry.mapToAttrs(listAttrs);
        Set<String> ocs = LdapObjectClass.getDistributionListObjectClasses(this);
        entry.addAttr(A_objectClass, ocs);
        String zimbraIdStr = LdapUtil.generateUUID();
        entry.setAttr(A_zimbraId, zimbraIdStr);
        entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
        entry.setAttr(A_mail, listAddress);
        // unlike accounts (which have a zimbraMailDeliveryAddress for the primary,
        // and zimbraMailAliases only for aliases), DLs use zibraMailAlias for both.
        // Postfix uses these two attributes to route mail, and zimbraMailDeliveryAddress
        // indicates that something has a physical mailbox, which DLs don't.
        entry.setAttr(A_zimbraMailAlias, listAddress);
        // by default a distribution list is always created enabled
        if (!entry.hasAttribute(Provisioning.A_zimbraMailStatus)) {
            entry.setAttr(A_zimbraMailStatus, MAIL_STATUS_ENABLED);
        }
        String displayName = entry.getAttrString(Provisioning.A_displayName);
        if (displayName != null) {
            entry.setAttr(A_cn, displayName);
        }
        entry.setAttr(A_uid, localPart);
        setGroupHomeServer(entry, creator);
        String dn = mDIT.distributionListDNCreate(baseDn, entry.getAttributes(), localPart, domain);
        entry.setDN(dn);
        zlc.createEntry(entry);
        DistributionList dlist = getDLBasic(DistributionListBy.id, zimbraIdStr, zlc);
        if (dlist != null) {
            AttributeManager.getInstance().postModify(listAttrs, dlist, callbackContext);
            removeExternalAddrsFromAllDynamicGroups(dlist.getAllAddrsSet(), zlc);
            allDLs.addGroup(dlist);
        } else {
            throw ServiceException.FAILURE("unable to get distribution list after creating LDAP entry: " + listAddress, null);
        }
        return dlist;
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.DISTRIBUTION_LIST_EXISTS(listAddress);
    } catch (LdapException e) {
        throw e;
    } catch (AccountServiceException e) {
        throw e;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to create distribution list: " + listAddress, e);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZMutableEntry(com.zimbra.cs.ldap.ZMutableEntry) LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) Date(java.util.Date) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) CallbackContext(com.zimbra.cs.account.callback.CallbackContext) LdapDomain(com.zimbra.cs.account.ldap.entry.LdapDomain) Domain(com.zimbra.cs.account.Domain) LdapException(com.zimbra.cs.ldap.LdapException) LdapDistributionList(com.zimbra.cs.account.ldap.entry.LdapDistributionList) DistributionList(com.zimbra.cs.account.DistributionList)

Example 13 with AccountServiceException

use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.

the class RenameDomain method createNewDomain.

private Domain createNewDomain() throws ServiceException {
    // Get existing domain attributes
    // make a copy, we don't want to step over our old domain object
    Map<String, Object> domainAttrs = new HashMap<String, Object>(mOldDomain.getAttrs(false));
    // remove attributes that are not needed for createDomain
    domainAttrs.remove(Provisioning.A_o);
    domainAttrs.remove(Provisioning.A_dc);
    domainAttrs.remove(Provisioning.A_objectClass);
    // use a new zimbraId so getDomainById of the old domain will not return this half baked domain
    domainAttrs.remove(Provisioning.A_zimbraId);
    domainAttrs.remove(Provisioning.A_zimbraDomainName);
    domainAttrs.remove(Provisioning.A_zimbraMailStatus);
    // will the new domain get a new create timestamp? or should it inherit the
    // old domain's timestamp?  use new timestamp seems more right.
    domainAttrs.remove(Provisioning.A_zimbraCreateTimestamp);
    // Remove DKIM parameter, user/admin need to recreate DKIM entries as per new domain name.
    domainAttrs.remove("DKIMDomain");
    domainAttrs.remove("DKIMIdentity");
    domainAttrs.remove("DKIMKey");
    domainAttrs.remove("DKIMSelector");
    domainAttrs.remove("DKIMPublicKey");
    // domain level system accounts should be updated to use the new domain name
    String curNotebookAcctName = (String) domainAttrs.get(Provisioning.A_zimbraNotebookAccount);
    String newNotebookAcctName = getNewAddress(curNotebookAcctName);
    if (curNotebookAcctName != null && newNotebookAcctName != null) {
        domainAttrs.remove(Provisioning.A_zimbraNotebookAccount);
        domainAttrs.put(Provisioning.A_zimbraNotebookAccount, newNotebookAcctName);
    }
    // the new domain is created shutdown and rejecting mails
    domainAttrs.put(Provisioning.A_zimbraDomainStatus, Provisioning.DOMAIN_STATUS_SHUTDOWN);
    domainAttrs.put(Provisioning.A_zimbraMailStatus, Provisioning.MAIL_STATUS_DISABLED);
    Domain newDomain = null;
    try {
        debug("Creating new domain %s", mNewDomainName);
        newDomain = mProv.createDomain(mNewDomainName, domainAttrs);
    } catch (AccountServiceException e) {
        if (e.getCode().equals(AccountServiceException.DOMAIN_EXISTS)) {
            newDomain = mProv.get(Key.DomainBy.name, mNewDomainName);
            if (newDomain == null) {
                // this should not happen
                throw ServiceException.FAILURE("failed to load existing domain " + mNewDomainName, null);
            }
            // the new domain already exists, make sure it is the one that was being renamed to
            RenameInfo renameInfo = RenameInfo.load(newDomain, false);
            if (renameInfo == null) {
                // no rename info, indicating that the new domain already exists, and was NOT created
                // by a previous rename domain.  reactivate the old domain and throw an exception
                endRenameDomain(mOldDomain, null);
                throw ServiceException.INVALID_REQUEST("domain " + mNewDomainName + " already exists", null);
            }
            if (!renameInfo.srcDomainName().equals(mOldDomainName)) {
                throw ServiceException.INVALID_REQUEST("domain " + mNewDomainName + " was being renamed from " + renameInfo.srcDomainName() + " it cannot be renamed from " + mOldDomainName + " until the previous rename is finished", null);
            }
            // all is well
            return newDomain;
        } else
            throw e;
    }
    RenameInfo renameInfo = new RenameInfo(mOldDomainName, null, null);
    renameInfo.write(mProv, newDomain);
    return newDomain;
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) HashMap(java.util.HashMap) Domain(com.zimbra.cs.account.Domain)

Example 14 with AccountServiceException

use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.

the class LdapProvisioning method renameUCService.

@Override
public void renameUCService(String zimbraId, String newName) throws ServiceException {
    LdapUCService ucService = (LdapUCService) getUCServiceById(zimbraId, null, false);
    if (ucService == null) {
        throw AccountServiceException.NO_SUCH_UC_SERVICE(zimbraId);
    }
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.RENAME_UCSERVICE);
        String newDn = mDIT.ucServiceNameToDN(newName);
        zlc.renameEntry(ucService.getDN(), newDn);
        ucServiceCache.remove(ucService);
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.UC_SERVICE_EXISTS(newName);
    } catch (LdapException e) {
        throw e;
    } catch (AccountServiceException e) {
        throw e;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to rename ucservice: " + zimbraId, e);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) AccountServiceException(com.zimbra.cs.account.AccountServiceException) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) LdapUCService(com.zimbra.cs.account.ldap.entry.LdapUCService) LdapException(com.zimbra.cs.ldap.LdapException)

Example 15 with AccountServiceException

use of com.zimbra.cs.account.AccountServiceException in project zm-mailbox by Zimbra.

the class LdapProvisioning method createZimlet.

@Override
public Zimlet createZimlet(String name, Map<String, Object> zimletAttrs) throws ServiceException {
    name = name.toLowerCase().trim();
    CallbackContext callbackContext = new CallbackContext(CallbackContext.Op.CREATE);
    AttributeManager.getInstance().preModify(zimletAttrs, null, callbackContext, true);
    ZLdapContext zlc = null;
    try {
        zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.CREATE_ZIMLET);
        String hasKeyword = LdapConstants.LDAP_FALSE;
        if (zimletAttrs.containsKey(A_zimbraZimletKeyword)) {
            hasKeyword = ProvisioningConstants.TRUE;
        }
        ZMutableEntry entry = LdapClient.createMutableEntry();
        entry.mapToAttrs(zimletAttrs);
        entry.setAttr(A_objectClass, "zimbraZimletEntry");
        entry.setAttr(A_zimbraZimletEnabled, ProvisioningConstants.FALSE);
        entry.setAttr(A_zimbraZimletIndexingEnabled, hasKeyword);
        entry.setAttr(A_zimbraCreateTimestamp, LdapDateUtil.toGeneralizedTime(new Date()));
        String dn = mDIT.zimletNameToDN(name);
        entry.setDN(dn);
        zlc.createEntry(entry);
        Zimlet zimlet = lookupZimlet(name, zlc);
        AttributeManager.getInstance().postModify(zimletAttrs, zimlet, callbackContext);
        return zimlet;
    } catch (LdapEntryAlreadyExistException nabe) {
        throw AccountServiceException.ZIMLET_EXISTS(name);
    } catch (LdapException e) {
        throw e;
    } catch (AccountServiceException e) {
        throw e;
    } catch (ServiceException e) {
        throw ServiceException.FAILURE("unable to create zimlet: " + name, e);
    } finally {
        LdapClient.closeContext(zlc);
    }
}
Also used : ZMutableEntry(com.zimbra.cs.ldap.ZMutableEntry) LdapEntryAlreadyExistException(com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException) AccountServiceException(com.zimbra.cs.account.AccountServiceException) Zimlet(com.zimbra.cs.account.Zimlet) LdapZimlet(com.zimbra.cs.account.ldap.entry.LdapZimlet) ZLdapContext(com.zimbra.cs.ldap.ZLdapContext) AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) CallbackContext(com.zimbra.cs.account.callback.CallbackContext) LdapException(com.zimbra.cs.ldap.LdapException) Date(java.util.Date)

Aggregations

AccountServiceException (com.zimbra.cs.account.AccountServiceException)44 ServiceException (com.zimbra.common.service.ServiceException)22 LdapException (com.zimbra.cs.ldap.LdapException)20 LdapEntryAlreadyExistException (com.zimbra.cs.ldap.LdapException.LdapEntryAlreadyExistException)20 ZLdapContext (com.zimbra.cs.ldap.ZLdapContext)20 AuthFailedServiceException (com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException)19 Account (com.zimbra.cs.account.Account)14 ZMutableEntry (com.zimbra.cs.ldap.ZMutableEntry)14 CallbackContext (com.zimbra.cs.account.callback.CallbackContext)13 Date (java.util.Date)13 Domain (com.zimbra.cs.account.Domain)10 HashMap (java.util.HashMap)10 LdapDomain (com.zimbra.cs.account.ldap.entry.LdapDomain)8 LdapEntry (com.zimbra.cs.account.ldap.entry.LdapEntry)5 Cos (com.zimbra.cs.account.Cos)4 Test (org.junit.Test)4 DistributionList (com.zimbra.cs.account.DistributionList)3 GuestAccount (com.zimbra.cs.account.GuestAccount)3 Server (com.zimbra.cs.account.Server)3 Signature (com.zimbra.cs.account.Signature)3