Search in sources :

Example 56 with Config

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

the class LdapProvisioning method updateLastLogon.

private void updateLastLogon(Account acct) throws ServiceException {
    if (EphemeralStore.getFactory() instanceof LdapEphemeralStore.Factory) {
        Config config = Provisioning.getInstance().getConfig();
        long freq = config.getLastLogonTimestampFrequency();
        // never update timestamp if frequency is 0
        if (freq == 0) {
            return;
        }
        Date lastLogon = acct.getLastLogonTimestamp();
        // hasn't passed since the last timestamp was logged
        if (lastLogon != null && (lastLogon.getTime() + freq > System.currentTimeMillis())) {
            return;
        }
    }
    try {
        acct.setLastLogonTimestamp(new Date());
    } catch (ServiceException e) {
        ZimbraLog.account.warn("error updating zimbraLastLogonTimestamp", e);
    }
}
Also used : AccountServiceException(com.zimbra.cs.account.AccountServiceException) AuthFailedServiceException(com.zimbra.cs.account.AccountServiceException.AuthFailedServiceException) ServiceException(com.zimbra.common.service.ServiceException) Config(com.zimbra.cs.account.Config) LdapConfig(com.zimbra.cs.account.ldap.entry.LdapConfig) ExternalLdapConfig(com.zimbra.cs.ldap.LdapServerConfig.ExternalLdapConfig) GalSearchConfig(com.zimbra.cs.gal.GalSearchConfig) LogFactory(com.zimbra.common.util.LogFactory) ZLdapFilterFactory(com.zimbra.cs.ldap.ZLdapFilterFactory) Date(java.util.Date)

Example 57 with Config

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

the class ZimbraLmtpBackend method checkDedupeCacheSize.

/**
     * If the configured Message-ID cache size has changed, create a new cache and copy
     * values from the old one.
     */
private void checkDedupeCacheSize() {
    try {
        Config config = Provisioning.getInstance().getConfig();
        int cacheSize = config.getMessageIdDedupeCacheSize();
        long entryTimeout = config.getMessageIdDedupeCacheTimeout();
        synchronized (ZimbraLmtpBackend.class) {
            Map<String, Set<Integer>> newMap = null;
            if (receivedMessageIDs == null) {
                // if non-zero entry timeout is specified then use a timeout map, else use an lru map
                receivedMessageIDs = entryTimeout == 0 ? new LruMap<String, Set<Integer>>(cacheSize) : new TimeoutMap<String, Set<Integer>>(entryTimeout);
            } else if (receivedMessageIDs instanceof LruMap) {
                if (entryTimeout != 0) {
                    // change to a timeout map
                    newMap = MapUtil.newTimeoutMap(entryTimeout);
                } else if (((LruMap) receivedMessageIDs).getMaxSize() != cacheSize) {
                    // adjust lru map size
                    newMap = MapUtil.newLruMap(cacheSize);
                }
            } else if (receivedMessageIDs instanceof TimeoutMap) {
                if (entryTimeout == 0) {
                    // change to a lru map
                    newMap = MapUtil.newLruMap(cacheSize);
                } else {
                    ((TimeoutMap) receivedMessageIDs).setTimeout(entryTimeout);
                }
            }
            if (newMap != null) {
                // Copy entries from the old map to the new one.  The old map
                // is iterated in order from least-recently accessed to last accessed.
                // If the new map size is smaller, we'll get the latest entries.
                newMap.putAll(receivedMessageIDs);
                receivedMessageIDs = newMap;
            }
        }
    } catch (ServiceException e) {
        ZimbraLog.lmtp.warn("Unable to update dedupe cache size.", e);
        // create an empty lru map if it doesn't exist already.
        synchronized (ZimbraLmtpBackend.class) {
            if (receivedMessageIDs == null) {
                receivedMessageIDs = new LruMap<String, Set<Integer>>(0);
            }
        }
    }
}
Also used : LruMap(com.zimbra.common.util.LruMap) Set(java.util.Set) HashSet(java.util.HashSet) ServiceException(com.zimbra.common.service.ServiceException) DeliveryServiceException(com.zimbra.common.service.DeliveryServiceException) MailServiceException(com.zimbra.cs.mailbox.MailServiceException) Config(com.zimbra.cs.account.Config) DebugConfig(com.zimbra.common.localconfig.DebugConfig) TimeoutMap(com.zimbra.common.util.TimeoutMap)

Example 58 with Config

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

the class TestJaxbProvisioning method testGetConfig.

@Test
public void testGetConfig() throws Exception {
    ZimbraLog.test.debug("Starting test %s", testName());
    Config cfg = prov.getConfig();
    assertNotNull("Config", cfg);
    cfg = prov.getConfig("zimbra_user");
    assertNotNull("Config", cfg);
}
Also used : Config(com.zimbra.cs.account.Config) Test(org.junit.Test)

Example 59 with Config

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

the class TestProvAlias method testAliasDomain_Case3.

/*
        Case 3:
            Alias1@aliasdomain.com points at account1@localdomain.com.  (there is no alias1@localdomain.com alias)
            Global config zimbra default domain is set to localdomain.com.
            Auth is attempted with "alias1".  Does it work?  NO
            
    */
@Test
public void testAliasDomain_Case3() throws Exception {
    String testName = getTestName();
    String acctLocalPart = "account1";
    String acctName = getEmail(acctLocalPart, LOCAL_DOMAIN_NAME, testName);
    String aliasLocalPart = "alias1";
    String aliasName = getEmail(aliasLocalPart, ALIAS_DOMAIN_NAME, testName);
    Config config = prov.getConfig();
    String origDefaltDomainName = config.getAttr(Provisioning.A_zimbraDefaultDomainName);
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraDefaultDomainName, LOCAL_DOMAIN_NAME);
    prov.modifyAttrs(config, attrs);
    Account acct = prov.createAccount(acctName, PASSWORD, null);
    prov.addAlias(acct, aliasName);
    String authAs = getLocalPart(aliasLocalPart, testName);
    Account acctGot = prov.get(AccountBy.name, authAs);
    assertNull(acctGot);
    // put the orig back
    attrs.clear();
    attrs.put(Provisioning.A_zimbraDefaultDomainName, "");
    prov.modifyAttrs(config, attrs);
}
Also used : Account(com.zimbra.cs.account.Account) HashMap(java.util.HashMap) Config(com.zimbra.cs.account.Config)

Example 60 with Config

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

the class TestProvAlias method cleanup.

@AfterClass
public static void cleanup() throws Exception {
    Config config = prov.getConfig();
    Map<String, Object> attrs = new HashMap<String, Object>();
    attrs.put(Provisioning.A_zimbraDefaultDomainName, origDefaultDomainName);
    prov.modifyAttrs(config, attrs);
    Cleanup.deleteAll(baseDomainName());
}
Also used : HashMap(java.util.HashMap) Config(com.zimbra.cs.account.Config)

Aggregations

Config (com.zimbra.cs.account.Config)73 HashMap (java.util.HashMap)24 Provisioning (com.zimbra.cs.account.Provisioning)10 Test (org.junit.Test)8 ServiceException (com.zimbra.common.service.ServiceException)7 Account (com.zimbra.cs.account.Account)7 RetentionPolicy (com.zimbra.soap.mail.type.RetentionPolicy)7 Element (com.zimbra.common.soap.Element)6 Policy (com.zimbra.soap.mail.type.Policy)6 Cos (com.zimbra.cs.account.Cos)5 Server (com.zimbra.cs.account.Server)5 Domain (com.zimbra.cs.account.Domain)4 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)4 Pair (com.zimbra.common.util.Pair)3 HashSet (java.util.HashSet)3 SMTPMessage (com.sun.mail.smtp.SMTPMessage)2 ZFilterAction (com.zimbra.client.ZFilterAction)2 ZFileIntoAction (com.zimbra.client.ZFilterAction.ZFileIntoAction)2 ZFilterCondition (com.zimbra.client.ZFilterCondition)2 ZHeaderCondition (com.zimbra.client.ZFilterCondition.ZHeaderCondition)2