Search in sources :

Example 76 with Provisioning

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

the class DataSourceCallback method scheduleCos.

/**
     * Updates data source schedules for all accounts that are on the current server
     * and in the given COS.
     */
private void scheduleCos(Cos cos) throws ServiceException {
    ZimbraLog.datasource.info("Updating schedule for all DataSources for all accounts in COS %s.", cos.getName());
    List<Account> accts;
    Provisioning prov = Provisioning.getInstance();
    // Look up all account id's for this server
    if (prov instanceof LdapProv)
        accts = lookupAccountsFromLDAP(prov, cos.getId());
    else
        accts = lookupAccountsFromDB(prov);
    // Update schedules for all data sources on this server
    for (Account account : accts) {
        if (account != null && Provisioning.ACCOUNT_STATUS_ACTIVE.equals(account.getAccountStatus(prov))) {
            Cos accountCos = prov.getCOS(account);
            if (accountCos != null && cos.getId().equals(accountCos.getId())) {
                scheduleAccount(account);
            }
        }
    }
}
Also used : Account(com.zimbra.cs.account.Account) Cos(com.zimbra.cs.account.Cos) Provisioning(com.zimbra.cs.account.Provisioning) LdapProv(com.zimbra.cs.account.ldap.LdapProv)

Example 77 with Provisioning

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

the class AuthMechanism method newInstance.

public static AuthMechanism newInstance(Account acct, Map<String, Object> context) throws ServiceException {
    String authMechStr = AuthMech.zimbra.name();
    if (!acct.isIsExternalVirtualAccount()) {
        Provisioning prov = Provisioning.getInstance();
        Domain domain = prov.getDomain(acct);
        // see if it specifies an alternate auth
        if (domain != null) {
            String am;
            Boolean asAdmin = context == null ? null : (Boolean) context.get(AuthContext.AC_AS_ADMIN);
            if (asAdmin != null && asAdmin) {
                am = domain.getAuthMechAdmin();
                if (am == null) {
                    // fallback to zimbraAuthMech if zimbraAuthMechAdmin is not specified
                    am = domain.getAuthMech();
                }
            } else {
                am = domain.getAuthMech();
            }
            if (am != null) {
                authMechStr = am;
            }
        }
    }
    if (authMechStr.startsWith(AuthMech.custom.name() + ":")) {
        return new CustomAuth(AuthMech.custom, authMechStr);
    } else {
        try {
            AuthMech authMech = AuthMech.fromString(authMechStr);
            switch(authMech) {
                case zimbra:
                    return new ZimbraAuth(authMech);
                case ldap:
                case ad:
                    return new LdapAuth(authMech);
                case kerberos5:
                    return new Kerberos5Auth(authMech);
            }
        } catch (ServiceException e) {
            ZimbraLog.account.warn("invalid auth mech", e);
        }
        ZimbraLog.account.warn("unknown value for " + Provisioning.A_zimbraAuthMech + ": " + authMechStr + ", falling back to default mech");
        return new ZimbraAuth(AuthMech.zimbra);
    }
}
Also used : AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) Domain(com.zimbra.cs.account.Domain) Provisioning(com.zimbra.cs.account.Provisioning)

Example 78 with Provisioning

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

the class FreeBusyProviderURLCheck method preModify.

/* (non-Javadoc)
     * @see com.zimbra.cs.account.AttributeCallback#preModify(com.zimbra.cs.account.callback.CallbackContext, java.lang.String, java.lang.Object, java.util.Map, com.zimbra.cs.account.Entry)
     */
@Override
public void preModify(CallbackContext context, String attrName, Object attrValue, Map attrsToModify, Entry entry) throws ServiceException {
    String value = (String) attrValue;
    if (StringUtil.isNullOrEmpty(value)) {
        // zimbraFreebusyExternalZimbraURL
        return;
    }
    Provisioning prov = Provisioning.getInstance();
    if (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExchangeURL) && (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExternalZimbraURL))) {
        throw ServiceException.INVALID_REQUEST("Setting both " + Provisioning.A_zimbraFreebusyExchangeURL + " and " + Provisioning.A_zimbraFreebusyExternalZimbraURL + " is not allowed", null);
    } else if (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExchangeURL)) {
        String[] zimbraFbExtUrl = prov.getConfig().getFreebusyExternalZimbraURL();
        if (zimbraFbExtUrl != null && zimbraFbExtUrl.length > 0) {
            throw ServiceException.INVALID_REQUEST("Setting both " + Provisioning.A_zimbraFreebusyExchangeURL + " and " + Provisioning.A_zimbraFreebusyExternalZimbraURL + " is not allowed", null);
        }
    } else if (attrsToModify.containsKey(Provisioning.A_zimbraFreebusyExternalZimbraURL)) {
        String exchngFbUrl = prov.getConfig().getFreebusyExchangeURL();
        if (!StringUtil.isNullOrEmpty(exchngFbUrl)) {
            throw ServiceException.INVALID_REQUEST("Setting both " + Provisioning.A_zimbraFreebusyExchangeURL + " and " + Provisioning.A_zimbraFreebusyExternalZimbraURL + " is not allowed", null);
        }
    }
}
Also used : Provisioning(com.zimbra.cs.account.Provisioning)

Example 79 with Provisioning

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

the class AccountStatus method handleAccountStatusClosed.

private void handleAccountStatusClosed(Account account) throws ServiceException {
    Provisioning prov = Provisioning.getInstance();
    String status = account.getAccountStatus(prov);
    if (status.equals(Provisioning.ACCOUNT_STATUS_CLOSED)) {
        ZimbraLog.misc.info("removing account address and all its aliases from all distribution lists");
        String[] addrToRemove = new String[] { account.getName() };
        Set<String> dlIds = prov.getDistributionLists(account);
        for (String dlId : dlIds) {
            DistributionList dl = prov.get(Key.DistributionListBy.id, dlId);
            if (dl != null) {
                try {
                    // will remove all members that are aliases of the account too
                    prov.removeMembers(dl, addrToRemove);
                } catch (ServiceException se) {
                    if (AccountServiceException.NO_SUCH_MEMBER.equals(se.getCode())) {
                        ZimbraLog.misc.debug("Member not found in dlist; skipping", se);
                    } else {
                        throw se;
                    }
                }
            }
        }
    }
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) ServiceException(com.zimbra.common.service.ServiceException) Provisioning(com.zimbra.cs.account.Provisioning) DistributionList(com.zimbra.cs.account.DistributionList)

Example 80 with Provisioning

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

the class AdminGroup method postModify.

@Override
public void postModify(CallbackContext context, String attrName, Entry entry) {
    if (!(entry instanceof DistributionList))
        return;
    Provisioning prov = Provisioning.getInstance();
    if (!(prov instanceof LdapProv))
        return;
    DistributionList group = (DistributionList) entry;
    ((LdapProv) prov).removeFromCache(group);
}
Also used : Provisioning(com.zimbra.cs.account.Provisioning) LdapProv(com.zimbra.cs.account.ldap.LdapProv) DistributionList(com.zimbra.cs.account.DistributionList)

Aggregations

Provisioning (com.zimbra.cs.account.Provisioning)532 Account (com.zimbra.cs.account.Account)216 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)158 Element (com.zimbra.common.soap.Element)144 ServiceException (com.zimbra.common.service.ServiceException)96 BeforeClass (org.junit.BeforeClass)93 MockProvisioning (com.zimbra.cs.account.MockProvisioning)89 Server (com.zimbra.cs.account.Server)83 HashMap (java.util.HashMap)76 Domain (com.zimbra.cs.account.Domain)70 SoapProvisioning (com.zimbra.cs.account.soap.SoapProvisioning)53 Mailbox (com.zimbra.cs.mailbox.Mailbox)50 Cos (com.zimbra.cs.account.Cos)32 Test (org.junit.Test)30 NamedEntry (com.zimbra.cs.account.NamedEntry)25 AuthToken (com.zimbra.cs.account.AuthToken)23 Group (com.zimbra.cs.account.Group)23 ArrayList (java.util.ArrayList)23 AccountServiceException (com.zimbra.cs.account.AccountServiceException)22 DistributionList (com.zimbra.cs.account.DistributionList)22