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);
}
}
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);
}
}
}
}
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);
}
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);
}
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());
}
Aggregations